Skip to content

Commit

Permalink
docs: Mention that generateStaticParams can be used on individual p…
Browse files Browse the repository at this point in the history
…ages
  • Loading branch information
amannn committed Sep 23, 2024
1 parent 7a55799 commit 12fd5c5
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions docs/pages/docs/getting-started/app-router/with-i18n-routing.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -256,15 +256,22 @@ In case you ran into an issue, have a look at [the App Router example](/examples

## Static rendering

When using the setup with i18n routing, `next-intl`will currently opt into dynamic rendering when APIs like `useTranslations` are used in Server Components. This is a limitation that we aim to remove in the future, but as a stopgap solution, `next-intl` provides a temporary API that can be used to enable static rendering:
When using the setup with i18n routing, `next-intl`will currently opt into dynamic rendering when APIs like `useTranslations` are used in Server Components. This is a limitation that we aim to remove in the future, but as a stopgap solution, `next-intl` provides a temporary API that can be used to enable static rendering.

<Steps>

### Add `generateStaticParams` to `app/[locale]/layout.tsx`
### Add `generateStaticParams`

Since we are using a dynamic route segment for the `[locale]` param, we need to pass all possible values to Next.js via [`generateStaticParams`](https://nextjs.org/docs/app/api-reference/functions/generate-static-params) so that the routes can be rendered at build time.

```tsx filename="app/[locale]/layout.tsx"
Depending on your needs, you can add `generateStaticParams` either to a layout or pages:

1. **Layout**: Enables static rendering for all pages within this layout (e.g. `app/[locale]/layout.tsx`)
2. **Individual pages**: Enables static rendering for a specific page (e.g. `app/[locale]/page.tsx`)

**Example:**

```tsx
import {routing} from '@/i18n/routing';

export function generateStaticParams() {
Expand Down

0 comments on commit 12fd5c5

Please sign in to comment.