You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The LocaleLayout example provided in the documentation is outdated for the latest versions of Next.js. Since Next.js 15, the params in app directory layouts are now a promise. This requires using await when destructuring params in the LocaleLayout.
Current example from the docs:
exportdefaultasyncfunctionLocaleLayout({
children,params: {locale}}: {children: React.ReactNode;params: {locale: string};}){// Ensure that the incoming `locale` is validif(!routing.locales.includes(localeasany)){notFound();}// Providing all messages to the client// side is the easiest way to get startedconstmessages=awaitgetMessages();return(<htmllang={locale}><body><NextIntlClientProvidermessages={messages}>{children}</NextIntlClientProvider></body></html>);}
Proposed update:
exportdefaultasyncfunctionLocaleLayout({
children,
params
}: {children: React.ReactNode;params: Promise<{locale: string}>;}){const{ locale }=awaitparams;// Ensure that the incoming `locale` is validif(!routing.locales.includes(localeasany)){notFound();}// Providing all messages to the client// side is the easiest way to get startedconstmessages=awaitgetMessages();return(<htmllang={locale}><body><NextIntlClientProvidermessages={messages}>{children}</NextIntlClientProvider></body></html>);}
Why this change is necessary:
The current example leads to a runtime error in Next.js 15+ because params is not destructurable until resolved as a promise. This adjustment will align the documentation with the latest Next.js API changes.
The text was updated successfully, but these errors were encountered:
Link to page
https://next-intl.dev/docs/getting-started/app-router/with-i18n-routing#layout
Describe the problem
The
LocaleLayout
example provided in the documentation is outdated for the latest versions of Next.js. Since Next.js 15, theparams
inapp
directory layouts are now a promise. This requires usingawait
when destructuringparams
in theLocaleLayout
.Current example from the docs:
Proposed update:
Why this change is necessary:
The current example leads to a runtime error in Next.js 15+ because params is not destructurable until resolved as a promise. This adjustment will align the documentation with the latest Next.js API changes.
The text was updated successfully, but these errors were encountered: