← Courses

Documentation Course

Next.js In-Depth

From First Route to Production-Grade Architecture

Start Reading

A complete A-Z Next.js curriculum — from absolute basics for React developers new to the framework through production patterns for mid-level engineers to the deep engine internals and distributed architecture that only senior engineers ever learn. Built from real experience shipping E-commerce platforms, SaaS dashboards, and media sites at scale.

43 modulesBeginner to AdvancedWritten / Documentation-style43 of 43 modules live

How to use this course

This course works as both a sequential read and a standalone reference. Read sequentially to build a complete model of the App Router rendering pipeline. Or jump to any module when you hit a specific problem — a caching mystery after the v15 upgrade, a hydration mismatch, a Core Web Vitals regression, or a TTFB that won't move.

Total reading time

~19.5 hrs

across 43 modules

Built from

App Router v13–16

E-commerce, SaaS, media at scale

Prerequisite

You ship Next.js in production

App Router required, Pages Router context provided

Phase 1 — Foundation

Absolute basics · No prior knowledge assumed

9 modules
F-1
What Is Next.js and Why Does It Exist?
The blank canvas problem React creates, the rendering spectrum from CSR to PPR, and what Next.js actually is under the hood — compiler, router, server, and CDN interface.
F-2
The App Router: File-System Routing & The Special File Matrix
Every special file in the app/ directory — page, layout, template, loading, error, not-found, default, forbidden, unauthorized — and exactly what each one does and when to reach for it.
F-3
Server Components vs Client Components — First Contact
The network boundary in plain terms, what "use client" actually costs, why Server Components are the default, and the five mistakes every engineer makes the first week.
F-4
Data Fetching in the App Router
async/await directly in Server Components, fetch() with Next.js cache extensions, loading skeletons with Suspense, and the redirect/notFound control-flow functions.
F-5
Dynamic Routes, Params, and Navigation Hooks
Slug segments, catch-all routes, async params in Next.js 15, generateStaticParams, and the full suite of client-side navigation hooks including the new useLinkStatus.
F-6
Built-in Components — Image, Font, Script, Link, and Form
Why next/image exists, the four Script loading strategies, the new Form component for prefetched search, and what Link's prefetch prop actually controls.
F-7
Route Handlers and the Backend-for-Frontend Pattern
Building GET/POST/PUT/DELETE handlers with NextRequest and NextResponse, the new proxy.js convention, userAgent() for device detection, and when to use a Route Handler vs a Server Action.
F-8
Your First Real Next.js Application
Building a content site end-to-end — layouts, dynamic routes, data fetching, generateMetadata for SEO, static vs dynamic rendering decisions, and what silently breaks when you deploy outside Vercel.
F-9
The Render Decision Tree — Static, Dynamic, and Streaming
The complete decision flowchart: every API that forces dynamic rendering (cookies, headers, searchParams, noStore, connection), the root layout footgun that opts your entire app out of static, and how to read next build output to verify render mode before you ship.

Phase 2 — Practitioner

Production patterns · Real application architecture

17 modules
P-1
Advanced Data Fetching — Patterns, Caching, and Control
Sequential vs parallel fetching, unstable_cache and cache(), revalidatePath scope, connection() and unstable_noStore() for opting into dynamic rendering, and eliminating waterfall chains.
P-2
Server Actions — Mutations Done Right
How Server Actions are compiled, useActionState (the useFormState replacement), useOptimistic for instant UI, the after() API for post-response side effects, and Zod validation patterns.
P-3
Authentication with Auth.js (NextAuth v5)
JWT vs database sessions, OAuth and credentials providers, auth() in Server Components and Actions, middleware-based route protection, RBAC, and the new forbidden()/unauthorized() auth interrupt system.
P-4
Database Integration — Prisma, PostgreSQL, and Connection Pooling
Setting up Prisma with the App Router, why new PrismaClient() per request will kill your database at scale, PgBouncer and Neon for serverless pooling, and the full mutation pattern via Server Actions.
P-5
Middleware — Routing Logic at the Edge
The middleware execution model, matcher config, cookies()/headers() write constraints, userAgent() for device routing, draftMode() for CMS preview, and the 1ms performance budget.
P-6
Caching in Practice — The Four-Layer Model and the `use cache` Directive
The four cache layers, the old fetch()-based model vs the new use cache directive, cacheLife() TTL profiles, cacheTag()/updateTag() for on-demand invalidation, and staleTimes tuning.
P-7
SEO, Metadata, Open Graph, and Sitemaps
generateMetadata vs static metadata, generateViewport(), dynamic OG images with ImageResponse, generateImageMetadata() for multiple images, generateSitemaps() for large catalogs, and draftMode() for CMS preview.
P-8
Testing Next.js Applications
Testing Server Components that call cookies()/headers() outside request context, AsyncLocalStorage-aware test wrappers, mocking the Data Cache layer for deterministic tests, testing optimistic UI race conditions, E2E with Playwright, and the five test patterns that catch real production bugs.
P-9
Configuration — next.config.ts, Environment Variables, and Instrumentation
The complete next.config.ts surface, plus the NEXT_PUBLIC_ build-time baking trap (why the same Docker image cannot serve staging and production), runtime environment injection patterns, and the instrumentation.ts startup hook.
P-10
Performance Optimisation for Practitioners
Bundle analysis, dynamic() for code splitting, advanced Image configuration with remotePatterns and custom loaders, Script strategy deep dive, optimizePackageImports for barrel files, and memory leak detection.
P-11
Internationalisation (i18n) Routing
Sub-path vs domain routing, locale detection via Accept-Language in middleware, next-intl with server-side getTranslations, locale-aware generateStaticParams, and hreflang SEO.
P-12
MDX, View Transitions, and Content-Rich Application Patterns
MDX with @next/mdx and custom component mapping, remote MDX from a CMS, the View Transitions API with the viewTransition config, and when MDX is the right choice vs a headless CMS.
P-13
Building a Production-Grade Feature — End-to-End
A full authenticated dashboard with real data and mutations — Server vs Client Component decisions, optimistic UI, error boundaries, per-page caching strategy, after() for side effects, and a pre-ship checklist.
P-14
Deployment and CI/CD Pipelines
Vercel zero-config and preview deployments, self-hosting with standalone output, static exports for CDN-only deployments, Docker multi-stage builds, PWA setup, and GitHub Actions CI pipelines.
P-15
Connection Pooling at Scale — PgBouncer, Neon, and Prisma Accelerate
The serverless connection exhaustion problem with real math (100 functions × pool_size > max_connections), PgBouncer transaction vs session mode, Neon serverless driver, Prisma Accelerate, Supabase pooler, the pgbouncer=true flag, monitoring pg_stat_activity, and a decision matrix by infrastructure type.
P-16
Migrating from Pages Router to App Router
The coexistence model, page-by-page migration strategy, getServerSideProps→RSC, getStaticProps→generateStaticParams, API Routes→Route Handlers, next/router→next/navigation API differences, _app/_document→RootLayout providers, Middleware behaviour during partial migration, and the ten pitfalls that block every team mid-migration.
P-17
AI Integration and Streaming Route Handlers
ReadableStream and TransformStream in Route Handlers, the Vercel AI SDK (streamText, useChat, useCompletion), token-by-token streaming to the browser, abort signal propagation for cancelled requests, rate limiting streaming endpoints, streaming error handling constraints, and cost control via token budgets.

Phase 3 — Architect

Engine internals · High-throughput systems · Distributed architecture

