Next.js

This content was generated with the assistance of AI and should be verified against the official documentation before being relied on in production.

The reference material consulted while preparing these pages is listed in the section bibliography.

This section is written against Next.js 16.3 (16.3.8 was the latest release on 2026-10-03, when every version, URL and example in the section was checked, and the official documentation reported @doc-version 16.3.8), React 19.3 (19.3.0), Node.js 20.9 or later and TypeScript 5.1 or later. It describes the App Router as the primary model and the Pages Router wherever an existing application still uses it. Two caching models coexist in 16.3: the previous model (the default) and the opt-in Cache Components model (cacheComponents: true); every page that touches caching says which one each example uses.

Next.js publishes one major version a year and gives each one a long-term support life cycle. On 2026-10-03 the support policy listed Next.js 16.x (released 2025-10-21) as Active LTS — new features, bug fixes and security patches until Next.js 17 ships — and Next.js 15.x (released 2024-10-21) as Maintenance LTS, which receives only critical bug fixes and security updates, as semver-minor releases, for two years from its first release; 14.x and older are unsupported. Patch releases are frequent, and several of them in 2026 were security releases, so pin an exact version and read the release notes before updating. The Release Cadence and Support Policy section and the What’s Changed & Upgrading page cover the details.

What Next.js is

Next.js is an open-source React framework, maintained by Vercel and developed in the open on GitHub, for building full-stack web applications. React describes the user interface as components; Next.js supplies everything around them that a production site needs:

  • file-system routing: the App Router (app/, recommended) built on React Server Components, with the older Pages Router (pages/) still supported

  • React Server Components, Client Components and Server Functions (Server Actions)

  • every rendering strategy — server-side rendering, client-side rendering, static site generation, incremental static regeneration and Partial Prerendering — with streaming and hydration

  • a multi-layer cache with explicit revalidation APIs

  • Route Handlers for HTTP APIs, and Proxy (called Middleware before Next.js 16) in front of every request

  • image, font and script optimisation, and the Metadata API for SEO

  • Turbopack, the default bundler since Next.js 16, and the React Compiler

  • deployment to a Node.js server, a Docker container, static hosting, or a platform through an adapter

A new project is one command away:

npx create-next-app@latest bookshelf --yes
cd bookshelf
npm run dev

Source: Installation

Who this section is for

The section is for developers who already know React and want to build and ship React applications with Next.js:

  • React developers moving from a client-only single-page application (for example a Vite SPA with React Router) to server rendering, static generation and React Server Components

  • readers of older Next.js books and tutorials, which mostly target the Pages Router and Next.js 12 or 13, who need to know what changed (async request APIs, proxy.ts, Turbopack, the new caching APIs, Auth.js v5)

  • back-end developers on this site’s FastAPI, NestJS or Django sections who want a front end for the same Bookshelf API, and teams choosing between Next.js and other React or non-React frameworks

It does not re-teach React itself: components, Hooks, Suspense, Actions and the React Compiler are covered in the React Reference, and the pages here link there instead of repeating it.

The Bookshelf scenario

Every example builds one small, original application, Bookshelf: a Next.js App Router front end in the same domain as the Python FastAPI, NestJS and Django sections, so that the stacks can be compared page by page. It extends the Next.js files sketched on NestJS vs Next.js and has:

  • a public catalogue of books, authors and reviews: statically generated book pages (generateStaticParams with ISR or 'use cache'), a server-rendered search page that reads searchParams, and client-side filters

  • a personalised header and a "my reviews" area, rendered dynamically from cookies() and streamed with Suspense

  • review creation and editing with Server Actions, useActionState, useOptimistic and updateTag

  • an intercepted-route modal for book covers and a parallel-route slot

  • sign-in with Auth.js v5, a Data Access Layer, and forbidden() / unauthorized()

  • a JSON API built with Route Handlers, plus a backend-for-frontend variant that proxies the FastAPI, NestJS or Django Bookshelf API

  • proxy.ts for locale detection (app/[locale]) and an optimistic authentication check

  • next/image covers, next/font, Tailwind CSS v4, and the Metadata API with Open Graph images, a sitemap and robots.txt

  • tests with Vitest and Playwright

  • a Docker standalone deployment, and a static-export variant of the catalogue

