amannn / next-intl

🌐 Internationalization (i18n) for Next.js
https://next-intl-docs.vercel.app
MIT License
2.58k stars 236 forks source link

docs: params is async on async layout #1534

Closed bchatard closed 3 days ago

bchatard commented 4 days ago

Since NextJS 15 the params props is async on async layout.

If we don't specify the async an error is raised in console in dev mode

Error: Route "/[locale]" used `params.locale`. `params` should be awaited before using its properties. Learn more: https://nextjs.org/docs/messages/sync-dynamic-apis
    at createParamsAccessError (node_modules/.pnpm/next@15.0.3_react-dom@19.0.0-rc-66855b96-20241106_react@19.0.0-rc-66855b96-20241106__react@19.0.0-rc-66855b96-20241106/node_modules/next/dist/src/server/request/params.ts:467:9)
    at getMessage (node_modules/.pnpm/next@15.0.3_react-dom@19.0.0-rc-66855b96-20241106_react@19.0.0-rc-66855b96-20241106__react@19.0.0-rc-66855b96-20241106/node_modules/next/dist/src/server/create-deduped-by-callsite-server-error-logger.ts:46:20)
    at warnForSyncAccess (node_modules/.pnpm/next@15.0.3_react-dom@19.0.0-rc-66855b96-20241106_react@19.0.0-rc-66855b96-20241106__react@19.0.0-rc-66855b96-20241106/node_modules/next/dist/src/server/request/params.ts:445:4)
    at syncIODev (node_modules/.pnpm/next@15.0.3_react-dom@19.0.0-rc-66855b96-20241106_react@19.0.0-rc-66855b96-20241106__react@19.0.0-rc-66855b96-20241106/node_modules/next/dist/src/server/request/params.ts:403:10)
    at LocaleLayout (src/app/[locale]/layout.tsx:32:65)
  30 | }>;
  31 |
> 32 | export default async function LocaleLayout({ children, params: { locale } }: Props) {
     |                                                                 ^
  33 |   // Ensure that the incoming `locale` is valid
  34 |   if (!routing.locales.includes(locale as string)) {
  35 |     notFound();

see: https://nextjs.org/docs/app/building-your-application/upgrading/version-15\#asynchronous-layout

vercel[bot] commented 4 days ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
next-intl-example-app-router ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 12, 2024 1:07pm
next-intl-example-app-router-without-i18n-routing ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 12, 2024 1:07pm
vercel[bot] commented 4 days ago

@bchatard is attempting to deploy a commit to the next-intl Team on Vercel.

A member of the Team first needs to authorize it.

amannn commented 3 days ago

Thanks for the PR! There's already one open at https://github.com/amannn/next-intl/pull/1089 though, I'm currently waiting for upstream bugs in Next.js 15 to be fixed before broadly updating docs (see https://github.com/amannn/next-intl/pull/1089#issuecomment-2428934266).

bchatard commented 3 days ago

Sorry I miss this PR. I'll close this one