CoachnestCoachnest
Sign InGet Started
Back to course

Next.js 16: The Complete Developer Guide

…
—
Contents
1

What's New in Next.js 16

Reading14mFree
2

Installation, CLI & Your First Project

Reading12mFree
3

Project Structure & Conventions Deep Dive

Reading16m
4

Turbopack — The New Default Bundler

Video18m
5

Configuring TypeScript, ESLint & next.config.ts

Reading14m
6

Chapter 1 — Quiz

Quiz10m
7

App Router Fundamentals

Reading16m
8

Dynamic Routes, Catch-Alls & Type-Safe Params

Reading14m
9

Route Groups & Parallel Routes

Reading16m
10

Intercepting Routes & Modal Patterns

Reading12m
11

Loading, Error & Not-Found UI

Reading12m
12

Chapter 2 — Routing Quiz

Quiz12m

Understanding the Server/Client Boundary

Reading18m
14

Choosing When to use "use client"

Reading14m
15

Composing Server & Client Components

Reading14m
16

server-only, client-only & Code Splitting

Reading12m
17

Chapter 3 — Quiz

Quiz10m
18

Fetching Data in Server Components

Reading14m
19

The Next.js 16 Cache Model

Reading16m
20

Revalidation: revalidateTag, revalidatePath & On-Demand

Reading12m
21

Cache Components — Building Reusable Cached Functions

Reading14m
22

Search Params, Cookies & Dynamic APIs

Reading12m
23

Chapter 4 — Quiz

Quiz12m
24

Server Actions From First Principles

Reading16m
25

Forms with useActionState & Progressive Enhancement

Reading14m
26

Optimistic UI with useOptimistic

Reading12m
27

Validation with Zod + Server Actions

Reading12m
28

Chapter 5 — Quiz

Quiz10m
29

Static vs Dynamic vs Streaming

Reading14m
30

generateStaticParams & Pre-Rendering Dynamic Routes

Reading12m
31

Incremental Static Regeneration (ISR)

Reading12m
32

Partial Prerendering (PPR)

Reading16m
33

Edge Runtime vs Node.js Runtime

Reading12m
34

Rendering Strategies Deep Dive

Video22m
35

Chapter 6 — Quiz

Quiz12m
36

Tailwind CSS v4 with Next.js 16

Reading14m
37

CSS Modules, Global Styles & Scoped CSS

Reading10m
38

next/image — Smart, Fast Images

Reading14m
39

Fonts, Icons & Metadata

Reading12m
40

Chapter 7 — Quiz

Quiz10m
41

Middleware Fundamentals

Reading14m
42

Sessions, JWTs & Cookies

Reading16m
43

Protecting Server Components & Server Actions

Reading12m
44

Chapter 8 — Quiz

Quiz10m
45

Prisma with Next.js — The Production Setup

Reading14m
46

Mutations: Server Actions + Database Writes

Reading12m
47

Route Handlers & REST APIs

Reading12m
48

Chapter 9 — Quiz

Quiz10m
49

Unit & Component Testing with Vitest

Reading12m
50

End-to-End Testing with Playwright

Reading14m
51

Deploying to Vercel

Reading12m
52

Self-Hosting with Docker

Reading14m
53

Production Performance Checklist

Reading12m
54

Final Assessment — Next.js 16 Mastery

Quiz20m
←→navigate lessons
Chapter 3 of 10·Chapter 3 — Server Components & Client Components
Lesson 13 of 54Reading18 min

Understanding the Server/Client Boundary

#Understanding the Server/Client Boundary¶

The single biggest mental shift in Next.js (since v13, refined in v16) is that components are server-rendered by default. You opt into client rendering only where you need it.

The Three Kinds of Components¶

KindMarkerRuns On
Server ComponentNone (default)Server only
Client Component"use client" at the top of the fileServer (for the initial HTML) and client (for hydration & interactivity)
Shared ComponentNo client APIs, no server APIsEither — depends on who imports it

Server Component — What You Can Do¶

  • async directly: export default async function Page() { … }
  • Access the database, the filesystem, secrets in env
  • Fetch with the global fetch() (deduped & cacheable)
  • Import heavyweight server libraries — they never reach the client bundle

What you cannot do:

  • useState, useEffect, useReducer, useRef — no client hooks
  • Browser APIs (window, document, localStorage)
  • Event handlers like onClick={() => …}

Client Component — What You Can Do¶

  • All React hooks
  • Event handlers
  • Browser APIs
  • State

What you cannot do:

  • Be async (use Suspense + a data hook instead)
  • Import server-only modules (Next.js will error)
  • Read env vars not prefixed with NEXT_PUBLIC_

A Picture¶

┌─────────────────────────────────────────┐ │ Server │ │ - Layout (server) │ │ - Page (server, async) │ │ - Hero (server) │ │ - PriceWidget ("use client") ◀──┐ │ │ - <CountUp/> (lib) │ │ │ - Sidebar (server) │ │ │ │ │ └───────────────────────────────────────┼──┘ │ ships JS for this subtree only

How the Boundary Propagates¶

Once you mark a component "use client", everything it imports becomes part of the client bundle, transitively. So push the directive as deep as possible.

tsx
12 lines
1// ❌ Marks the whole product card client-side just for a button
2"use client";
3export default function ProductCard({ product }) {
4  return (
5    <article>
6      <Image src={product.cover} alt={product.title} width={400} height={300} />
7      <h3>{product.title}</h3>
8      <p>{product.summary}</p>
9      <button onClick={() => addToCart(product.id)}>Add to cart</button>
10    </article>
11  );
12}
tsx
18 lines
1// ✅ Only the button is interactive
2// ProductCard.tsx — server
3export default function ProductCard({ product }) {
4  return (
5    <article>
6      <Image src={product.cover} alt={product.title} width={400} height={300} />
7      <h3>{product.title}</h3>
8      <p>{product.summary}</p>
9      <AddToCartButton id={product.id} />
10    </article>
11  );
12}
13
14// AddToCartButton.tsx — client
15"use client";
16export function AddToCartButton({ id }: { id: string }) {
17  return <button onClick={() => addToCart(id)}>Add to cart</button>;
18}

A Useful Mental Model¶

Server Components handle rendering data. Client Components handle rendering interactions.

Most of your tree is Server Components reading data. The interactive leaves are small Client Components: forms, modals, buttons with state, sliders, theme toggles.

Common Errors¶

ErrorFix
Cannot use useState in a Server ComponentAdd "use client" to the file.
You're importing a component that needs the browser …Move the import into a Client Component.
Functions cannot be passed directly to Client ComponentsPass plain JSON-serializable props, or wrap the function in a Server Action.
Module not found: Can't resolve 'fs' from a Client ComponentThe component is somehow being included client-side; verify the directive and import chain.

Previous

Chapter 2 — Routing Quiz

Next

Choosing When to use "use client"

Use ← → arrow keys to navigate between lessons