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
13

Understanding the Server/Client Boundary

Reading18m

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 14 of 54Reading14 min

Choosing When to use "use client"

#Choosing When to use "use client"¶

A simple decision tree: start as a Server Component. Only switch when you need something a Server Component can't do.

Use Client When You Need…¶

  1. 1State — useState, useReducer
  2. 2Effects — useEffect, useLayoutEffect
  3. 3Event handlers — onClick, onChange, onSubmit
  4. 4Browser APIs — window, document, localStorage, navigator, IntersectionObserver
  5. 5Third-party libraries that need the DOM — e.g. Mapbox, Three.js, Quill editor
  6. 6Context — useContext (the Provider itself must be a Client Component)

Stay Server When You Need…¶

  1. 1Just rendering data (the most common case!)
  2. 2Fetching from the database or a secret API
  3. 3Reading the file system
  4. 4Computing markdown/MDX
  5. 5Anything that takes user input but submits via Server Actions or forms

The Test¶

"If I deleted JavaScript on the client entirely, would this still work?"

If yes — keep it server. If no — make it client.

Patterns¶

Forms¶

tsx
12 lines
1// app/contact/page.tsx — Server Component
2import { submitContact } from "./actions";
3
4export default function ContactPage() {
5  return (
6    <form action={submitContact}>
7      <input name="email" type="email" required />
8      <textarea name="message" required />
9      <button>Send</button>
10    </form>
11  );
12}

No "use client" needed — the form posts to a Server Action. Works without JavaScript.

Theme Toggle¶

tsx
11 lines
1// components/ThemeToggle.tsx
2"use client";
3import { useState, useEffect } from "react";
4
5export function ThemeToggle() {
6  const [dark, setDark] = useState(false);
7  useEffect(() => {
8    document.documentElement.classList.toggle("dark", dark);
9  }, [dark]);
10  return <button onClick={() => setDark((d) => !d)}>{dark ? "☀️" : "🌙"}</button>;
11}

Must be client — needs state and DOM access.

Conditional Rendering Based on Auth¶

tsx
10 lines
1// Server — reads cookies on the server
2export default async function Header() {
3  const user = await getCurrentUser();
4  return (
5    <header>
6      <Logo />
7      {user ? <UserMenu user={user} /> : <SignInButton />}
8    </header>
9  );
10}

Don't ship auth logic to the client — read the session server-side.

Anti-Patterns¶

Anti-pattern 1 — Marking The Root Client¶

tsx
2 lines
1// app/layout.tsx
2"use client";   // ❌ Now the entire app is a client component tree

Defaults to client → loses Server Component benefits everywhere. Push "use client" to the leaves.

Anti-pattern 2 — Putting a Provider at the Root Without a Wrapper¶

The third-party providers (Theme, ReactQuery, Redux) are all Client Components. Wrap them in a single Providers file and use it inside the server root layout:

tsx
22 lines
1// components/Providers.tsx
2"use client";
3import { ThemeProvider } from "next-themes";
4import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
5
6const qc = new QueryClient();
7export function Providers({ children }: { children: React.ReactNode }) {
8  return (
9    <QueryClientProvider client={qc}>
10      <ThemeProvider>{children}</ThemeProvider>
11    </QueryClientProvider>
12  );
13}
14
15// app/layout.tsx — Server Component
16import { Providers } from "@/components/Providers";
17
18export default function RootLayout({ children }: { children: React.ReactNode }) {
19  return (
20    <html lang="en"><body><Providers>{children}</Providers></body></html>
21  );
22}

Previous

Understanding the Server/Client Boundary

Next

Composing Server & Client Components

Use ← → arrow keys to navigate between lessons