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

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
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 2 of 10·Chapter 2 — Routing & Navigation with the App Router
Lesson 10 of 54Reading12 min

Intercepting Routes & Modal Patterns

#Intercepting Routes & Modal Patterns¶

Intercepting routes solve a classic problem: clicking a thumbnail should open a modal, but visiting the URL directly should show a full page.

The Convention¶

PrefixMeaning
(.)Match the same level
(..)Match one level up
(..)(..)Match two levels up
(...)Match from the app root

These are folder names, not file names.

A Photo Gallery Example¶

We want /photo/:id to:

  • Show a full page when the URL is opened or refreshed
  • Show a modal over the feed when navigated to from /feed
app/ feed/ page.tsx @modal/ (.)photo/[id]/page.tsx ← intercepts /photo/:id when nav happens from /feed default.tsx layout.tsx ← renders {children} and {modal} photo/[id]/page.tsx ← the regular, full-page version

The Layout¶

tsx
12 lines
1// app/feed/layout.tsx
2export default function FeedLayout({ children, modal }: {
3  children: React.ReactNode;
4  modal: React.ReactNode;
5}) {
6  return (
7    <>
8      {children}
9      {modal}     {/* renders the intercepted modal when present */}
10    </>
11  );
12}

The Modal¶

tsx
14 lines
1// app/feed/@modal/(.)photo/[id]/page.tsx
2import { Dialog } from "@/components/ui/dialog";
3import { getPhoto } from "@/lib/photos";
4
5export default async function PhotoModal({ params }: { params: Promise<{ id: string }> }) {
6  const { id } = await params;
7  const photo = await getPhoto(id);
8  return (
9    <Dialog open>
10      <img src={photo.src} alt={photo.caption} />
11      <p>{photo.caption}</p>
12    </Dialog>
13  );
14}

The Default Slot¶

If you navigate to /feed directly, the modal slot has nothing to render:

tsx
4 lines
1// app/feed/@modal/default.tsx
2export default function Default() {
3  return null;
4}

The Trigger¶

tsx
5 lines
1import Link from "next/link";
2
3<Link href={`/photo/${photo.id}`}>      {/* navigated → modal opens */}
4  <img src={photo.thumb} alt="" />
5</Link>

A right-click → "open in new tab" loads the full page route at app/photo/[id]/page.tsx. The URL is the same.

Closing the Modal¶

Push back to the parent route:

tsx
7 lines
1"use client";
2import { useRouter } from "next/navigation";
3
4export function CloseButton() {
5  const router = useRouter();
6  return <button onClick={() => router.back()}>Close</button>;
7}

Real-World Recipes¶

  • Image lightbox on a gallery
  • Login modal that overlays the page you were on (deep-linkable)
  • Quick view of a product card on a shop listing
  • Comment thread opened from a notifications feed

When NOT to Use Intercepting Routes¶

  • The modal has no URL of its own. Use a regular client component.
  • You need to render the modal from anywhere in the app, not just a single segment. Use a portal pattern.
  • You want a drawer that doesn't change the URL. Don't intercept — keep it local state.

Previous

Route Groups & Parallel Routes

Next

Loading, Error & Not-Found UI

Use ← → arrow keys to navigate between lessons