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

StartClient.tsx

37 lines979 Bytes

1import { Await, HeadContent, RouterProvider } from '@tanstack/solid-router'
2import { hydrateStart } from '@tanstack/start-client-core/client'
3import type { AnyRouter } from '@tanstack/router-core'
4import type { JSXElement } from 'solid-js'
5​
6let hydrationPromise: Promise<AnyRouter> | undefined
7​
8const Dummy = (props: { children?: JSXElement }) => <>{props.children}</>
9​
10export function StartClient() {
11 if (!hydrationPromise) {
12 hydrationPromise = hydrateStart()
13 }
14 return (
15 <Await
16 promise={hydrationPromise}
17 children={(router) => (
18 <Dummy>
19 <Dummy>
20 <RouterProvider
21 router={router}
22 InnerWrap={(props) => (
23 <Dummy>
24 <Dummy>
25 <HeadContent />
26 {props.children}
27 </Dummy>
28 <Dummy />
29 </Dummy>
30 )}
31 />
32 </Dummy>
33 </Dummy>
34 )}
35 />
36 )