Open History to see the last commit
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 defaultOptions: { queries: { staleTime: 30_000 } },
11 })
12β
13 const router = createRouter({
14 routeTree,
15 context: { queryClient },
16 defaultPreload: 'intent',
17 defaultPreloadStaleTime: 0,
18 defaultErrorComponent: DefaultCatchBoundary,
19 defaultNotFoundComponent: () => <NotFound />,
20 })
21 setupRouterSsrQueryIntegration({
22 router,
23 queryClient,
24 })
25β
26 return router
27}
28β
29declare module '@tanstack/react-router' {
30 interface Register {
31 router: ReturnType<typeof getRouter>
32 }
33}