Next.js

Intermediate · Roadmap · 58 lessons · 10 groups

Next.js 16 and the App Router — the file-system router, layouts and navigation, Server and Client Components as the framework applies them, data fetching and caching (including Cache Components and use cache), mutations with Server Actions and route handlers, rendering strategies, styling and assets, authentication, the proxy layer, optimization, testing, and deployment. React's own component model stays in react, the language in javascript, types in typescript, and Node itself in nodejs. Fifty-eight lessons.

0%

Not started

Nothing saved yet. Progress is kept in this browser until you sign in.

Start the path

Getting started · 5

Routing · 9

Server and Client Components · 5

Data fetching and caching · 8

Mutations and APIs · 6

Rendering strategies · 5

Styling and assets · 5

Authentication and security · 4

Optimization and testing · 5

Deployment and beyond · 6

01What Next.js is and why it existsReact gives you components; Next.js adds the router, server rendering, bundler and deployment story a real site needs. What it decides and what it costs.Beginner · 4 min02Creating a Next.js projectScaffold an app with create-next-app, read its prompts and defaults, and run the dev, build and start scripts on a current Next.js 16 install.Beginner · 1 min03The project structureWhat each file and folder in a Next.js 16 project does, how a route becomes public, and how to colocate code with private folders and an optional src directory.Beginner · 4 min04The App Router and the Pages RouterNext.js has two routers that can coexist. How the Pages Router worked, what the App Router changed, and why new projects should start with the App Router.Beginner · 16 min05Turbopack and the dev serverWhat a bundler does, why Next.js 16 made Turbopack the default for dev and build, how it works, and when you might still pass the --webpack flag.Beginner · 6 min01The file-system routerHow folders become URL segments in the App Router, why a page or route file makes a segment public, and what Next.js does with a URL that matches nothing.Beginner · 6 min02Pages and layoutsPages render the UI for a URL, layouts wrap it and persist across navigation. The required root layout, nesting, templates, and the generated LayoutProps type.Beginner · 5 min03Dynamic routes and paramsSquare-bracket segments, catch-all and optional catch-all routes, awaiting params and searchParams in Next.js 16, and the typed PageProps helper.Beginner · 6 min04Route groups and private foldersParenthesized folders organize routes and layouts without changing URLs; underscore folders opt out of routing. Caveats: root layouts and path clashes.Beginner · 4 min05Linking and moving between pagesThe Link component, prefetching, client-side transitions, useRouter and usePathname, and what makes a Next.js navigation feel instant or slow.Beginner · 5 min06Loading UI and streamingHow loading.tsx wraps a page in Suspense, why streaming improves perceived speed, and how to stream parts of a page with your own Suspense boundaries.Intermediate · 3 min07Error handling and not-foundExpected errors versus uncaught exceptions, error.tsx and global-error.tsx boundaries, notFound() with not-found.tsx, and the status code streaming changes.Intermediate · 5 min08Parallel and intercepting routesNamed @slots that render several pages in one layout, default.tsx fallbacks, and intercepting routes with (.) and (..) for modals that keep deep-linkable URLs.Advanced · 9 min09Redirects and rewritesredirect(), permanentRedirect, next.config redirects and rewrites, and proxy.ts. Which one to use, which status codes they send, and how a rewrite differs.Intermediate · 6 min01Server Components in Next.jsWhy layouts and pages are Server Components by default in Next.js, what that lets you do, what it forbids, and how the RSC payload reaches the browser.Intermediate · 7 min02The use client boundaryWhat "use client" actually declares, why it marks a boundary in the module graph rather than one component, and how to keep client JavaScript small.Intermediate · 11 min03Composing Server and Client ComponentsWhich nestings of server and client components work, why importing a Server Component into a Client Component fails, and the children slot that fixes it.Intermediate · 8 min04Environment variables and server-only codeHow .env files load, why only NEXT_PUBLIC_ variables reach the browser, and how the server-only package turns an accidental client import into a build error.Intermediate · 5 min05Third-party components and context providersWhy context and some libraries break in Server Components, and how to wrap them in a small Client Component, place providers deep, and author libraries.Intermediate · 5 min01Fetching data in Server ComponentsAwait a fetch right inside an async Server Component, stream slow data behind Suspense, and see why uncached fetches need a boundary under Cache Components.Intermediate · 4 min02Querying a database directlyCall an ORM or database client from a Server Component, keep the data layer server-only, deduplicate with React.cache, and handle synchronous drivers.Intermediate · 7 min03Request memoization and parallel fetchingHow Next.js deduplicates identical fetches in one render, when React.cache is needed instead, and how to avoid request waterfalls with Promise.all.Intermediate · 7 min04The four cachesRequest memoization, the Data Cache, the Full Route Cache, and the Router Cache: what each did, and what replaced it in Next.js 16 with Cache Components.Intermediate · 29 min05Cache Components and use cacheOpt in to caching with the use cache directive and cacheLife, mix static, cached and streamed content on one page, and learn what a cached function cannot read.Intermediate · 25 min06Revalidation and cache tagsTag cached data with cacheTag, then refresh it with updateTag, revalidateTag, revalidatePath, or refresh, and pick the right one after a mutation.Intermediate · 13 min07Dynamic APIs: cookies, headers, and searchParamsRequest-time data is async in Next.js 16. How cookies(), headers(), params and searchParams work, why they need Suspense, and how to feed cached code.Intermediate · 5 min08Client-side data fetchingWhen a Client Component should fetch for itself, how use() with a server-started promise compares with SWR and TanStack Query, and how to seed a library.Intermediate · 17 min01Server Actions basicsDefine a Server Action with use server, call it from a form, pass extra arguments with bind, and treat it as a public POST endpoint that needs auth checks.Intermediate · 6 min02Forms and pending statesShow a pending state with useActionState or useFormStatus, bind a form to a Server Action, and use the Form component for GET search forms.Intermediate · 14 min03Validation and error handling in actionsValidate FormData on the server with a schema, return expected errors as state with useActionState, and leave unexpected failures to error boundaries.Intermediate · 7 min04Optimistic updatesUse useOptimistic to show a Server Action's result immediately, roll back on failure, and know when waiting for the server is the better choice.Intermediate · 6 min05Route handlersBuild HTTP endpoints with route.ts, read params and the request, and see how GET handlers are cached, static, or dynamic with and without Cache Components.Intermediate · 6 min06The proxy fileproxy.ts replaces middleware.ts in Next.js 16. Redirect, rewrite, and set headers before a request finishes, scope it with a matcher, and know its limits.Intermediate · 11 min01Static and dynamic renderingStatic rendering builds HTML once at build time, dynamic rendering per request. See what triggers each in Next.js 16 and how Cache Components changes it.Intermediate · 11 min02Partial prerenderingPartial prerendering serves a prebuilt static shell and streams dynamic holes into it. In Next.js 16 it is the default with Cache Components.Intermediate · 24 min03Generating static paramsUse generateStaticParams to prerender dynamic routes at build time, handle nested segments, and see what changes under Cache Components.Intermediate · 14 min04Incremental static regenerationISR updates static pages without a full rebuild. See the classic revalidate model and how Cache Components replaces it with cacheLife and tags.Intermediate · 12 min05Metadata and SEOSet titles and social tags with the metadata object and generateMetadata, add sitemap, robots and OG image files, and understand streaming metadata.Intermediate · 44 min01CSS Modules and global CSSStyle Next.js App Router pages with CSS Modules for scoped classes and global CSS for the truly global, and learn how import order decides CSS order.Beginner · 16 min02Tailwind CSS in Next.jsInstall Tailwind CSS v4 in a Next.js 16 app with the PostCSS plugin, import it once in your root layout, and know where it fits next to CSS Modules.Beginner · 4 min03Fonts with next/fontLoad Google and local fonts with next/font so they are self-hosted at build time, cause no layout shift, and connect to Tailwind through CSS variables.Beginner · 10 min04Optimizing imagesUse next/image for correctly sized, lazy-loaded images with no layout shift, and configure remote images, sizes, quality, and preloading in Next.js 16.Intermediate · 9 min05Scripts and third-party codeLoad analytics, tag managers, and widgets with next/script and its loading strategies, run code after load, and use @next/third-parties for common embeds.Intermediate · 14 min01Authentication concepts and sessionsSeparate authentication, sessions, and authorization, then build a cookie session in Next.js 16 with signed JWTs, the cookies API, and the right cookie flags.Intermediate · 12 min02Protecting routes and dataWhere to put auth checks in Next.js 16: a proxy for fast optimistic redirects, a data access layer for real checks, and a check inside every Server Action.Intermediate · 8 min03Auth.js and auth librariesChoosing between hosted auth, self-run libraries and session toolkits, what happened to Auth.js, and how a library plugs into a Data Access Layer.Intermediate · 36 min04Security headers and CSPThe browser-enforced headers worth setting, how to build a nonce-based Content Security Policy in proxy.ts, and why nonces force dynamic rendering.Intermediate · 8 min01Bundle analysis and lazy loadingFind heavy client code with next analyze, split it out with next/dynamic and dynamic import(), and know where bundle growth usually comes from.Intermediate · 6 min02Core Web Vitals in Next.jsWhat LCP, INP and CLS measure, which Next.js features target each, the difference between lab and field data, and how to report vitals with a hook.Intermediate · 23 min03Unit and component testingSet up Vitest or Jest for a Next.js app, write a component test, and learn why async Server Components belong in end-to-end tests instead.Intermediate · 27 min04End-to-end testing with PlaywrightDrive a real browser against a production build with Playwright, reuse a logged-in state, and test the flows unit tests cannot reach.Intermediate · 38 min05TypeScript in Next.jsThe Next.js-specific TypeScript features: generated route types, PageProps and LayoutProps, typed links with typedRoutes, and typed config.Intermediate · 6 min01Build output and next buildRead the route table next build prints, know what each symbol means, what lands in .next, and which flags help when a build fails or a route is not static.Intermediate · 1 min02Deploying to VercelDeploy a Next.js app to Vercel from Git or the CLI, tell preview from production deployments, scope environment variables, and see what each feature runs on.Beginner · 6 min03Self-hosting with Node.js and DockerRun Next.js with next start or the standalone output, package it in a multi-stage Docker image, and handle the caches, env vars, and proxy settings.Advanced · 17 min04Static exportsSet output: 'export' to turn a Next.js app into plain HTML, CSS, and JavaScript for any static host, and learn what the build rejects, allows, and costs you.Intermediate · 2 min05Upgrading and the codemodsMove a Next.js app to version 16 with next upgrade and the official codemods, know the breaking changes the codemods miss, and verify with a checklist.Intermediate · 10 min06The Pages Router for legacy appsRead and maintain a Pages Router app: its data functions and special files, how it coexists with the App Router, and a page-by-page path for migrating it.Intermediate · 16 min

