Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incremental Static Regeneration - docs update explaining surprising behavior #66151

Merged
merged 12 commits into from
Jun 10, 2024
Merged
6 changes: 6 additions & 0 deletions docs/02-app/01-building-your-application/04-caching/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,12 @@ For [dynamic segments](/docs/app/building-your-application/routing/dynamic-route

You can disable caching at request time by using `export const dynamicParams = false` option in a route segment. When this config option is used, only paths provided by `generateStaticParams` will be served, and other routes will 404 or match (in the case of [catch-all routes](/docs/app/building-your-application/routing/dynamic-routes#catch-all-segments)).

#### Incremental Static Regeneration
Even if you don't have any static routes to render at build time, you still need `generateStaticParams` to return an empty array if you want dynamically generated pages to be cached.
```jsx
export const generateStaticParams = async () => [];
```

See the [`generateStaticParams` API reference](/docs/app/api-reference/functions/generate-static-params).

### React `cache` function
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ export const dynamicParams = true // true | false,
> **Good to know**:
>
> - This option replaces the `fallback: true | false | blocking` option of `getStaticPaths` in the `pages` directory.
> - Even though this defaults to true, your pages won't be cached unless your layout or page also makes use of `generateStaticParams`, even if it only returns an empty array.
delbaoliveira marked this conversation as resolved.
Show resolved Hide resolved
> - When `dynamicParams = true`, the segment uses [Streaming Server Rendering](/docs/app/building-your-application/routing/loading-ui-and-streaming#streaming-with-suspense).
> - If the `dynamic = 'error'` and `dynamic = 'force-static'` are used, it'll change the default of `dynamicParams` to `false`.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export default function Page({ params }) {
> **Good to know**
>
> - You can use the [`dynamicParams`](/docs/app/api-reference/file-conventions/route-segment-config#dynamicparams) segment config option to control what happens when a dynamic segment is visited that was not generated with `generateStaticParams`.
> - You must include `generateStaticParams` even if you only want pages to be cached *after* build time.
delbaoliveira marked this conversation as resolved.
Show resolved Hide resolved
> - During `next dev`, `generateStaticParams` will be called when you navigate to a route.
> - During `next build`, `generateStaticParams` runs before the corresponding Layouts or Pages are generated.
> - During revalidation (ISR), `generateStaticParams` will not be called again.
Expand Down
Loading