()
| 7 | import { getServerEnvs } from './server/get-envs'; |
| 8 | |
| 9 | export const getRouter = async () => { |
| 10 | const envs = await getServerEnvs(); |
| 11 | const rqContext = TanstackQuery.getContext(envs.apiUrl); |
| 12 | |
| 13 | const router = createTanstackRouter({ |
| 14 | scrollRestoration: true, |
| 15 | routeTree, |
| 16 | context: { |
| 17 | ...rqContext, |
| 18 | ...envs, |
| 19 | session: { |
| 20 | session: null, |
| 21 | user: null, |
| 22 | userId: null, |
| 23 | }, |
| 24 | }, |
| 25 | defaultPreload: 'intent', |
| 26 | defaultNotFoundComponent: () => ( |
| 27 | <FullPageEmptyState |
| 28 | title="Page not found" |
| 29 | description="The page you're looking for doesn't exist or has moved." |
| 30 | className="min-h-screen" |
| 31 | > |
| 32 | <LinkButton href="/">Go to home</LinkButton> |
| 33 | </FullPageEmptyState> |
| 34 | ), |
| 35 | Wrap: (props: { children: React.ReactNode }) => { |
| 36 | return ( |
| 37 | <TanstackQuery.Provider {...rqContext} apiUrl={envs.apiUrl}> |
| 38 | {props.children} |
| 39 | </TanstackQuery.Provider> |
| 40 | ); |
| 41 | }, |
| 42 | }); |
| 43 | |
| 44 | setupRouterSsrQueryIntegration({ |
| 45 | router, |
| 46 | queryClient: rqContext.queryClient, |
| 47 | }); |
| 48 | |
| 49 | return router; |
| 50 | }; |
| 51 | |
| 52 | declare module '@tanstack/react-router' { |
| 53 | interface Register { |
nothing calls this directly
no test coverage detected