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