Open History to see the last commit
1import { QueryClient } from '@tanstack/react-query'
2import { createRouter as createTanStackRouter } from '@tanstack/react-router'
3import { routerWithQueryClient } from '@tanstack/react-router-with-query'
4import { routeTree } from './routeTree.gen'
5import { DefaultCatchBoundary } from './components/DefaultCatchBoundary'
6import { NotFound } from './components/NotFound'
7β
8// NOTE: Most of the integration code found here is experimental and will
9// definitely end up in a more streamlined API in the future. This is just
10// to show what's possible with the current APIs.
11β
12export function createRouter() {
13 const queryClient = new QueryClient()
14β
15 return routerWithQueryClient(
16 createTanStackRouter({
17 routeTree,
18 context: { queryClient },
19 defaultPreload: 'intent',
20 defaultErrorComponent: DefaultCatchBoundary,
21 defaultNotFoundComponent: () => <NotFound />,
22 }),
23 queryClient,
24 )
25}
26β
27declare module '@tanstack/react-router' {
28 interface Register {
29 router: ReturnType<typeof createRouter>
30 }
31}