Course outline · 0% complete

0/29 lessons0%

Course overview →

What makes a page dynamic

lesson 7-2 · ~8 min · 23/29

Next.js decides from your code

You rarely declare a strategy. Next.js infers it: at build time it tries to prerender every page, and a page becomes dynamic when it does something only knowable at request time:

  • Reading cookies or request headers (who is asking?)
  • Reading searchParams (/search?q=shoes, what is asked?)
  • Fetching uncached data (plain fetch with no caching opted in)

No such dependency, and the page can be static. Add revalidate and a static page becomes ISR. The strategy is per-page, so one app freely mixes a static landing page, an ISR blog, and a dynamic dashboard.

Quiz

A pricing page renders fixed JSX with no fetches, no cookies, and no searchParams. What does next build do with it?

Reading the build output

After next build, Next.js prints a route table with a symbol per route: a static/prerendered marker for pages baked at build time, and a dynamic marker for pages rendered per request. Get in the habit of reading it. A page you meant to be static showing up dynamic usually means a stray cookies() call or an uncached fetch snuck in.

This diagnosis skill matters because the symptoms differ: static mistakes look like stale data, dynamic mistakes look like slow pages and server load.

Problem

A dashboard greets the signed-in user by reading a session cookie. Can next build prerender it as static HTML, yes or no?