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β
11 const router = createRouter({
12 routeTree,
13 context: { queryClient },
14 defaultPreload: 'intent',
15 defaultErrorComponent: DefaultCatchBoundary,
16 defaultNotFoundComponent: () => <NotFound />,
17 })
18 setupRouterSsrQueryIntegration({
19 router,
20 queryClient,
21 })
22β
23 return router
24}
25β
26declare module '@tanstack/react-router' {
27 interface Register {
28 router: ReturnType<typeof getRouter>
29 }
30}