SkillByAIOpen interactive version →

Lesson 11 / 25

Prerendering Dynamic Routes

Static pages for known params.

generateStaticParams at build time

Dynamic segments can still be static: return the known params from generateStaticParams and Next.js prerenders each one at build time (marked ● in the build output). Requests for params that were not listed can be rendered on demand and cached, or rejected with export const dynamicParams = false. For very large sites, prerender the most popular pages and let the rest render on first request.

The prerendered product pages in the build output, run

I built the demo store with next build (Next.js 16.3.8), started it with next start and requested pages with curl; the output is copied from that run, trimmed to the relevant lines. The three products returned by generateStaticParams were prerendered as static HTML.

npx next build

Output:

├   /products/[id]
│ ├ ● /products/1
│ ├ ● /products/2
│ └ ● /products/3

Prerender the popular pages

For thousands of items, prerender the top sellers and let the long tail render on demand.

Quick check: What does ● (SSG) mean in the build output?

  • A client-only page
  • A failed page
  • An API route
  • Pages prerendered as static HTML from generateStaticParams
Answer

Pages prerendered as static HTML from generateStaticParams — Static generation for known params.