Init
This commit is contained in:
28
src/router.tsx
Normal file
28
src/router.tsx
Normal file
@@ -0,0 +1,28 @@
|
||||
import { createRouter } from '@tanstack/react-router'
|
||||
import { setupRouterSsrQueryIntegration } from '@tanstack/react-router-ssr-query'
|
||||
import * as TanstackQuery from './integrations/tanstack-query/root-provider'
|
||||
|
||||
// Import the generated route tree
|
||||
import { routeTree } from './routeTree.gen'
|
||||
|
||||
// Create a new router instance
|
||||
export const getRouter = () => {
|
||||
const rqContext = TanstackQuery.getContext()
|
||||
|
||||
const router = createRouter({
|
||||
routeTree,
|
||||
context: { ...rqContext },
|
||||
defaultPreload: 'intent',
|
||||
Wrap: (props: { children: React.ReactNode }) => {
|
||||
return (
|
||||
<TanstackQuery.Provider {...rqContext}>
|
||||
{props.children}
|
||||
</TanstackQuery.Provider>
|
||||
)
|
||||
},
|
||||
})
|
||||
|
||||
setupRouterSsrQueryIntegration({ router, queryClient: rqContext.queryClient })
|
||||
|
||||
return router
|
||||
}
|
||||
Reference in New Issue
Block a user