Open History to see the last commit
1import { TanStackRouterDevtools } from '@tanstack/react-router-devtools'
2import * as React from 'react'
3import {
4 HeadContent,
5 Link,
6 Outlet,
7 Scripts,
8 createRootRouteWithContext,
9} from '@tanstack/react-router'
10import type { RouterContext } from '../routerContext'
11β
12export const Route = createRootRouteWithContext<RouterContext>()({
13 head: () => ({
14 links: [{ rel: 'icon', href: '/images/favicon.ico' }],
15 meta: [
16 {
17 title: 'TanStack Router SSR Basic File Based Streaming',
18 },
19 {
20 charSet: 'UTF-8',
21 },
22 {
23 name: 'viewport',
24 content: 'width=device-width, initial-scale=1.0',
25 },
26 ],
27 scripts: [
28 {
29 src: 'https://unpkg.com/@tailwindcss/browser@4',
30 },
31 ...(!import.meta.env.PROD
32 ? [
33 {
34 type: 'module',
35 children: `import RefreshRuntime from "/@react-refresh"
36 RefreshRuntime.injectIntoGlobalHook(window)
37 window.$RefreshReg$ = () => {}
38 window.$RefreshSig$ = () => (type) => type
39 window.__vite_plugin_react_preamble_installed__ = true`,
40 },
41 {
42 type: 'module',
43 src: '/@vite/client',
44 },
45 ]
46 : []),
47 {
48 type: 'module',
49 src: import.meta.env.PROD
50 ? '/static/entry-client.js'
51 : '/src/entry-client.tsx',
52 },
53 ],
54 }),
55 component: RootComponent,
56})
57β
58function RootComponent() {
59 return (
60 <html lang="en">
61 <head>
62 <HeadContent />
63 </head>
64 <body>
65 <div className="p-2 flex gap-2 text-lg">
66 <Link
67 to="/"
68 activeProps={{
69 className: 'font-bold',
70 }}
71 activeOptions={{ exact: true }}
72 >
73 Home
74 </Link>{' '}
75 <Link
76 to="/posts"
77 activeProps={{
78 className: 'font-bold',
79 }}
80 >
81 Posts
82 </Link>{' '}
83 <Link
84 to="/error"
85 activeProps={{
86 className: 'font-bold',
87 }}
88 >
89 Error
90 </Link>
91 </div>
92 <hr />
93 <Outlet /> {/* Start rendering router matches */}
94 <TanStackRouterDevtools position="bottom-right" />
95 <Scripts />
96 </body>
97 </html>
98 )
99}