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

__root.tsx

47 lines1.1 KB

1import * as React from 'react'
2import { Link, Outlet, createRootRoute } from '@tanstack/react-router'
3import { TanStackRouterDevtools } from '@tanstack/react-router-devtools'
4​
5export const Route = createRootRoute({
6 component: RootComponent,
7 notFoundComponent: () => {
8 return (
9 <div>
10 <p>This is the notFoundComponent configured on root route</p>
11 <Link to="/">Start Over</Link>
12 </div>
13 )
14 },
15})
16​
17function RootComponent() {
18 return (
19 <>
20 <div className="p-2 flex gap-2 text-lg border-b">
21 <Link
22 to="/"
23 activeProps={{
24 className: 'font-bold',
25 }}
26 activeOptions={{ exact: true }}
27 viewTransition
28 >
29 Home
30 </Link>{' '}
31 <Link
32 to="/posts"
33 activeProps={{
34 className: 'font-bold',
35 }}
36 viewTransition
37 >
38 Posts
39 </Link>{' '}
40 </div>
41 <hr />
42 <Outlet />
43 {/* Start rendering router matches */}
44 <TanStackRouterDevtools position="bottom-right" />
45 </>
46 )