Open History to see the last commit
1import { HeadContent, Scripts, createRootRoute } from '@tanstack/solid-router'
2// Devtools are dynamically imported on the client to avoid server-side bundling
3import { onMount, createSignal } from 'solid-js'
4// import { aiDevtoolsPlugin } from "@tanstack/react-ai-devtools";
5import { HydrationScript } from 'solid-js/web'
6import appCss from '../styles.css?url'
7import Header from '../components/Header'
8import type { JSXElement } from 'solid-js'
9
10export const Route = createRootRoute({
11 head: () => ({
12 meta: [
13 {
14 charSet: 'utf-8',
15 },
16 {
17 name: 'viewport',
18 content: 'width=device-width, initial-scale=1',
19 },
20 {
21 title: 'TanStack Start Starter',
22 },
23 ],
24 links: [
25 {
26 rel: 'stylesheet',
27 href: appCss,
28 },
29 {
30 rel: 'icon',
31 type: 'image/svg+xml',
32 href: 'https://tanstack.com/favicon-light.svg',
33 media: '(prefers-color-scheme: light)',
34 },
35 {
36 rel: 'icon',
37 type: 'image/svg+xml',
38 href: 'https://tanstack.com/favicon-dark.svg',
39 media: '(prefers-color-scheme: dark)',
40 },
41 ],
42 }),
43
44 shellComponent: RootDocument,
45})
46
47function RootDocument({ children }: { children: JSXElement }) {
48 const [Devtools, setDevtools] = createSignal<JSXElement | null>(null)
49
50 onMount(async () => {
51 try {
52 const [{ TanStackDevtools }, { TanStackRouterDevtoolsPanel }] =
53 await Promise.all([
54 import('@tanstack/solid-devtools'),
55 import('@tanstack/solid-router-devtools'),
56 ])
57
58 setDevtools(
59 <TanStackDevtools
60 config={{
61 position: 'bottom-right',
62 }}
63 plugins={[
64 {
65 name: 'Tanstack Router',
66 render: <TanStackRouterDevtoolsPanel />,
67 },
68 // aiDevtoolsPlugin(),
69 ]}
70 eventBusConfig={{
71 connectToServerBus: true,
72 }}
73 />,
74 )
75 } catch (e) {
76 // If devtools fail to load on the client, ignore silently
77 // This prevents build/SSR from failing due to dev-only exports
78 // eslint-disable-next-line no-console
79 console.warn('Failed to load devtools on client', e)
80 }
81 })
82
83 return (
84 <html lang="en">
85 <head>
86 <HydrationScript />
87 </head>
88 <body>
89 <HeadContent />
90 <Header />
91 {children}
92 {Devtools()}
93 <Scripts />
94 </body>
95 </html>
96 )
97}