This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
[Docs]: Change locale in App Router without-i18n-routing #1334
Labels
You can continue the conversation there. Go to discussion →
Link to page
https://next-intl-docs.vercel.app/docs/getting-started/app-router/without-i18n-routing
Describe the problem
I'm using next-intl in the App Router without-i18n-routing configuration.
Point 3 of the linked documentation reports:
But say nothing about how to handle changes in that user setting.
As example, consider the case in which the language is stored in a database (language is a general app setting). When someone changes the database, we expect the language to change too.
So we need a way to refresh the getLocale() calling.
Currently, the only way I found to achieve this is by using both
revalidatePath("/", "layout")
(on the server) androuter.refresh()
(on the client)I have a subscription on my database key changes, once I see a change, i trigger a rootLayout revalidation by using
revalidatePath("/", "layout")
and then notify the client to refresh the router viarouter.refresh()
But this solution does not seem stable (see below).
My question (and suggestion for a doc updates) is: is this the correct way to handle locale changes without-i18n-routing?
NOTE:
I said that 'seems not stable' because I saw that next js hits cache while revalidating path. In fact, I see the cookie
x-nextjs-cache: HIT
in the header response of therevalidatePath("/", "layout")
Looking at your 790, it seems to me that all the magic to avoid cache hitting is done in the middleware, which is not required in the without-i18n-routing
The text was updated successfully, but these errors were encountered: