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