Open History to see the last commit
1import { HeadContent, Scripts, createRootRoute } from '@tanstack/react-router'
2import { TanStackRouterDevtoolsPanel } from '@tanstack/react-router-devtools'
3import { TanStackDevtools } from '@tanstack/react-devtools'
4import { PostHogProvider } from '@posthog/react'
5
6import { PostHogIdentity } from '#/components/posthog-identity.tsx'
7import appCss from '../styles.css?url'
8
9const posthogToken = import.meta.env.VITE_PUBLIC_POSTHOG_PROJECT_TOKEN
10const posthogHost = import.meta.env.VITE_PUBLIC_POSTHOG_HOST
11
12export const Route = createRootRoute({
13 head: () => ({
14 meta: [
15 {
16 charSet: 'utf-8',
17 },
18 {
19 name: 'viewport',
20 content: 'width=device-width, initial-scale=1',
21 },
22 {
23 title: 'modelschemas — live AI model schemas',
24 },
25 {
26 name: 'description',
27 content:
28 'Which AI models exist right now, and what do their payloads look like? Live request/response JSON Schemas and model metadata across OpenAI, Anthropic, Gemini, Grok, ElevenLabs, OpenRouter, FAL and BytePlus — built for agents.',
29 },
30 ],
31 links: [
32 {
33 rel: 'stylesheet',
34 href: appCss,
35 },
36 {
37 rel: 'icon',
38 type: 'image/svg+xml',
39 href: '/icon.svg',
40 },
41 ],
42 }),
43 shellComponent: RootDocument,
44})
45
46function RootDocument({ children }: { children: React.ReactNode }) {
47 if ((!posthogToken || !posthogHost) && import.meta.env.DEV) {
48 const missing = !posthogToken
49 ? 'VITE_PUBLIC_POSTHOG_PROJECT_TOKEN'
50 : 'VITE_PUBLIC_POSTHOG_HOST'
51 throw new Error(
52 `${missing} variable required by PostHog is missing or un-configured, this causes events to be silently missed. This error stops appearing once ${missing} is configured`,
53 )
54 }
55
56 const content = (
57 <>
58 {children}
59 <TanStackDevtools
60 config={{
61 position: 'bottom-right',
62 }}
63 plugins={[
64 {
65 name: 'Tanstack Router',
66 render: <TanStackRouterDevtoolsPanel />,
67 },
68 ]}
69 />
70 </>
71 )
72
73 return (
74 <html lang="en">
75 <head>
76 <HeadContent />
77 </head>
78 <body>
79 {posthogToken && posthogHost ? (
80 <PostHogProvider
81 apiKey={posthogToken}
82 options={{
83 api_host: posthogHost,
84 ui_host: posthogHost,
85 defaults: '2025-05-24',
86 capture_exceptions: true,
87 debug: import.meta.env.DEV,
88 logs: {
89 environment: import.meta.env.MODE,
90 serviceName: 'modelschemas-web',
91 },
92 tracing_headers:
93 typeof window !== 'undefined' ? [window.location.hostname] : [],
94 }}
95 >
96 <PostHogIdentity />
97 {content}
98 </PostHogProvider>
99 ) : (
100 content
101 )}
102 <Scripts />
103 </body>
104 </html>
105 )
106}