Getting started

5 lessons

  1. 01 / 05What Next.js is and why it existsReact gives you components; Next.js adds the router, server rendering, bundler and deployment story a real site needs. What it decides and what it costs.4 min
  2. 02 / 05Creating a Next.js projectScaffold an app with create-next-app, read its prompts and defaults, and run the dev, build and start scripts on a current Next.js 16 install.1 min
  3. 03 / 05The project structureWhat each file and folder in a Next.js 16 project does, how a route becomes public, and how to colocate code with private folders and an optional src directory.4 min
  4. 04 / 05The App Router and the Pages RouterNext.js has two routers that can coexist. How the Pages Router worked, what the App Router changed, and why new projects should start with the App Router.16 min
  5. 05 / 05Turbopack and the dev serverWhat a bundler does, why Next.js 16 made Turbopack the default for dev and build, how it works, and when you might still pass the --webpack flag.6 min

Routing

9 lessons

  1. 01 / 09The file-system routerHow folders become URL segments in the App Router, why a page or route file makes a segment public, and what Next.js does with a URL that matches nothing.6 min
  2. 02 / 09Pages and layoutsPages render the UI for a URL, layouts wrap it and persist across navigation. The required root layout, nesting, templates, and the generated LayoutProps type.5 min
  3. 03 / 09Dynamic routes and paramsSquare-bracket segments, catch-all and optional catch-all routes, awaiting params and searchParams in Next.js 16, and the typed PageProps helper.6 min
  4. 04 / 09Route groups and private foldersParenthesized folders organize routes and layouts without changing URLs; underscore folders opt out of routing. Caveats: root layouts and path clashes.4 min
  5. 05 / 09Linking and moving between pagesThe Link component, prefetching, client-side transitions, useRouter and usePathname, and what makes a Next.js navigation feel instant or slow.5 min
  6. 06 / 09Loading UI and streamingHow loading.tsx wraps a page in Suspense, why streaming improves perceived speed, and how to stream parts of a page with your own Suspense boundaries.3 min
  7. 07 / 09Error handling and not-foundExpected errors versus uncaught exceptions, error.tsx and global-error.tsx boundaries, notFound() with not-found.tsx, and the status code streaming changes.5 min
  8. 08 / 09Parallel and intercepting routesNamed @slots that render several pages in one layout, default.tsx fallbacks, and intercepting routes with (.) and (..) for modals that keep deep-linkable URLs.9 min
  9. 09 / 09Redirects and rewritesredirect(), permanentRedirect, next.config redirects and rewrites, and proxy.ts. Which one to use, which status codes they send, and how a rewrite differs.6 min

