Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

router.ts

26 lines674 Bytes

1import { createElement } from "react";
2import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
3import { createRouter, RouterHistory } from "@tanstack/react-router";
4​
5import { routeTree } from "./routeTree.gen";
6​
7export function getRouter(history: RouterHistory) {
8 const queryClient = new QueryClient();
9​
10 return createRouter({
11 routeTree,
12 history,
13 context: {
14 queryClient,
15 },
16 Wrap: ({ children }) => createElement(QueryClientProvider, { client: queryClient }, children),
17 });
19​
20export type AppRouter = ReturnType<typeof getRouter>;
21​
22declare module "@tanstack/react-router" {
23 interface Register {
24 router: AppRouter;
25 }