@@ -591,15 +591,33 @@ export async function generateStaticParams() {
...
@@ -591,15 +591,33 @@ export async function generateStaticParams() {
}
}
```
```
Pathsyoudon't return are still served. Next.js prerenders a static shell for the unknown params and streams the rest at request time. See [ISR with Cache Components](/docs/app/guides/incremental-static-regeneration-cache-components) for the full prerender-a-subset workflow.
Bydefault,pathsyoudon't return are still served. Next.js prerenders a static shell for the unknown params and streams the rest at request time. See [ISR with Cache Components](/docs/app/guides/incremental-static-regeneration-cache-components) for the full prerender-a-subset workflow.
### `dynamicParams` is not supported
### Use `dynamicParams = false` to reject unknown params
**Delete the export.** With Cache Components enabled, exporting `dynamicParams` fails the build with this error message:
Keep `dynamicParams = false` if the values returned by `generateStaticParams` are the complete set of paths that should exist for this deployment:
> Route segment config "dynamicParams" is not compatible with `nextConfig.cacheComponents`.
Next.js records the complete generated parameter combinations at build time. A request for any other combination returns a hard 404 before the Page component or Route Handler runs and before a fallback shell is sent. Revalidating a generated path can update its content, but does not add new parameter combinations. Add new paths by returning them from `generateStaticParams` in a new deployment.
Params not returned by `generateStaticParams` are rendered on request. If you used `dynamicParams: false` to reject them, call [`notFound()`](/docs/app/api-reference/functions/not-found) in the page when the param doesn'tresolvetorealdata.
If unknown params should render on demand, omit `dynamicParams` or set it to `true` and follow the `<Suspense>` guidance below.
@@ -5,7 +5,7 @@ description: API reference for the dynamicParams route segment config option.
...
@@ -5,7 +5,7 @@ description: API reference for the dynamicParams route segment config option.
The `dynamicParams` option allows you to control what happens when a dynamic segment is visited that was not generated with [generateStaticParams](/docs/app/api-reference/functions/generate-static-params).
The `dynamicParams` option allows you to control what happens when a dynamic segment is visited that was not generated with [generateStaticParams](/docs/app/api-reference/functions/generate-static-params).
> - This option replaces the `fallback: true | false | blocking` option of `getStaticPaths` in the `pages` directory.
> - This option replaces the `fallback: true | false | blocking` option of `getStaticPaths` in the `pages` directory.
> - `dynamicParams` is not available when [Cache Components](/docs/app/api-reference/config/next-config-js/cacheComponents) is enabled.
> - With [Cache Components](/docs/app/api-reference/config/next-config-js/cacheComponents), `false` treats the complete parameter combinations returned by `generateStaticParams` as the allowed paths for that deployment. Other combinations return a 404 before the Page component or Route Handler runs, and no fallback shell is sent.
> - [`generateStaticParams`](/docs/app/api-reference/functions/generate-static-params) is not called again during revalidation. To add a path to a closed dynamic route, create a new deployment that returns the path from `generateStaticParams`.