Server and Client Components

5 lessons

  1. 01 / 05Server Components in Next.jsWhy layouts and pages are Server Components by default in Next.js, what that lets you do, what it forbids, and how the RSC payload reaches the browser.7 min
  2. 02 / 05The use client boundaryWhat "use client" actually declares, why it marks a boundary in the module graph rather than one component, and how to keep client JavaScript small.11 min
  3. 03 / 05Composing Server and Client ComponentsWhich nestings of server and client components work, why importing a Server Component into a Client Component fails, and the children slot that fixes it.8 min
  4. 04 / 05Environment variables and server-only codeHow .env files load, why only NEXT_PUBLIC_ variables reach the browser, and how the server-only package turns an accidental client import into a build error.5 min
  5. 05 / 05Third-party components and context providersWhy context and some libraries break in Server Components, and how to wrap them in a small Client Component, place providers deep, and author libraries.5 min

Data fetching and caching

8 lessons

  1. 01 / 08Fetching data in Server ComponentsAwait a fetch right inside an async Server Component, stream slow data behind Suspense, and see why uncached fetches need a boundary under Cache Components.4 min
  2. 02 / 08Querying a database directlyCall an ORM or database client from a Server Component, keep the data layer server-only, deduplicate with React.cache, and handle synchronous drivers.7 min
  3. 03 / 08Request memoization and parallel fetchingHow Next.js deduplicates identical fetches in one render, when React.cache is needed instead, and how to avoid request waterfalls with Promise.all.7 min
  4. 04 / 08The four cachesRequest memoization, the Data Cache, the Full Route Cache, and the Router Cache: what each did, and what replaced it in Next.js 16 with Cache Components.29 min
  5. 05 / 08Cache Components and use cacheOpt in to caching with the use cache directive and cacheLife, mix static, cached and streamed content on one page, and learn what a cached function cannot read.25 min
  6. 06 / 08Revalidation and cache tagsTag cached data with cacheTag, then refresh it with updateTag, revalidateTag, revalidatePath, or refresh, and pick the right one after a mutation.13 min
  7. 07 / 08Dynamic APIs: cookies, headers, and searchParamsRequest-time data is async in Next.js 16. How cookies(), headers(), params and searchParams work, why they need Suspense, and how to feed cached code.5 min
  8. 08 / 08Client-side data fetchingWhen a Client Component should fetch for itself, how use() with a server-started promise compares with SWR and TanStack Query, and how to seed a library.17 min

