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

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 11 of 54Reading12 min

Loading, Error & Not-Found UI

#Loading, Error & Not-Found UI¶

loading.tsx — Streaming UI¶

Drop a loading.tsx in a route segment to wrap its page.tsx in a Suspense boundary automatically.

tsx
9 lines
1// app/dashboard/loading.tsx
2export default function Loading() {
3  return (
4    <div className="space-y-3 p-8">
5      <div className="h-8 w-1/3 rounded bg-gray-200 animate-pulse" />
6      <div className="h-32 w-full rounded bg-gray-200 animate-pulse" />
7    </div>
8  );
9}

While the server renders page.tsx, the browser sees the skeleton immediately.

Nested loading.tsx¶

app/ dashboard/loading.tsx ← shown on /dashboard, /dashboard/* dashboard/billing/loading.tsx ← takes over inside billing

A nested loading state replaces the parent's only for its own subtree.

error.tsx — Per-Segment Error Boundaries¶

tsx
20 lines
1// app/dashboard/error.tsx
2"use client";
3
4export default function DashboardError({
5  error,
6  reset,
7}: {
8  error: Error & { digest?: string };
9  reset: () => void;
10}) {
11  return (
12    <div className="p-8 text-center">
13      <h2 className="text-xl font-bold">Something went wrong</h2>
14      <p className="text-sm text-gray-600">Error code: {error.digest}</p>
15      <button onClick={reset} className="mt-4 rounded bg-black px-4 py-2 text-white">
16        Try again
17      </button>
18    </div>
19  );
20}

error.tsx must be a Client Component (it uses React's error boundary mechanism). The reset() function re-renders the segment.

Why Per-Segment?¶

The error catcher resets independently. A failure in /dashboard/billing doesn't blank out the dashboard chrome — only the billing region shows the error UI.

global-error.tsx — Catches Root Layout Crashes¶

tsx
13 lines
1// app/global-error.tsx
2"use client";
3
4export default function GlobalError({ error, reset }: ErrorProps) {
5  return (
6    <html>
7      <body>
8        <h2>Application crashed</h2>
9        <button onClick={reset}>Retry</button>
10      </body>
11    </html>
12  );
13}

This file is mandatory to render when even the root layout fails — that's why it includes its own <html><body>.

not-found.tsx — Friendly 404s¶

Render when you call notFound() or hit an unmatched URL.

tsx
5 lines
1// app/blog/[slug]/page.tsx
2import { notFound } from "next/navigation";
3
4const post = await db.post.findUnique({ where: { slug } });
5if (!post) notFound();   // unwinds, renders the nearest not-found.tsx
tsx
9 lines
1// app/blog/[slug]/not-found.tsx
2export default function NotFound() {
3  return (
4    <div className="p-8 text-center">
5      <h1 className="text-3xl font-bold">Post not found</h1>
6      <Link href="/blog">← Back to blog</Link>
7    </div>
8  );
9}

Throwing Errors From Server Components¶

tsx
5 lines
1export default async function Page() {
2  const data = await fetch("/api/something");
3  if (!data.ok) throw new Error("Upstream failure");
4  // … nearest error.tsx renders
5}

In production the error message is redacted from the client and replaced with a unique error.digest. Use the digest to look up the full trace in your server logs.

Putting It All Together¶

app/dashboard/ layout.tsx loading.tsx ← shows skeleton while page streams error.tsx ← catches errors in the dashboard tree not-found.tsx ← shown if notFound() is called inside page.tsx billing/ loading.tsx error.tsx page.tsx

This is the production-grade default. Build it once, never think about generic loading/error screens again.

Previous

Intercepting Routes & Modal Patterns

Next

Chapter 2 — Routing Quiz

Use ← → arrow keys to navigate between lessons