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

router.tsx

36 lines943 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 defaultOptions: {
11 queries: {
12 experimental_prefetchInRender: true,
13 },
14 },
15 })
16​
17 const router = createRouter({
18 routeTree,
19 context: { queryClient },
20 defaultPreload: 'intent',
21 defaultErrorComponent: DefaultCatchBoundary,
22 defaultNotFoundComponent: () => <NotFound />,
23 })
24 setupRouterSsrQueryIntegration({
25 router,
26 queryClient,
27 })
28​
29 return router
31​
32declare module '@tanstack/solid-router' {
33 interface Register {
34 router: ReturnType<typeof getRouter>
35 }