Mutations and APIs

6 lessons

  1. 01 / 06Server Actions basicsDefine a Server Action with use server, call it from a form, pass extra arguments with bind, and treat it as a public POST endpoint that needs auth checks.6 min
  2. 02 / 06Forms and pending statesShow a pending state with useActionState or useFormStatus, bind a form to a Server Action, and use the Form component for GET search forms.14 min
  3. 03 / 06Validation and error handling in actionsValidate FormData on the server with a schema, return expected errors as state with useActionState, and leave unexpected failures to error boundaries.7 min
  4. 04 / 06Optimistic updatesUse useOptimistic to show a Server Action's result immediately, roll back on failure, and know when waiting for the server is the better choice.6 min
  5. 05 / 06Route handlersBuild HTTP endpoints with route.ts, read params and the request, and see how GET handlers are cached, static, or dynamic with and without Cache Components.6 min
  6. 06 / 06The proxy fileproxy.ts replaces middleware.ts in Next.js 16. Redirect, rewrite, and set headers before a request finishes, scope it with a matcher, and know its limits.11 min

Rendering strategies

5 lessons

  1. 01 / 05Static and dynamic renderingStatic rendering builds HTML once at build time, dynamic rendering per request. See what triggers each in Next.js 16 and how Cache Components changes it.11 min
  2. 02 / 05Partial prerenderingPartial prerendering serves a prebuilt static shell and streams dynamic holes into it. In Next.js 16 it is the default with Cache Components.24 min
  3. 03 / 05Generating static paramsUse generateStaticParams to prerender dynamic routes at build time, handle nested segments, and see what changes under Cache Components.14 min
  4. 04 / 05Incremental static regenerationISR updates static pages without a full rebuild. See the classic revalidate model and how Cache Components replaces it with cacheLife and tags.12 min
  5. 05 / 05Metadata and SEOSet titles and social tags with the metadata object and generateMetadata, add sitemap, robots and OG image files, and understand streaming metadata.44 min

Styling and assets

5 lessons

  1. 01 / 05CSS Modules and global CSSStyle Next.js App Router pages with CSS Modules for scoped classes and global CSS for the truly global, and learn how import order decides CSS order.16 min
  2. 02 / 05Tailwind CSS in Next.jsInstall Tailwind CSS v4 in a Next.js 16 app with the PostCSS plugin, import it once in your root layout, and know where it fits next to CSS Modules.4 min
  3. 03 / 05Fonts with next/fontLoad Google and local fonts with next/font so they are self-hosted at build time, cause no layout shift, and connect to Tailwind through CSS variables.10 min
  4. 04 / 05Optimizing imagesUse next/image for correctly sized, lazy-loaded images with no layout shift, and configure remote images, sizes, quality, and preloading in Next.js 16.9 min
  5. 05 / 05Scripts and third-party codeLoad analytics, tag managers, and widgets with next/script and its loading strategies, run code after load, and use @next/third-parties for common embeds.14 min

Authentication and security

4 lessons

  1. 01 / 04Authentication concepts and sessionsSeparate authentication, sessions, and authorization, then build a cookie session in Next.js 16 with signed JWTs, the cookies API, and the right cookie flags.12 min
  2. 02 / 04Protecting routes and dataWhere to put auth checks in Next.js 16: a proxy for fast optimistic redirects, a data access layer for real checks, and a check inside every Server Action.8 min
  3. 03 / 04Auth.js and auth librariesChoosing between hosted auth, self-run libraries and session toolkits, what happened to Auth.js, and how a library plugs into a Data Access Layer.36 min
  4. 04 / 04Security headers and CSPThe browser-enforced headers worth setting, how to build a nonce-based Content Security Policy in proxy.ts, and why nonces force dynamic rendering.8 min

Optimization and testing

5 lessons

  1. 01 / 05Bundle analysis and lazy loadingFind heavy client code with next analyze, split it out with next/dynamic and dynamic import(), and know where bundle growth usually comes from.6 min
  2. 02 / 05Core Web Vitals in Next.jsWhat LCP, INP and CLS measure, which Next.js features target each, the difference between lab and field data, and how to report vitals with a hook.23 min
  3. 03 / 05Unit and component testingSet up Vitest or Jest for a Next.js app, write a component test, and learn why async Server Components belong in end-to-end tests instead.27 min
  4. 04 / 05End-to-end testing with PlaywrightDrive a real browser against a production build with Playwright, reuse a logged-in state, and test the flows unit tests cannot reach.38 min
  5. 05 / 05TypeScript in Next.jsThe Next.js-specific TypeScript features: generated route types, PageProps and LayoutProps, typed links with typedRoutes, and typed config.6 min

Deployment and beyond

6 lessons

  1. 01 / 06Build output and next buildRead the route table next build prints, know what each symbol means, what lands in .next, and which flags help when a build fails or a route is not static.1 min
  2. 02 / 06Deploying to VercelDeploy a Next.js app to Vercel from Git or the CLI, tell preview from production deployments, scope environment variables, and see what each feature runs on.6 min
  3. 03 / 06Self-hosting with Node.js and DockerRun Next.js with next start or the standalone output, package it in a multi-stage Docker image, and handle the caches, env vars, and proxy settings.17 min
  4. 04 / 06Static exportsSet output: 'export' to turn a Next.js app into plain HTML, CSS, and JavaScript for any static host, and learn what the build rejects, allows, and costs you.2 min
  5. 05 / 06Upgrading and the codemodsMove a Next.js app to version 16 with next upgrade and the official codemods, know the breaking changes the codemods miss, and verify with a checklist.10 min
  6. 06 / 06The Pages Router for legacy appsRead and maintain a Pages Router app: its data functions and special files, how it coexists with the App Router, and a page-by-page path for migrating it.16 min
Esc
↑↓ navigate↵ open? shortcuts

Keyboard shortcuts

Press Esc to close

Anywhere

⌘K
Search and commands
/
Search
?
This sheet
Esc
Close

Reading a lesson

J
Next lesson
K
Previous lesson
B
Bookmark