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

__root.tsx

46 lines926 Bytes

1/// <reference types="vite/client" />
2import * as React from 'react'
3import { TanStackRouterDevtools } from '@tanstack/react-router-devtools'
4import {
5 HeadContent,
6 Link,
7 Outlet,
8 Scripts,
9 createRootRoute,
10} from '@tanstack/react-router'
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>
36 <Link to="/">Index</Link>
37 <Link to="/about">About</Link>
38 </div>
39​
40 {children}
41 <TanStackRouterDevtools position="bottom-right" />
42 <Scripts />
43 </body>
44 </html>
45 )