Pre-render dynamic routes at build time
generateStaticParams is the App Router's equivalent of getStaticPaths. Export it from a dynamic route, return the list of params to pre-build, and Next.js generates static HTML for each at build time.
Default behavior for unknown params
Paths not in your list render on demand and get cached. Set export const dynamicParams = false to 404 unknown slugs instead.
Multi-level dynamic segments
For nested dynamic segments, return objects that fill in all segments. The function runs once at build; it doesn't have to enumerate every combination — only the ones you want pre-built.
Prebuild the dynamic paths whose first visit matters most. Use traffic and editorial importance to choose the list, leave the long tail for on-demand rendering, and set dynamicParams = false only when unknown identifiers are truly invalid.
Prebuilding everything moves runtime cost into every deployment and scales with the catalog. Prebuilding nothing makes the first visitor to each path pay. A measured hybrid usually gives the best deployment and request profile. Count generated pages, build duration, and artifact size as the data set grows. Compare first and second requests for an unlisted path, then disable dynamic params. Include deletion behavior so removed content does not survive as an old static page.