Open History to see the last commit
1// src/routes/__root.tsx
2import {
3 HeadContent,
4 Outlet,
5 Scripts,
6 createRootRouteWithContext,
7} from '@tanstack/react-router'
8import type { QueryClient } from '@tanstack/react-query'
9import type { ReactNode } from 'react'
10import { TanStackRouterDevtools } from '@tanstack/react-router-devtools'
11export interface Context {
12 queryClient: QueryClient
13}
14β
15export const Route = createRootRouteWithContext<Context>()({
16 head: () => ({
17 links: [{ rel: 'stylesheet' }],
18 meta: [
19 {
20 charSet: 'utf-8',
21 },
22 {
23 name: 'viewport',
24 content: 'width=device-width, initial-scale=1',
25 },
26 {
27 title: 'TanStack Start Starter',
28 },
29 ],
30 }),
31 component: RootComponent,
32})
33β
34function RootComponent() {
35 return (
36 <RootDocument>
37 <Outlet />
38 </RootDocument>
39 )
40}
41β
42function RootDocument({ children }: Readonly<{ children: ReactNode }>) {
43 return (
44 <html>
45 <head>
46 <HeadContent />
47 </head>
48 <body>
49 {children}
50 <TanStackRouterDevtools position="bottom-right" />
51 <Scripts />
52 </body>
53 </html>
54 )
55}