Diagram titled Bookshelf: the Next.js App Router front end built across this section. Three kinds of client sit at the top: the browser (HTML first paint, then hydration; Client Components, Link and the router cache), crawlers and link previews (sitemap.ts, robots.ts, metadata and Open Graph images) and API clients (curl and mobile apps calling GET /api/books). All of them reach a CDN or host serving static HTML and immutable assets, a Docker standalone server, or a static export of the catalogue. Below it, the Next.js server runs proxy.ts first (locale detection and redirect to /en or /es, optimistic session-cookie check), then the App Router under app/[locale]: the (shop) route group with the catalogue, search and statically generated or cached book pages; the (account) route group with the personalised header and my reviews, rendered dynamically from cookies and streamed with Suspense; the @modal slot with the intercepted (.)books/[id] cover modal; Route Handlers in app/api/books/route.ts; and Server Actions that create and edit reviews and call updateTag. These use the server-only Data Access Layer in lib/dal.ts (Auth.js v5 auth, requireUser, DTOs, forbidden and unauthorized) and the cache layers (Cache Components or the previous model, cacheLife, cacheTag, revalidateTag, updateTag). At the bottom are the backing services: the Bookshelf data read through lib/books.ts, an optional back-end API (the FastAPI, NestJS or Django Bookshelf, proxied server-side as a backend for frontend) and the identity provider for OAuth sign-in, with secrets kept only in server environment variables. A footnote lists the other parts of the scenario: next/image covers, next/font, Tailwind v4, i18n messages, instrumentation.ts, and Vitest and Playwright tests.
Figure 1. The Bookshelf application: clients, the Next.js server and its backing services

The final project layout (app/[locale]/(shop), app/[locale]/(account), @modal, components/, lib/dal.ts, lib/actions/, proxy.ts, instrumentation.ts and next.config.ts) is assembled on Project Structure. Stripe and headless-CMS commerce concepts are covered by a separate worked example on Advanced Patterns.

Reading path

Read the React Reference first if components, props, state, effects, Hooks and Suspense are new; in particular Server Rendering, SSG and React Server Components explains the React primitives that Next.js automates. Then read this section in order the first time, and use it as a reference afterwards:

  1. Foundations: what a React framework adds, a first project, the project structure, and configuration, TypeScript and environment variables.

  2. Routing: the file-system router, layouts and special files, dynamic routes and route groups, linking and navigation, parallel and intercepting routes, redirects, rewrites and Proxy, and internationalisation.

  3. Rendering: the rendering model, Server and Client Components, server-side rendering, streaming, client-side rendering, static site generation, incremental static regeneration, hydration, and Partial Prerendering with Cache Components.

  4. Data: data fetching, Server Actions and mutations, caching, and Route Handlers with the backend-for-frontend pattern.

  5. UI and optimisations: styling, images, fonts and scripts, metadata and SEO, and performance.

  6. Security and authentication: authentication and authorisation, then data security and Content Security Policy.

  7. Tooling, testing and operations: Turbopack and the compiler, testing, and debugging, instrumentation and observability.

  8. Production: deployment and self-hosting, the Pages Router, and what changed and how to upgrade.

  9. Beyond the basics: advanced patterns.

Readers who know Next.js from older books or tutorials can start with What’s Changed & Upgrading and then jump to the topics they use. The React + Next.js Cheat Sheet condenses React and Next.js onto one printable page.

mindmap root((Next.js)) Foundations Introduction and architecture Getting started Project structure Configuration and env vars Routing Routing fundamentals Layouts and special files Dynamic routes and groups Linking and navigation Parallel and intercepting routes Redirects rewrites and Proxy Internationalization Rendering Rendering fundamentals Server and Client Components Server-side rendering Streaming and Suspense Client-side rendering Static site generation Incremental static regeneration Hydration PPR and Cache Components Data Data fetching Server Actions Caching Route Handlers and BFF UI and optimisations Styling Images fonts and scripts Metadata and SEO Performance and Web Vitals Security Authentication and authorization Data security and CSP Tooling and testing Turbopack and the compiler Testing Debugging and observability Production Deployment and self-hosting Pages Router Upgrading Beyond the basics Advanced patterns Cheat sheet
Figure 2. The section at a glance

