Reject ungenerated paths
A product or documentation site should serve only a known catalog of generated slugs.
Next.js 16+ · Const
dynamicParams controls requests for dynamic route segments that generateStaticParams did not generate. It defaults to true for request-time generation; false makes those paths return 404.
Export this route-segment setting from a layout, page, or route to decide how dynamic paths missing from generateStaticParams behave. Keep the default true to generate such paths at request time, or use false to make them return a 404.
export const dynamicParams = true // true | false| Name | Type | Description |
|---|---|---|
dynamicParams | boolean | A boolean route-segment setting: true enables request-time generation for omitted paths, while false makes omitted paths return 404. |
// app/blog/[slug]/page.tsx
export const dynamicParams = false
export function generateStaticParams() {
return [{ slug: "hello-world" }]
}
export default async function Page({
params,
}: {
params: Promise<{ slug: string }>
}) {
const { slug } = await params
return <h1>{slug}</h1>
}Only the slug returned by generateStaticParams is served; another slug receives a 404.
A product or documentation site should serve only a known catalog of generated slugs.
A route should support new parameter values beyond the build-time list.
Migrating an application from the Pages Router's getStaticPaths fallback behavior.
It controls requests for dynamic segments that generateStaticParams did not return. true, the default, generates those segments at request time; false returns a 404.
Follow-up: How would you prevent runtime generation while retaining a successful response for unknown data? Keep dynamicParams true and handle missing data with notFound() in the page.
Export dynamicParams as a boolean from a page, layout, or route segment. Its value applies to dynamic segments not included in generateStaticParams.
Follow-up: What happens when Cache Components is enabled? The export is unsupported and should be removed; use notFound() when a parameter does not resolve to real data.
The default true allows omitted dynamic paths to be generated on demand. Setting it to false restricts serving to generated paths and makes omitted paths return 404.
Follow-up: Which older routing API did this replace? It replaces getStaticPaths fallback modes from the Pages Router.
generateStaticParamsdynamicgetStaticPathsCache Componentsdynamic segments