@@ -4,10 +4,16 @@ import { createInstance } from "i18next"
44import { isbot } from "isbot"
55import { renderToPipeableStream } from "react-dom/server"
66import { I18nextProvider , initReactI18next } from "react-i18next"
7- import { type AppLoadContext , type EntryContext , type HandleDataRequestFunction , ServerRouter } from "react-router"
7+ import {
8+ type EntryContext ,
9+ type HandleDataRequestFunction ,
10+ type RouterContextProvider ,
11+ ServerRouter ,
12+ } from "react-router"
813import i18n from "./localization/i18n" // your i18n configuration file
914import i18nextOpts from "./localization/i18n.server"
1015import { resources } from "./localization/resource"
16+ import { globalAppContext } from "./server/context"
1117
1218// Reject all pending promises from handler functions after 10 seconds
1319export const streamTimeout = 10000
@@ -17,11 +23,12 @@ export default async function handleRequest(
1723 responseStatusCode : number ,
1824 responseHeaders : Headers ,
1925 context : EntryContext ,
20- appContext : AppLoadContext
26+ appContext : RouterContextProvider
2127) {
2228 const callbackName = isbot ( request . headers . get ( "user-agent" ) ) ? "onAllReady" : "onShellReady"
2329 const instance = createInstance ( )
24- const lng = appContext . lang
30+ const ctx = appContext . get ( globalAppContext )
31+ const lng = ctx . lang
2532 const ns = i18nextOpts . getRouteNamespaces ( context )
2633
2734 await instance
@@ -48,7 +55,7 @@ export default async function handleRequest(
4855
4956 resolve (
5057 // @ts -expect-error - We purposely do not define the body as existent so it's not used inside loaders as it's injected there as well
51- appContext . body ( stream , {
58+ ctx . body ( stream , {
5259 headers : responseHeaders ,
5360 status : didError ? 500 : responseStatusCode ,
5461 } )
0 commit comments