0
Challenge · 22Rendering & Caching
Static generation & generateStaticParams
Renderingused in ~80% of apps
A dynamic route like /jobs/[slug] sounds like it must run on every request — that is the trap. With generateStaticParams you can pre-render every job page at build time, so a 'dynamic' URL becomes a static file served from the edge in milliseconds. Interviewers love this one because most tutorials never make the distinction crisp.
Core idea. A `[slug]` segment describes the URL *shape*; it says nothing about *when* the page renders. `generateStaticParams` returns the list of concrete params to pre-render at build time, turning a dynamic route into a set of fully static pages — no request-time work, no database hit per visit.
poke it, drag it,
try to break it
try to break it
no slides here.
you drive.
you drive.
Playground, this isn't a screenshot
component tree server client
<LikeButton />Server Component
Build error: useState / onClick are not allowed in a Server Component. Add "use client" to fix it.
Render HTML / read props
await data directly (db, fetch)
useState / useEffectclient only
onClick & event handlersclient only
window / localStorageclient only
JS shipped to browser0 KB
JavaScript shipped to the browser0 KB / 71 KB if all client
2 interactive component(s) are still Server Components— they would crash the build because Server Components can't use state or event handlers. Select one and add "use client".
↑ play a little first, then dig in