Replies: 1 comment 3 replies
-
|
Global request middleware context doesn't flow into route The idea is: // routes/__root.tsx
export const Route = createRootRouteWithContext<{ locale: string; messages: Record<string, string> }>()({
beforeLoad: async () => {
const locale = getLocale() // createIsomorphicFn: server reads request URL, client reads window.location
const { messages } = await loadTranslations({ data: locale })
return { locale, messages }
},
component: RootComponent,
})Because The middleware approach would be cleaner if #6395 lands, but |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I need to do these things at root level:
langattribute of<html>element to resolved locale.Obviously non-root routes can't change the content of
<html>element nor pass any values to context providers, which are declared way higher in the tree than route pages.I tried to do something revolving around global middleware returning locale and translation resources to context in
src/start.ts, but the root loader doesn't pick on context signature change from that file.Beta Was this translation helpful? Give feedback.
All reactions