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

__root.tsx

85 lines1.8 KB

1import {
2 HeadContent,
3 Link,
4 Outlet,
5 createRootRoute,
6} from '@tanstack/solid-router'
7import { TanStackRouterDevtools } from '@tanstack/solid-router-devtools'
8​
9export const Route = createRootRoute({
10 component: RootComponent,
11 notFoundComponent: () => {
12 return (
13 <div>
14 <p>This is the notFoundComponent configured on root route</p>
15 <Link to="/">Start Over</Link>
16 </div>
17 )
18 },
19})
20​
21function RootComponent() {
22 return (
23 <>
24 <HeadContent />
25 <div class="p-2 flex gap-2 text-lg border-b">
26 <Link
27 to="/"
28 activeProps={{
29 class: 'font-bold',
30 }}
31 activeOptions={{ exact: true }}
32 >
33 Home
34 </Link>{' '}
35 <Link
36 to="/posts"
37 activeProps={{
38 class: 'font-bold',
39 }}
40 >
41 Posts
42 </Link>{' '}
43 <Link
44 to="/layout-a"
45 activeProps={{
46 class: 'font-bold',
47 }}
48 >
49 Layout
50 </Link>{' '}
51 <Link
52 to="/without-loader"
53 activeProps={{
54 class: 'font-bold',
55 }}
56 >
57 without-loader
58 </Link>{' '}
59 <Link
60 // @ts-expect-error
61 to="/this-route-does-not-exist"
62 activeProps={{
63 class: 'font-bold',
64 }}
65 >
66 This Route Does Not Exist
67 </Link>
68 </div>
69 <hr />
70 <div style={{ height: '200vh' }} />
71 <Link
72 preload="viewport"
73 to="/viewport-test"
74 activeProps={{
75 class: 'font-bold',
76 }}
77 >
78 viewport-test
79 </Link>
80 <Outlet />
81 {/* Start rendering router matches */}
82 <TanStackRouterDevtools position="bottom-right" />
83 </>
84 )