Framework cheatsheet
Next.js 16 Cheatsheet
Create, run and build Next.js apps, and the App Router patterns you reach for most.
Command line
- Create an app — Create a new Next.js project with an interactive setup.
- Start the development server — Run the app at http://localhost:3000 with hot reload.
- Use another port — Start the dev server on port 4000.
- Build for production — Create an optimized production build and print the route table.
- Run the production build — Start the server after a build.
- Print environment info — Show Node, npm and Next.js versions. Handy for bug reports.
- Turn off telemetry — Opt out of anonymous usage data collection.
Routing and files
- Create a page — A page.tsx file inside app/ is a route. This one serves /about from app/about/page.tsx.
- Create a layout — A layout wraps its pages and persists across navigation.
- Read a dynamic route parameter — In app/blog/[slug]/page.tsx, params is a promise, so await it.
- Link between pages — Navigate on the client without a full page reload.
- Create an API route — A route.ts file exports a function per HTTP method.
- Show a loading state — A loading.tsx next to a page is shown while the page streams in.
- Return a 404 — Call notFound() in a server component to render the closest not-found page.
Data and server code
- Fetch data in a server component — Server components can be async, so fetch data directly.
- Make a client component — Add this directive at the top of a file to use state, effects and browser APIs.
- Create a server action — A function marked "use server" runs on the server and can be called from forms.
- Redirect — Send the user to another route from server code.
- Refresh cached data — Invalidate cached data for a route after a change.
- Read a cookie — cookies() is async in current versions, so await it.
Metadata and configuration
- Set page metadata — Export metadata from a page or layout for the title and description.
- Optimize an image — Use next/image for resizing, lazy loading and modern formats.
- Expose an environment variable to the browser — Only variables prefixed with NEXT_PUBLIC_ are included in the browser bundle.
- Write next.config.ts — Configure Next.js in a typed config file.
Related cheatsheets
- Angular 22 cheatsheet — Angular CLI commands and standalone component, signals, template, routing, HTTP and forms snippets.
- Astro cheatsheet — Build fast content sites with Astro: components, layouts, routing, content collections, islands, endpoints and deployment.
- Django 6 cheatsheet — Create projects, run migrations, test and deploy Django apps, plus the ORM queries you use every day.
- .NET and ASP.NET Core 10 cheatsheet — The dotnet CLI for creating, building, testing and publishing projects, plus common ASP.NET Core and EF Core code.
- Express 5 cheatsheet — Build HTTP servers and APIs with Express 5 on Node.js.
- FastAPI 0.115 cheatsheet — Install, run, test and deploy FastAPI apps from the command line.