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