import { QueryClient } from "@tanstack/react-query";
import { createRouter } from "@tanstack/react-router";
import { setupRouterSsrQueryIntegration } from "@tanstack/react-router-ssr-query";
import { routeTree } from "./routeTree.gen";
import { DefaultCatchBoundary } from "./components/DefaultCatchBoundary";
import { NotFound } from "./components/NotFound";
const QUERY_STALE_MS = 30 * 1000;
const QUERY_GC_MS = 10 * 60 * 1000;
export function getRouter() {
const queryClient = new QueryClient({
defaultOptions: {
queries: { staleTime: QUERY_STALE_MS, gcTime: QUERY_GC_MS, retry: 1, refetchOnWindowFocus: false },
},
});
const router = createRouter({
routeTree,
context: { queryClient },
defaultPreload: "intent",
defaultErrorComponent: DefaultCatchBoundary,
defaultNotFoundComponent: () => <NotFound />,
scrollRestoration: true,
});
setupRouterSsrQueryIntegration({ router, queryClient });
return router;
}