Skip to solution
mediumFrontend

What makes a route dynamic in the Next.js App Router?

950 views
01

Understand the problem

Dynamic functions and uncached data opt a route out of static rendering.

nextjsdynamic-renderingcookiesheaders
02

Attempt it yourself

Sketch your approach before reading the solution — that's what interviews test.

Nudge consolestandby

Stuck? Beam a request up — the console returns a conceptual nudge that guides your logic without spoiling the implementation.

03

Study the solution

Using cookies(), headers(), draftMode(), or the searchParams prop, or fetching with no-store / no cache, makes a route dynamic (rendered per request). Without those, Next.js prerenders the route statically by default.

Solution ready — 2 min read

Classified // press E to declassify

04

Read the code

Both ways to opt into dynamic
// Implicit: reading a dynamic function
import { headers } from 'next/headers';
const ua = (await headers()).get('user-agent');   // → dynamic

// Or uncached data:
await fetch('https://api/now', { cache: 'no-store' });  // → dynamic

// Explicit segment config:
export const dynamic = 'force-dynamic';
export const revalidate = 0;
05

Join the discussion

Discussion (0)

Sign in to join the discussion.

No responses yet. Be the first to share what you think.

Transmission complete // awaiting log

KEEP THE
STREAK ALIVE.

Dossier 25 of 95 decoded in the Next.js track. One more won't hurt.

Back to track