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

router.tsx

20 lines529 Bytes

1import { createRouter } from '@tanstack/solid-router'
2import { createIsomorphicFn } from '@tanstack/solid-start'
3import { routeTree } from './routeTree.gen'
4​
5const getSSROptions = createIsomorphicFn().server(() => {
6 const array = new Uint8Array(16)
7 crypto.getRandomValues(array)
8 const nonce = Array.from(array, (b) => b.toString(16).padStart(2, '0')).join(
9 '',
10 )
11 return { nonce }
12})
13​
14export function getRouter() {
15 return createRouter({
16 routeTree,
17 scrollRestoration: true,
18 ssr: getSSROptions(),
19 })