mirror of
https://github.com/linsa-io/linsa.git
synced 2026-01-12 12:20:23 +01:00
29 lines
877 B
TypeScript
29 lines
877 B
TypeScript
import { createRouter as createTanStackRouter } from "@tanstack/react-router"
|
|
import { routeTree } from "./routeTree.gen"
|
|
import { DefaultCatchBoundary } from "./components/DefaultCatchBoundary"
|
|
import { NotFound } from "./components/NotFound"
|
|
import { QueryClient } from "@tanstack/react-query"
|
|
import { routerWithQueryClient } from "@tanstack/react-router-with-query"
|
|
|
|
export function createRouter() {
|
|
const queryClient = new QueryClient()
|
|
const router = routerWithQueryClient(
|
|
createTanStackRouter({
|
|
routeTree,
|
|
defaultPreload: "intent",
|
|
defaultErrorComponent: DefaultCatchBoundary,
|
|
defaultNotFoundComponent: () => <NotFound />,
|
|
context: { queryClient, auth: undefined! },
|
|
}),
|
|
queryClient,
|
|
)
|
|
|
|
return router
|
|
}
|
|
|
|
declare module "@tanstack/react-router" {
|
|
interface Register {
|
|
router: ReturnType<typeof createRouter>
|
|
}
|
|
}
|