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

__root.tsx

53 lines1.1 KB

1/// <reference types="vite/client" />
2import {
3 HeadContent,
4 Link,
5 Outlet,
6 Scripts,
7 createRootRoute,
8} from '@tanstack/react-router'
9import { TanStackRouterDevtools } from '@tanstack/react-router-devtools'
10import * as React from 'react'
11import appCss from '~/styles/app.css?url'
12​
13export const Route = createRootRoute({
14 head: () => ({
15 links: [{ rel: 'stylesheet', href: appCss }],
16 }),
17 component: RootComponent,
18})
19​
20function RootComponent() {
21 return (
22 <RootDocument>
23 <Outlet />
24 </RootDocument>
25 )
27​
28function RootDocument({ children }: { children: React.ReactNode }) {
29 return (
30 <html>
31 <head>
32 <HeadContent />
33 </head>
34 <body>
35 <div className="p-2 flex gap-2 text-lg">
36 <Link
37 to="/"
38 activeProps={{
39 className: 'font-bold',
40 }}
41 activeOptions={{ exact: true }}
42 >
43 Home
44 </Link>
45 </div>
46 <hr />
47 {children}
48 <TanStackRouterDevtools position="bottom-right" />
49 <Scripts />
50 </body>
51 </html>
52 )