amannn / next-intl

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

Next 15 breaking Async Request APIs #1471

Closed ChiefORZ closed 3 weeks ago

ChiefORZ commented 3 weeks ago

Description

With the breaking change of the Next.js version 15 of the Async Request APIs we need to change the implementation of receiving the headers in Server-Side Rendering.

Currently the following error occurs, when trying to access const t = useTranslations() in an Server Component:

[ Server ]  Error: Route "/[locale]" used `headers().get('X-NEXT-INTL-LOCALE')`. `headers()` should be awaited before using its value. Learn more: https://nextjs.org/docs/messages/sync-dynamic-apis

Verifications

Mandatory reproduction URL

https://github.com/amannn/next-intl-bug-repro-app-router

Reproduction description

git clone https://github.com/amannn/next-intl-bug-repro-app-router
cd next-intl-bug-repro-app-router
pnpm i
pnpm up next@^15
pnpm dev

Expected behaviour

Repository should be updated to support next@15

ChiefORZ commented 3 weeks ago

duplicate of https://github.com/amannn/next-intl/issues/1375#issue-2552102735

amannn commented 3 weeks ago

Please see: https://github.com/amannn/next-intl/issues/1375#issuecomment-2439437363