17 modules
A-1
RSC Internals — The React Flight Protocol and React 19
The RSC wire format, React Flight serialisation, how the client reconciler processes RSC payloads, React 19 async params/searchParams as Promises, and the React Compiler's automatic memoisation model.
A-2
The Full Request Lifecycle and Edge Infrastructure
DNS → CDN → edge → origin → streaming response anatomy, cold start cost breakdown, ISR revalidation internals, instrumentation.ts register() lifecycle, and instrumentation-client.js for browser SDK boot.
A-3
The Caching Architecture — Deep Internals
Request Memoization mechanics, Data Cache tag registry and purge API, use cache directive internals, cacheLife profiles, cacheTag/updateTag, use cache: private and remote, custom cacheHandlers, and cache stampede prevention.
A-4
Partial Prerendering — Static Shell, Dynamic Holes
PPR compilation model, how Next.js analyses the Suspense tree, static shell generation at build time, dynamic slot streaming at request time, dynamicIO and use cache as modern PPR primitives, and the PPR vs ISR vs SSR decision matrix.
A-5
Streaming SSR and the Suspense Architecture
React 18/19 streaming internals, chunked Transfer-Encoding mechanics, selective hydration priority, hydration mismatch root causes, React.lazy vs dynamic() vs RSC boundary, and preventing flash before hydration.
A-6
Server Actions at Scale — Internals and Security
Server Action compilation, encrypted action IDs, CSRF protection internals, mass assignment via FormData (the Object.fromEntries exploit), after() execution context and error isolation, serverActions bodySizeLimit and allowedOrigins, and the Server Action vs Route Handler architectural decision.
A-7
Advanced Routing Internals — Parallel, Intercepting, Templates, and Segments
Parallel routes @slot rendering, default.js and the unmatched slot 404 trap, template.js vs layout.js state semantics, intercepting route modal patterns, soft vs hard navigation mechanics, and route group layout inheritance.
A-8
State Across the Network Boundary
The full state matrix, URL state with nuqs, per-request server state with React cache(), cookie-based server state, Zustand with RSC, and the taint API for preventing accidental secret exposure.
A-9
Edge Compute, Feature Flags, and Geo-Routing
Edge runtime constraints and size limits, the Prisma/Edge incompatibility and why Drizzle + Neon serverless is the fix, middleware performance profiling, feature flag architecture with GrowthBook at the edge, A/B testing without layout shift, and geo-routing at the CDN layer.
A-10
Multi-Zones, Multi-Tenant, and Distributed Application Architecture
Next.js multi-zones for independent team deploys, basePath and reverse proxy wiring, shared auth across zones, multi-tenant subdomain routing with per-tenant database isolation, and assetPrefix for tenant CDN origins.
A-11
Build Engine Internals — Turbopack, SWC, and Memory Optimisation
Why Turbopack replaced Webpack, incremental computation model, SWC transforms, turbopack config and filesystem cache, module graph anatomy, diagnosing OOM build failures, and pageExtensions for non-standard project layouts.
A-12
Core Web Vitals Engineering
LCP critical path, CLS root causes in Next.js, INP and long task elimination, useReportWebVitals instrumentation, webVitalsAttribution for element-level diagnosis, and when synthetic Lighthouse disagrees with your RUM data.
A-13
Security Architecture
Nonce-based CSP in Middleware and the CDN cache invalidation trap (a cached nonce is not a nonce), SSRF via next/image remotePatterns wildcard misconfiguration, SSRF via Server Actions, secret leakage with server-only and taint API, and rate limiting: edge vs application layer.
A-14
Self-Hosting vs Serverless, WebSockets, and Long-Lived Connections
Standalone output internals, static export feature graveyard (what silently breaks), WebSocket authentication (HttpOnly cookie on upgrade handshake, token validation on reconnect, secret rotation with 40K live connections), Pusher/Ably vs Partykit vs self-hosted socket layer, and the cold start optimisation playbook.
A-15
Production Observability and Runbooks
OpenTelemetry via instrumentation.ts, instrumentation-client.js for browser SDK boot, custom spans across server/edge/client, Sentry integration, useReportWebVitals for CWV shipping, and four production runbooks: TTFB regression, cache miss storm, hydration error, memory leak during rolling deploy.
A-16
The Router Cache — Client-Side RSC Payload Cache Deep Dive
The most misdiagnosed staleness bug in Next.js: prefetch entry types (full vs partial), staleTimes per entry type, why Server Actions + revalidatePath do not immediately update what the user sees, router.refresh() semantics vs router.push(), and the production debugging workflow for "I mutated data and the UI is stale."
A-17
Error Architecture and Recovery Patterns
The complete error hierarchy: segment vs page vs root error boundaries, global-error.tsx for root layout crashes, the digest prop for server-side error correlation, how errors propagate through nested RSC trees, Suspense + error boundary interaction, and the four error categories (validation, not-found, auth, unexpected) with the right handling pattern for each.