Something went wrong. Try again.
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109import { HeadContent, Outlet, Scripts, createRootRouteWithContext } from "@tanstack/react-router";import { TanStackDevtools } from "@tanstack/react-devtools";import { ReactQueryDevtoolsPanel } from "@tanstack/react-query-devtools";import { TanStackRouterDevtoolsPanel } from "@tanstack/react-router-devtools";import type { QueryClient } from "@tanstack/react-query";
import { Header } from "~/chapters/header";
import appCss from "~/design-system/styles/global.css?url";
interface MyRouterContext { queryClient: QueryClient;}
const themeHydrationScript = ` (function() { try { var theme = localStorage.getItem('theme'); if (theme === 'dark' || (!theme && window.matchMedia('(prefers-color-scheme: dark)').matches)) { document.documentElement.setAttribute('data-theme', 'dark'); } else if (theme === 'light') { document.documentElement.setAttribute('data-theme', 'light'); } } catch (e) {} })();`;
export const Route = createRootRouteWithContext<MyRouterContext>()({ head: () => ({ meta: [ { charSet: "utf-8", }, { name: "viewport", content: "width=device-width, initial-scale=1", }, { title: "Prefetching Patterns", }, { name: "description", content: "A developer console for exploring data prefetching techniques in modern React applications with TanStack Router and Query.", }, ], links: [ { rel: "icon", href: "/favicon.ico" }, { rel: "stylesheet", href: appCss }, { rel: "preconnect", href: "https://fonts.googleapis.com" }, { rel: "preconnect", href: "https://fonts.gstatic.com", crossOrigin: "anonymous" }, { rel: "stylesheet", href: "https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600;700&display=swap", }, { rel: "stylesheet", href: "https://fonts.googleapis.com/css2?family=Barlow:wght@400;600;700&display=swap", }, ], }), component: RootComponent,});
function RootComponent() { return ( <RootDocument> <Outlet /> </RootDocument> );}
function RootDocument(props: Readonly<{ children: React.ReactNode }>) { return ( <html lang="en" suppressHydrationWarning> <head> <script dangerouslySetInnerHTML={{ __html: themeHydrationScript }} /> <HeadContent /> </head> <body> <a href="#main-content" className="sr-only focus:not-sr-only focus:absolute focus:top-2 focus:left-2 focus:z-50 focus:px-4 focus:py-2 focus:bg-(--bg-card) focus:border focus:border-(--accent-default) focus:text-(--text-primary) focus:font-mono focus:text-sm" > Skip to main content </a> <Header /> {props.children}
<TanStackDevtools plugins={[ { name: "TanStack Router", render: <TanStackRouterDevtoolsPanel />, defaultOpen: true, }, { name: "TanStack Query", render: <ReactQueryDevtoolsPanel />, defaultOpen: true, }, ]} /> <Scripts /> </body> </html> );}