Repository navigation
docs: enable static rendering in the Next.js next-intl guide - #1160
Merged
Merged
Conversation
getTolgee() and getTranslate() resolve the locale with next-intl's getLocale(), which falls back to reading request headers unless setRequestLocale() was called. That opts every route under the layout into dynamic rendering (tolgee/tolgee-js#3526). - Call setRequestLocale() in the layout and add generateStaticParams - Add a "Static rendering" section: pages using getTranslate() must call setRequestLocale() too - Return `locale` from i18n/request.ts, which next-intl 4 requires Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
👷 Deploy request for tolgee-docs pending review.Visit the deploys page to approve it
|
- rename the section to "Rendering Pages Statically" and open it with what to do - call setRequestLocale in every layout and page, also for getTolgee and the server T component - load messages/*.json through staticData in src/tolgee/shared.ts - note that static pages hold build-time translations and how revalidate refreshes them - link the section from the App router guide and the Next.js overview
…l-static-rendering
Anty0
enabled auto-merge (squash)
December 4, 2026 17:34
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes the guide side of tolgee/tolgee-js#3526.
Problem
In the App Router with next-intl guide, the layout calls
getTolgee(), which resolves the locale with next-intl'sgetLocale(). WithoutsetRequestLocale(locale), next-intl reads the locale from request headers, so every route under the layout is forced into dynamic rendering:TolgeeProvideris not the cause: with the provider removed butgetTolgee()kept, the error remains. WithoutgetTolgee(), the provider renders statically.Changes
setRequestLocale(locale)beforegetTolgee(), and addgenerateStaticParamsgetTranslate()must callsetRequestLocaletoo, because layouts and pages render independently. With it only in the layout, such a page still fails.src/i18n/request.ts: returnlocale. The current{ messages: { locale } }doesn't type-check with next-intl 4 (RequestConfigrequireslocale).Verified
Built with
@tolgee/react/@tolgee/web7.3.0,next16.2.12,next-intl4.13.7, React 19:next buildused headers()/enrenders "Hello world!",/csrenders "Ahoj světe!"