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

__root.tsx

41 lines918 Bytes

1import * as React from 'react'
2import {
3 Link,
4 Outlet,
5 createRootRouteWithContext,
6} from '@tanstack/react-router'
7import { type QueryClient } from '@tanstack/react-query'
8import { TanStackRouterDevtools } from '@tanstack/react-router-devtools'
9​
10export interface Context {
11 queryClient: QueryClient
13​
14export const Route = createRootRouteWithContext<Context>()({
15 component: RootComponent,
16 notFoundComponent: () => {
17 return <p>Not Found (on root route)</p>
18 },
19})
20​
21function RootComponent() {
22 return (
23 <>
24 <div className="p-2 flex gap-2 text-lg">
25 <Link
26 to="/"
27 activeProps={{
28 className: 'font-bold',
29 }}
30 activeOptions={{ exact: true }}
31 >
32 Home
33 </Link>
34 </div>
35 <hr />
36 <Outlet />
37 {/* Start rendering router matches */}
38 <TanStackRouterDevtools position="bottom-right" />
39 </>
40 )