Next.js is a production-ready React framework built by Vercel that enables server-side rendering, static site generation, and full-stack capabilities through a file-system-based router. It extends React with powerful features like automatic code splitting, image and font optimization, built-in API routes, and support for both the App Router (with React Server Components) and the Pages Router. As of Next.js 15/16, the framework shifted to explicit opt-in caching: fetch requests are no longer cached by default, and the new use cache directive with cacheTag/cacheLife APIs provide fine-grained cache control. Understanding that Next.js blurs the line between client and server is crucial: components run on the server by default in App Router, while "use client" enables interactivity exactly where needed.
What This Cheat Sheet Covers
This topic spans 25 focused tables and 204 indexed concepts, 138 flashcards, 8 practice tests with 254 questions. Below is a complete table-by-table outline of this topic, spanning foundational concepts through advanced details.
A jump-to index of every table row in this cheat sheet.
An interactive map of every table and concept in this topic.
Table 1: Project Setup and Initialization
Everything starts here: the commands that scaffold a new app, run the dev server, and produce a production build. Two of these shifted recently. Turbopack is now the default bundler for both next dev and next build, and static export is a setting in next.config.ts rather than the old standalone next export command.
| Command | Example | Description | |
|---|---|---|---|
npx create-next-app@latest my-app | Scaffolds a new Next.js project in a new folder, prompting for TypeScript, linter, Tailwind, and App Router, then installing dependencies. | ||
npm run dev | Starts the development server on http://localhost:3000 with Fast Refresh, which applies edits while keeping component state. | ||
npm run build | Builds the application for production. Optimizes bundles, type-checks the project, and prerenders static routes. | ||
npm start | Serves the production build. Requires next build first, and does not work with output: 'export'. | ||
npm install next@latest react@latest react-dom@latest | Installs Next.js into an existing project. Also requires adding the dev/build/start scripts and creating app/layout.tsx plus app/page.tsx. | ||
mv app/page.js app/page.tsxnpm run dev | Bootstraps TypeScript support. Rename any file to .ts/.tsx, and Next.js installs the dependencies and writes tsconfig.json on the next dev or build. | ||
next dev | • Rust-based incremental bundler built into Next.js, the dev default since Next.js 16 • opt out with next dev --webpack. | ||
next build | • Also the production-build default since Next.js 16, stable after a 15.5 beta • 2-5x faster builds; opt out with next build --webpack. | ||
output: 'export' in next.config.ts | • Generates fully static output into the out/ folder, one HTML file per route• set in config, then run next build. The next export command was removed in Next.js 14. |