Next.js automatically determines whether a route should be rendered statically at build time (Static Site Generation - SSG) or dynamically on every user request (Server-Side Rendering - SSR). For dynamic routes with parameters, generateStaticParams unlocks blazing static performance.
npm run build) or during background revalidation. Resulting files are cached globally on edge CDNs for near-zero millisecond response times.cookies(), headers(), searchParams).If a component uses information specific to an incoming user request, Next.js automatically opts that route into Dynamic Rendering:
cookies() from next/headersheaders() from next/headerssearchParams in page.tsxgenerateStaticParamsFor dynamic paths like app/courses/[slug]/page.tsx, Next.js doesn't know what slugs exist at build time unless you specify them. generateStaticParams queries your database during build time to generate static HTML pages for all known slugs!
dynamicParams)Control what happens when a user visits a dynamic slug that was NOT generated at build time:
generateStaticParams function do in dynamic routes?cookies() or headers() from next/headers?export const dynamicParams = false; in a page do?npm run build output indicates that a route has been statically pre-rendered?Continue learning with hands-on practice, examples, and exercises in the upcoming topic.
Test your understanding of this lesson with 5 questions. Each question has one correct answer.
Practice in live mentor-led sessions with real projects, mock tests, and verifiable certification at MSK Institute.