Next.js is an open-source framework built on React for creating web applications that render on the server, at build time or in the browser, chosen per route or even per component. Among web applications frameworks, it is a meta-framework: React supplies the component model, while Next.js adds file-based routing, rendering strategies, data fetching, bundling and deployment conventions.
The framework became popular because it solves problems that a plain single-page application leaves open, especially slow first loads and weak indexability of client-rendered pages. Its current architecture, the App Router, is built around React Server Components, while the older Pages Router remains supported for existing projects.
How Next.js renders a request
In the App Router, every component is a React Server Component by default. It runs only on the server, can read databases or files directly and sends a serialized result to the browser, so its code never enters the client bundle. Components marked with the "use client" directive are also rendered to HTML on the server but then hydrated in the browser to become interactive.
For each request, the framework resolves the route from the folder structure, renders the server tree, streams HTML in chunks as data becomes available and sends the payload that lets React attach event handlers. Suspense boundaries define which parts may appear later without holding up the rest of the page.
| Building block | Role | Where it runs |
|---|---|---|
| Server Components | Fetch data and render markup | Server or build machine |
| Client Components | Handle state, effects and events | Server for HTML, then browser |
| Route handlers | Expose HTTP endpoints | Server or edge runtime |
| Server Actions | Run mutations called from forms | Server |
| Middleware | Rewrite, redirect or check requests early | Edge-style runtime |
| Layouts | Share UI that persists across navigation | Server by default |
Rendering strategies and when each applies
The central idea of Next.js is that one application can mix rendering strategies. A marketing page can be static, a product page can be regenerated periodically and a dashboard can be rendered fresh for each user, all in the same codebase.
| Strategy | When HTML is produced | Best fit |
|---|---|---|
| SSG | At build time | Documentation, landing pages, blogs |
| ISR | At build, then regenerated after a set interval or on demand | Catalogs and content that changes hourly |
| SSR | On every request | Personalized or real-time pages |
| Streaming SSR | Progressively during the request | Pages with slow independent data sources |
| Client-side rendering | In the browser after load | Highly interactive widgets |
| Partial prerendering | Static shell plus dynamic holes | Mostly static pages with small personal parts |
Caching rules decide which strategy a route actually uses. Reading request data such as cookies or headers makes a route dynamic, while a revalidation interval, for example 60 seconds, turns it into incremental static regeneration. Defaults have changed between major versions, so explicit cache settings are safer than relying on implicit behavior.
Comparison with neighboring frameworks
Next.js competes with other full-stack meta-frameworks and also with plain client-side setups. The comparison below focuses on architectural choices rather than popularity.
| Approach | UI library | Default rendering | Typical strength |
|---|---|---|---|
| Next.js | React | Server Components with streaming | Wide rendering choice, large ecosystem |
| React SPA with a bundler | React | Client-side rendering | Simple hosting as static files |
| Nuxt | Vue.js | Universal SSR | Similar model for Vue teams |
| SvelteKit | Svelte | SSR with progressive enhancement | Small client bundles |
| Astro | Several | Static HTML with islands | Content-heavy sites with little JavaScript |
Choosing Next.js makes most sense when a team already uses React and needs both SEO-friendly pages and rich interactivity. For a mostly static content site, an islands architecture often ships far less JavaScript.
Routing, data and deployment in practice
Routes are defined by folders inside the app directory. A page file makes a segment publicly reachable, layout wraps child segments, loading provides a Suspense fallback and error defines an error boundary. Dynamic segments such as [slug] capture URL parameters.
- Data fetching happens directly in async Server Components, without a separate API layer for internal data.
- Image, font and script components handle resizing, font self-hosting and loading priority.
- Deployment targets include managed platforms, a Node.js server, containers and static export with reduced features.
- Edge runtime support allows some routes to run close to users, with a restricted set of Node.js APIs.
Self-hosting is fully possible, but features such as image optimization, ISR caches and middleware need careful configuration on infrastructure other than the platform maintained by the framework’s vendor.
Limitations and common pitfalls
The flexibility of Next.js brings a real learning curve. Most problems arise from misunderstanding where code runs and what is cached.
| Problem | Cause | Remedy |
|---|---|---|
| Hydration mismatch warnings | Server and browser render different output | Avoid dates, random values or browser APIs during render |
| Stale data in production | Route cached more than expected | Set revalidation or dynamic rendering explicitly |
| Large client bundles | “use client” placed too high in the tree | Push client boundaries down to leaf components |
| Secrets exposed | Server-only code imported into client modules | Use server-only modules and environment rules |
| Slow builds | Thousands of statically generated pages | Use ISR or on-demand generation |
Frequent major releases also mean that tutorials age quickly. Teams should check which router and version an example targets before copying its patterns.
A plain-language summary
React is a toolkit for building the parts of a web page, like buttons, menus and product cards. Next.js is the workshop around that toolkit: it decides where each page is prepared, how pages link together and how they reach visitors quickly.
Some pages can be prepared in advance like printed brochures, while others are made fresh for each visitor like a custom order. Next.js lets one website use both methods at the same time, so pages load fast and still show up to date information.
An example from practice
A mid-sized online furniture retailer runs its storefront as a client-rendered React application. Product pages show an empty frame for over a second on phones, and search engines index the product descriptions inconsistently.
The team migrates to Next.js with the App Router. Category and product pages become statically generated with a 10-minute revalidation interval, the shopping cart and account area are rendered dynamically for each user, and the image gallery stays a small Client Component. Price updates from the inventory system trigger on-demand revalidation of the affected products.
After the migration, product pages arrive as complete HTML on the first request, the amount of JavaScript sent to phones falls noticeably, and search results begin to show accurate descriptions and prices.