@@ -0,0 +1,32 @@
|
||||
// SPDX-License-Identifier: LicenseRef-ConusAI-Template-1.0
|
||||
// The client entry: start observability before the app hydrates (what Next's `instrumentation-client.ts`
|
||||
// did; src/observe/browser.ts holds all of it), then hydrate the document the server rendered.
|
||||
//
|
||||
// Install React event replay immediately, and prepare the current view before its first render.
|
||||
// The server-rendered page remains in place while the router and its matched view load.
|
||||
|
||||
import "./zod-browser"
|
||||
|
||||
import { instrumentationClient } from "@conusai-sdk/observe-start/client"
|
||||
import { Await, RouterProvider } from "@tanstack/react-router"
|
||||
import { hydrateStart } from "@tanstack/react-start/client"
|
||||
import { StrictMode, startTransition } from "react"
|
||||
import { hydrateRoot } from "react-dom/client"
|
||||
import { startBrowserObserve } from "./observe/browser"
|
||||
import { prepareInitialModuleViews } from "./ui/page-views"
|
||||
|
||||
export const observe = startBrowserObserve(document, instrumentationClient)
|
||||
|
||||
const hydration = hydrateStart().then(async (router) => {
|
||||
await prepareInitialModuleViews(router.state.matches)
|
||||
return router
|
||||
})
|
||||
|
||||
startTransition(() => {
|
||||
hydrateRoot(
|
||||
document,
|
||||
<StrictMode>
|
||||
<Await promise={hydration}>{(router) => <RouterProvider router={router} />}</Await>
|
||||
</StrictMode>,
|
||||
)
|
||||
})
|
||||
Reference in New Issue
Block a user