Next.js — The Full-Stack React Framework for the Web
Next.js is the most popular React framework for building full-stack web applications. It provides server-side rendering, static generation, API routes, file-based routing, and React Server Components — making React production-ready out of the box.
What it is
Next.js is a React framework by Vercel that handles the full stack: server-side rendering (SSR), static site generation (SSG), API routes, and React Server Components. It uses file-based routing where the directory structure under app/ defines your URL paths.
Next.js is the default choice for teams building React applications that need SEO, fast initial page loads, and a unified frontend-backend codebase. It powers sites from personal blogs to large-scale e-commerce platforms.
How it saves time or tokens
Next.js eliminates the need to configure Webpack, Babel, and SSR plumbing manually. React Server Components let you fetch data on the server without sending the fetch logic to the browser, reducing client-side JavaScript. The built-in image optimization, font loading, and code splitting mean fewer manual performance tweaks.
How to use
- Create a new Next.js project with create-next-app.
- Add pages by creating files in the app/ directory.
- Deploy to Vercel or any Node.js hosting.
# Create a new project
npx create-next-app@latest my-app
cd my-app
npm run dev
# Open http://localhost:3000
Example
// app/page.tsx - A Server Component by default
export default async function Home() {
const posts = await fetch('https://api.example.com/posts').then(r => r.json());
return (
<main>
<h1>Blog</h1>
{posts.map((post: any) => (
<article key={post.id}>
<h2>{post.title}</h2>
<p>{post.excerpt}</p>
</article>
))}
</main>
);
}
Related on TokRepo
- AI coding tools — AI assistants that understand Next.js project structure
- Featured workflows — Discover popular developer tool configurations
Common pitfalls
- Mixing client and server components incorrectly causes hydration errors. Mark interactive components with 'use client' and keep data-fetching in server components.
- The app/ router and pages/ router cannot coexist for the same route. Migrate incrementally but do not duplicate route paths.
- Large dependency bundles negate SSR performance gains. Use next/dynamic for lazy loading heavy client-side libraries.
Frequently Asked Questions
The app/ router (introduced in Next.js 13) uses React Server Components, nested layouts, and streaming by default. The pages/ router is the older approach using getServerSideProps and getStaticProps. New projects should use the app/ router. The pages/ router remains supported for backward compatibility.
No. Next.js can be deployed to any Node.js hosting, Docker container, or serverless platform. Vercel provides the smoothest deployment experience since they build Next.js, but AWS, Google Cloud, and self-hosted Node.js servers work fine.
Next.js renders pages on the server by default, so search engine crawlers receive fully rendered HTML. The Metadata API lets you define title, description, and Open Graph tags per page. Combined with automatic sitemap generation, Next.js provides strong SEO foundations out of the box.
Yes. Next.js API routes (route.ts files in the app/ directory) let you build REST or GraphQL endpoints. However, for API-only projects without a frontend, a lighter framework like Express or Fastify may be more appropriate.
React Server Components run on the server and send rendered HTML to the browser without the component JavaScript. This reduces client-side bundle size and lets you access databases or file systems directly in components. Interactive parts still use client components with 'use client' directive.
Citations (3)
- Next.js GitHub— Next.js provides SSR, SSG, API routes, and React Server Components
- Next.js Documentation— Next.js app router and React Server Components documentation
- React Official Docs— React Server Components reduce client-side JavaScript by running on the server
Related on TokRepo
Discussion
Related Assets
Conda — Cross-Platform Package and Environment Manager
Install, update, and manage packages and isolated environments for Python, R, C/C++, and hundreds of other languages from a single tool.
Sphinx — Python Documentation Generator
Generate professional documentation from reStructuredText and Markdown with cross-references, API autodoc, and multiple output formats.
Neutralinojs — Lightweight Cross-Platform Desktop Apps
Build desktop applications with HTML, CSS, and JavaScript using a tiny native runtime instead of bundling Chromium.