Adopt next/root-params in Next.js RSC example and tutorial
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 5.9k
- Forks
- 457
- Avg merge
- 1d 23h
- Merged PRs (30d)
- 16
Description
Next.js 16.3 introduced next/root-params, which lets any Server Component read root dynamic segments (e.g. [lang]) without prop drilling. This simplifies Lingui's RSC setup - no core changes needed, the improvements are in the example and docs.
Current state
- Every page/layout in
examples/nextjs-swctakesparams, awaits it, and passeslangtoinitLingui(lang). - The RSC tutorial documents this caveat: "you need to repeat the
setI18nin every page and layout… Please let us know if there's a known better way."
Proposed changes
Example (examples/nextjs-swc):
- Upgrade Next.js 15.0.1 → 16.3+
- Make
initLingui()read the locale vianext/root-paramsinternally, so pages/layouts/generateMetadatacall it with zero args and stop threadingparams
Docs (tutorials/react-rsc):
- Update snippets to the root-params pattern; keep the
params-prop approach for Next.js < 16.3 - Rewrite the "Pages, Layouts and Lingui" section (the per-page call remains due to React
cacheordering, but becomes a zero-arg one-liner) - Document caveats: not available in Client Components, Server Actions, or Route Handlers - pass the locale explicitly there
- Optionally: note that root-param getters are tracked in
'use cache'cache keys, sogetI18nInstance(await lang())inside cached functions is keyed per locale
Notes
Lingui's server-side useLingui()/Trans are sync and can't lazily resolve the locale themselves, so initLingui() per page/layout is still required. Removing it entirely would need an async init path in @lingui/react/server - out of scope here.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in examples/nextjs-swc by inspecting the current Next.js version, initLingui usage, and params flow, then review tutorials/react-rsc for the existing RSC guidance. Done means the example uses next/root-params with the documented version boundary, and the tutorial covers zero-argument initialization plus the listed Client Component, Server Action, and Route Handler caveats.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- nextjs, typescript
- Domain
- documentation, internationalization, web-dev
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100