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

router.tsx

24 lines633 Bytes

1import { createRouter } from '@tanstack/react-router'
2import { setupRouterSsrQueryIntegration } from '@tanstack/react-router-ssr-query'
3import * as TanstackQuery from './integrations/tanstack-query/root-provider'
4​
5// Import the generated route tree
6import { routeTree } from './routeTree.gen'
7​
8// Create a new router instance
9export const getRouter = () => {
10 const rqContext = TanstackQuery.getContext()
11​
12 const router = createRouter({
13 routeTree,
14 context: {
15 ...rqContext,
16 },
17​
18 defaultPreload: 'intent',
19 })
20​
21 setupRouterSsrQueryIntegration({ router, queryClient: rqContext.queryClient })
22​
23 return router