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