Skip to content
Source
Sign inSign up
TanStack/router
Open History to see the last commit

RouterClient.tsx

17 lines522 Bytes

1import { hydrate } from '@tanstack/router-core/ssr/client'
2import { Await } from '../awaited'
3import { RouterProvider } from '../RouterProvider'
4import type { AnyRouter } from '@tanstack/router-core'
5​
6let hydrationPromise: Promise<void> | undefined
7​
8export function RouterClient(props: { router: AnyRouter }) {
9 hydrationPromise ??= hydrate(props.router).finally(() => window.$_TSR!.h())
10​
11 return (
12 <Await
13 promise={hydrationPromise}
14 children={() => <RouterProvider router={props.router} />}
15 />
16 )