Why use the App Router?
Server Components by default
Pages and layouts render on the server, reducing the JavaScript sent to the browser and improving initial load performance.
File-system routing
Routes are defined by the folder structure inside the
app directory. No configuration needed.Nested layouts
Layouts wrap pages and preserve state across navigations. Share UI like headers, sidebars, and footers without re-rendering.
Streaming and Suspense
Stream parts of the UI progressively as data becomes available, keeping the experience responsive even for slow data sources.
Server Actions
Mutate data directly from components using async server functions. No separate API route needed for form submissions.
Full-stack in one project
Fetch data, run server logic, and render UI all within a single Next.js application without managing a separate backend.
How the App Router works
Theapp directory contains your application’s routes. Each folder in app maps to a URL segment. Special files like page.tsx and layout.tsx define what is rendered at each segment.
app are React Server Components. You opt into client-side interactivity with the 'use client' directive.
Getting started
Work through the guides in order to build a complete understanding of the App Router:Installation
Create a new Next.js app and set up TypeScript, ESLint, and path aliases.
Project structure
Learn the folder and file conventions used across a Next.js project.
Layouts and pages
Create pages and shared layouts with file-system routing.
Linking and navigating
Use the Link component, prefetching, and streaming for fast navigations.
Server and Client Components
Understand when to run code on the server vs. the client.
Fetching data
Fetch data in Server Components, stream loading states, and handle errors.
Mutating data
Use Server Actions to handle form submissions and data mutations.
Deploying
Deploy to Vercel, self-host with Node.js or Docker, or export as static files.
