Open History to see the last commit
1import { createRouter } from '@tanstack/react-router'
2import { createIsomorphicFn } from '@tanstack/react-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 })
20}