Skip to content

docs: Add blog post about rootParams #1632

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

Draft
wants to merge 16 commits into
base: main
Choose a base branch
from
Draft
Prev Previous commit
4.0 is released now
  • Loading branch information
amannn committed Apr 29, 2025
commit 35c8435ad0d7fb069ba6477a3b105a6d6aba0c63
8 changes: 1 addition & 7 deletions docs/src/pages/blog/nextjs-root-params.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -170,15 +170,13 @@ export default getRequestConfig(async () => {
});
```

`hasLocale` is a new addition scheduled for [`next-intl@4.0`](/blog/next-intl-4-0), but practically simply checks if the provided `locales` array contains a given `locale`. If it doesn't, typically because we're not in the `[locale]` segment, a default locale is used instead.

That's it—a single change to `i18n/request.ts` is all you need to do to start using `rootParams`!

## Time for spring cleaning

With this change, you can now simplify your codebase in various ways:

### Removing a pass-through root layout
### Remove a pass-through root layout

For certain patterns like global 404 pages, you might have used a pass-through root layout so far:

Expand Down Expand Up @@ -337,10 +335,6 @@ export default async function RootLayout({children, params}: Props) {

## Try `rootParams` today!

While this article mentions an upcoming `hasLocale` API from `next-intl@4.0` that simplifies working with `rootParams`, you can already try out the API today even in the `3.0` range.

The one rare case where a change from `next-intl@4.0` is required, is if you need to [manually pass a locale](#locale-override) to async APIs like `getTranslations` in case your UI renders multiple locales in parallel.

If you're giving `rootParams` a go with `next-intl`, let me know how it works for you by joining the discussion here: [Experiences with `rootParams`](https://github.com/amannn/next-intl/discussions/1627). I'm curious to hear how it simplifies your codebase!

—Jan
Expand Down