Open History to see the last commit
1/// <reference types="vite/client" />
2import {
3 HeadContent,
4 Link,
5 Outlet,
6 Scripts,
7 createRootRouteWithContext,
8} from '@tanstack/react-router'
9import { ReactQueryDevtools } from '@tanstack/react-query-devtools'
10import { TanStackRouterDevtools } from '@tanstack/react-router-devtools'
11import * as React from 'react'
12import type { QueryClient } from '@tanstack/react-query'
13import { DefaultCatchBoundary } from '~/components/DefaultCatchBoundary'
14import { NotFound } from '~/components/NotFound'
15import appCss from '~/styles/app.css?url'
16import { seo } from '~/utils/seo'
17β
18export const Route = createRootRouteWithContext<{
19 queryClient: QueryClient
20}>()({
21 head: () => ({
22 meta: [
23 {
24 charSet: 'utf-8',
25 },
26 {
27 name: 'viewport',
28 content: 'width=device-width, initial-scale=1',
29 },
30 ...seo({
31 title:
32 'TanStack Start | Type-Safe, Client-First, Full-Stack React Framework',
33 description: `TanStack Start is a type-safe, client-first, full-stack React framework. `,
34 }),
35 ],
36 links: [
37 { rel: 'stylesheet', href: appCss },
38 {
39 rel: 'apple-touch-icon',
40 sizes: '180x180',
41 href: '/apple-touch-icon.png',
42 },
43 {
44 rel: 'icon',
45 type: 'image/png',
46 sizes: '32x32',
47 href: '/favicon-32x32.png',
48 },
49 {
50 rel: 'icon',
51 type: 'image/png',
52 sizes: '16x16',
53 href: '/favicon-16x16.png',
54 },
55 { rel: 'manifest', href: '/site.webmanifest', color: '#fffff' },
56 { rel: 'icon', href: '/favicon.ico' },
57 ],
58 }),
59 errorComponent: (props) => {
60 return (
61 <RootDocument>
62 <DefaultCatchBoundary {...props} />
63 </RootDocument>
64 )
65 },
66 notFoundComponent: () => <NotFound />,
67 component: RootComponent,
68})
69β
70function RootComponent() {
71 return (
72 <RootDocument>
73 <Outlet />
74 </RootDocument>
75 )
76}
77β
78function RootDocument({ children }: { children: React.ReactNode }) {
79 return (
80 <html>
81 <head>
82 <HeadContent />
83 </head>
84 <body>
85 <div className="p-2 flex gap-2 text-lg">
86 <Link
87 to="/"
88 activeProps={{
89 className: 'font-bold',
90 }}
91 activeOptions={{ exact: true }}
92 >
93 Home
94 </Link>{' '}
95 <Link
96 to="/posts"
97 activeProps={{
98 className: 'font-bold',
99 }}
100 >
101 Posts
102 </Link>{' '}
103 <Link
104 to="/users"
105 activeProps={{
106 className: 'font-bold',
107 }}
108 >
109 Users
110 </Link>{' '}
111 <Link
112 to="/route-a"
113 activeProps={{
114 className: 'font-bold',
115 }}
116 >
117 Pathless Layout
118 </Link>{' '}
119 <Link
120 to="/deferred"
121 activeProps={{
122 className: 'font-bold',
123 }}
124 >
125 Deferred
126 </Link>{' '}
127 <Link
128 // @ts-expect-error
129 to="/this-route-does-not-exist"
130 activeProps={{
131 className: 'font-bold',
132 }}
133 >
134 This Route Does Not Exist
135 </Link>
136 </div>
137 <hr />
138 {children}
139 <TanStackRouterDevtools position="bottom-right" />
140 <ReactQueryDevtools buttonPosition="bottom-left" />
141 <Scripts />
142 </body>
143 </html>
144 )
145}