Skip to content
Source
Sign inSign up
TanStack/router
Open History to see the last commit

__root.tsx

87 lines2.1 KB

1/// <reference types="vite/client" />
2import {
3 HeadContent,
4 Link,
5 Scripts,
6 createRootRouteWithContext,
7} from '@tanstack/react-router'
8import { ReactQueryDevtools } from '@tanstack/react-query-devtools'
9import { TanStackRouterDevtoolsInProd } from '@tanstack/react-router-devtools'
10import * as React from 'react'
11import type { QueryClient } from '@tanstack/react-query'
12import appCss from '~/styles/app.css?url'
13​
14export const Route = createRootRouteWithContext<{
15 queryClient: QueryClient
16}>()({
17 head: () => ({
18 meta: [
19 {
20 charSet: 'utf-8',
21 },
22 ],
23 links: [{ rel: 'stylesheet', href: appCss }],
24 }),
25 shellComponent: RootDocument,
26})
27​
28function RootDocument({ children }: { children: React.ReactNode }) {
29 return (
30 <html>
31 <head>
32 <HeadContent />
33 </head>
34 <body>
35 <div className="p-2 flex gap-2 text-lg">
36 <Link
37 to="/"
38 activeProps={{
39 className: 'font-bold',
40 }}
41 >
42 Home
43 </Link>{' '}
44 <Link
45 to="/loader-fetchQuery/$type"
46 params={{ type: 'sync' }}
47 activeProps={{
48 className: 'font-bold',
49 }}
50 >
51 fetchQuery (sync)
52 </Link>{' '}
53 <Link
54 to="/loader-fetchQuery/$type"
55 params={{ type: 'async' }}
56 activeProps={{
57 className: 'font-bold',
58 }}
59 >
60 fetchQuery (async)
61 </Link>{' '}
62 <Link
63 to="/useQuery"
64 activeProps={{
65 className: 'font-bold',
66 }}
67 >
68 useQuery
69 </Link>{' '}
70 <Link
71 to="/useSuspenseQuery"
72 activeProps={{
73 className: 'font-bold',
74 }}
75 >
76 useSuspenseQuery
77 </Link>{' '}
78 </div>
79 <hr />
80 {children}
81 <TanStackRouterDevtoolsInProd position="bottom-right" />
82 <ReactQueryDevtools buttonPosition="bottom-left" />
83 <Scripts />
84 </body>
85 </html>
86 )