Open History to see the last commit
1import { createRouter as createTanstackRouter } from '@tanstack/react-router'
2import { createIsomorphicFn } from '@tanstack/react-start'
3import { DbClient } from '@tanstack/react-db'
4import { routerWithDbClient } from '@tanstack/react-router-with-db'
5import { routeTree } from './routeTree.gen'
6import './styles.css'
7
8export type RouterContext = {
9 dbClient: DbClient
10}
11
12const getRuntime = createIsomorphicFn()
13 .server(() => `server` as const)
14 .client(() => `browser` as const)
15
16export function getRouter() {
17 const dbClient = new DbClient({
18 runtime: getRuntime(),
19 })
20 const router = createTanstackRouter({
21 routeTree,
22 context: { dbClient },
23 scrollRestoration: true,
24 })
25
26 return routerWithDbClient(router, dbClient)
27}