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

__root.tsx

114 lines2.6 KB

1import {
2 HeadContent,
3 Link,
4 Outlet,
5 Scripts,
6 createRootRoute,
7} from '@tanstack/solid-router'
8​
9import { TanStackRouterDevtoolsInProd } from '@tanstack/solid-router-devtools'
10import { HydrationScript } from 'solid-js/web'
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 name: 'viewport',
20 content: 'width=device-width, initial-scale=1',
21 },
22 ...seo({
23 title:
24 'TanStack Start | Type-Safe, Client-First, Full-Stack React Framework',
25 description: `TanStack Start is a type-safe, client-first, full-stack React framework. `,
26 }),
27 ],
28 links: [
29 { rel: 'stylesheet', href: appCss },
30 {
31 rel: 'apple-touch-icon',
32 sizes: '180x180',
33 href: '/apple-touch-icon.png',
34 },
35 {
36 rel: 'icon',
37 type: 'image/png',
38 sizes: '32x32',
39 href: '/favicon-32x32.png',
40 },
41 {
42 rel: 'icon',
43 type: 'image/png',
44 sizes: '16x16',
45 href: '/favicon-16x16.png',
46 },
47 { rel: 'manifest', href: '/site.webmanifest', color: '#fffff' },
48 { rel: 'icon', href: '/favicon.ico' },
49 ],
50 }),
51 errorComponent: (props) => <p>{props.error.stack}</p>,
52 notFoundComponent: () => <NotFound />,
53 component: RootComponent,
54})
55​
56function RootComponent() {
57 return (
58 <html>
59 <head>
60 <HydrationScript />
61 </head>
62 <body>
63 <HeadContent />
64 <div class="p-2 flex gap-2 text-lg">
65 <Link
66 to="/"
67 activeProps={{
68 class: 'font-bold',
69 }}
70 activeOptions={{ exact: true }}
71 >
72 Home
73 </Link>{' '}
74 <Link
75 to="/posts"
76 activeProps={{
77 class: 'font-bold',
78 }}
79 >
80 Posts
81 </Link>{' '}
82 <Link
83 to="/users"
84 activeProps={{
85 class: 'font-bold',
86 }}
87 >
88 Users
89 </Link>{' '}
90 <Link
91 to="/deferred"
92 activeProps={{
93 class: 'font-bold',
94 }}
95 >
96 Deferred
97 </Link>{' '}
98 <Link
99 // @ts-expect-error
100 to="/this-route-does-not-exist"
101 activeProps={{
102 class: 'font-bold',
103 }}
104 >
105 This Route Does Not Exist
106 </Link>
107 </div>
108 <Outlet />
109 <TanStackRouterDevtoolsInProd />
110 <Scripts />
111 </body>
112 </html>
113 )