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

__root.tsx

67 lines1.4 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="/route-a"
45 activeProps={{
46 class: 'font-bold',
47 }}
48 >
49 Pathless Layout
50 </Link>{' '}
51 <Link
52 // @ts-expect-error
53 to="/this-route-does-not-exist"
54 activeProps={{
55 class: 'font-bold',
56 }}
57 >
58 This Route Does Not Exist
59 </Link>
60 </div>
61 <hr />
62 <Outlet />
63 {/* Start rendering router matches */}
64 <TanStackRouterDevtools position="bottom-right" />
65 </>
66 )