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

router.tsx

32 lines890 Bytes

1import { createRouter } from '@tanstack/solid-router'
2import { setupRouterSsrQueryIntegration } from '@tanstack/solid-router-ssr-query'
3import { QueryClient } from '@tanstack/solid-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 const router = createRouter({
11 routeTree,
12 defaultPreload: 'intent',
13 defaultErrorComponent: DefaultCatchBoundary,
14 defaultNotFoundComponent: () => <NotFound />,
15 scrollRestoration: true,
16 context: {
17 foo: {
18 bar: 'baz',
19 },
20 },
21 })
22​
23 setupRouterSsrQueryIntegration({ router, queryClient })
24​
25 return router
27​
28declare module '@tanstack/solid-router' {
29 interface Register {
30 router: ReturnType<typeof getRouter>
31 }