The Next.js pages link to existing material instead of repeating it, and cover only what Next.js adds.

Topic Where it lives How the Next.js section relates

React fundamentals: components, Hooks, Suspense, Actions, the React Compiler, server rendering

React Reference, in particular Server Rendering, SSG and React Server Components, Routing, Getting Started with React, Data Fetching, Forms and Actions, Build and Deployment and Code Splitting and Suspense

The Next.js pages link here for React itself and explain only how Next.js builds on each primitive.

The NestJS comparison and the first Next.js Bookshelf sketch

NestJS vs Next.js and NestJS

The Bookshelf scenario extends the files sketched there (app/books/page.tsx, lib/books-api.ts, app/api/books/route.ts, a Server Action); the Route Handlers & Backend for Frontend page links back to it.

TypeScript and JSX, JavaScript

TypeScript, including JSX and Frameworks, and JavaScript Development

The configuration page links here instead of re-explaining TypeScript or JSX, and shows only the Next.js plugin, typed routes and generated types.

Node.js runtime: modules, the event loop, streams, HTTP, worker_threads, deployment

Node.js

Linked for the runtime Next.js runs on; the Next.js pages cover only what Next.js adds.

Server rendering in other stacks

Vue: Server-Side Rendering (Nuxt) and Angular: Production and Performance (@angular/ssr, incremental hydration)

The rendering pages compare them in "the same idea in other stacks" notes, and the introduction’s framework table links them.

Styling, HTML and CSS, accessibility, CORS and browser testing

Tailwind CSS, Sass: Compilation, HTML & CSS, Accessibility, CORS and End-to-End Testing in Real Browsers

Linked from the styling, metadata and SEO, Route Handlers and testing pages, which cover only the Next.js side.

OAuth 2.0, OpenID Connect, JWT and the browser-based-app BFF pattern

OAuth Reference, including Browser-Based Apps, OpenID Connect and JWT & JOSE

The authentication page links here for protocol theory and documents Auth.js, which no other page on this site covers.

GraphQL and the Apollo Client SSR cache

GraphQL, including Apollo Client Configuration

The data-fetching page links here and shows only @apollo/client-integration-nextjs.

The same Bookshelf API in Python and TypeScript back ends

Python FastAPI (including Static Files, Templates & Frontend), NestJS and Django

The Next.js front end can consume any of them through the backend-for-frontend page.

Architecture: layering front end and back end, choosing a stack

Layering Backend & Frontend and Starting a New Project

The introduction links here for the "SSR hybrid" option and the choice of stack.

Containers, orchestration and cloud hosting

Docker, Kubernetes Reference, AWS: Developer Tools and DevOps (Amplify Hosting), AWS: CloudFront CDN, Azure: App Service and Functions (Static Web Apps) and Google Cloud

The deployment page shows only the Next.js-specific parts (output: 'standalone', static export, adapters, self-hosting caches).

AI chat front ends and AI-assisted prototyping

Conversational Channels and AI-Assisted Development

The advanced-patterns page links here for Next.js chat UIs and AI-generated prototypes.

Related topics that are planned but not yet part of this site are mentioned in prose only, where relevant: a programming languages comparison (issue #196), a cloud providers comparison for hosting choices (#201), API managers, secret managers, gateways and scaling (#184), e-commerce platforms (#246) and documentation tools such as the React-based Docusaurus (#247).

Bibliography

Every source used to prepare this section is listed here, each linked to its official site. Individual pages list the subset they derive from under their own == References heading.

Books

Both books target the Pages Router on Next.js versions that are no longer supported (12 and 13.2, with React 17 and 18). They were consulted for concept coverage, narrative and structure only; no text, code listing, figure or sample project is taken from them, every example in this section is written against the current official documentation, and the pages point out where the books are outdated.

Official Next.js documentation and resources

Published at nextjs.org/docs (the machine-readable index is llms.txt, @doc-version 16.3.8 on 2026-10-03), grouped as the documentation is:

Official React documentation

Published at react.dev:

Ecosystem projects used by the pages

Specifications and standards

The books are consulted references for concept coverage, narrative and structure; they are not reproduced here. The official documentation linked above is authoritative, and where the two differ, the documentation of the version you run prevails.