Getting locale from cookie #2205
Replies: 1 comment 2 replies
-
|
Hey, thanks for the kind words—glad to hear if
It sounds a bit like something unexpected is calling into your You can check out App Router without locale-based routing to see a working setup, maybe that helps! |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi everyone! I appreciate the work being done here, it was a relief to abandon the previous library and adopt next-intl, it makes everything REALLY easy. Thank you all very much.
I'm a noob in next-intl, trying to use localization on server components without the routing (using cookies) and, unfortunately, I'm struggling to get the cookie locale in my server components. According to the docs, I should be able to use next server's
cookie()in myi18n/request.tsfile. I even saw a video in YouTube in which this was done successfully (in Next 15.1.3).I'm using Next 16.1.0 though. This is my i18n/request.ts:
This throws an
Uncaught Error: 'cookies' was called outside a request scope.I found a dead discussion here. This discussion has something about using middlewares, but doesn't clarify how (and I have no idea).
Is there any way to retrieve the cookies in i18n/request.ts (or some way to get the locale from the cookie and pass it to next-intl)?
Beta Was this translation helpful? Give feedback.
All reactions