1import { createRouter, RouterHistory } from "@tanstack/react-router";
2
3import { routeTree } from "./routeTree.gen";
4import { isSidebarUtilityPage } from "./components/sidebar/mainAppLocation";
5
6export function getRouter(history: RouterHistory) {
7 return createRouter({
8 routeTree,
9 history,
10 context: {},
11 scrollRestoration: ({ location }) => isSidebarUtilityPage(location.pathname),
12 // Route components are split chunks (autoCodeSplitting in vite.config);
13 // fetching them on hover/focus intent hides the load from the first
14 // settings or pull-request navigation.
15 defaultPreload: "intent",
16 });
17}
18
19export type AppRouter = ReturnType<typeof getRouter>;
20
21declare module "@tanstack/react-router" {
22 interface Register {
23 router: AppRouter;
24 }
25}