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

root.tsx

69 lines1.5 KB

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