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

router.tsx

30 lines838 Bytes

1import { QueryClient } from '@tanstack/solid-query'
2import { createRouter } from '@tanstack/solid-router'
3import { setupRouterSsrQueryIntegration } from '@tanstack/solid-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
25​
26declare module '@tanstack/solid-router' {
27 interface Register {
28 router: ReturnType<typeof getRouter>
29 }