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

router.tsx

23 lines752 Bytes

1import { QueryClient } from '@tanstack/react-query'
2import { createRouter } from '@tanstack/react-router'
3import { setupRouterSsrQueryIntegration } from '@tanstack/react-router-ssr-query'
4import { routeTree } from './routeTree.gen'
5import { DefaultCatchBoundary } from './components/DefaultCatchBoundary'
6import { NotFound } from './components/NotFound'
7​
8export function getRouter() {
9 const queryClient = new QueryClient()
10 const router = createRouter({
11 routeTree,
12 context: { queryClient },
13 scrollRestoration: true,
14 defaultPreload: 'intent',
15 defaultErrorComponent: DefaultCatchBoundary,
16 defaultNotFoundComponent: () => <NotFound />,
17 })
18 setupRouterSsrQueryIntegration({
19 router,
20 queryClient,
21 })
22 return router