@@ -27,6 +27,99 @@ function RootComponent() {
2727 < / >
2828 )
2929}
30+ < % } else if (! includeExamples) { % >
31+ < % let hasContext = addOnEnabled[" apollo-client" ] || addOnEnabled[" tanstack-query" ]; % >
32+ import {
33+ HeadContent , Scripts , <% if (hasContext ) { %>createRootRouteWithContext <% } else { %>createRootRoute <% } %> } from ' @tanstack/react-router'
34+ import { TanStackRouterDevtoolsPanel } from ' @tanstack/react-router-devtools' ;
35+ import { TanStackDevtools } from ' @tanstack/react-devtools'
36+ < % for (const integration of integrations .filter (i => i .type === ' layout' || i .type === ' provider' || i .type === ' devtools' )) { % >
37+ import <%= integration .jsName %> from ' <%= relativePath(integration.path, true) %>'
38+ < % } % >< % if (addOnEnabled .paraglide ) { % >
39+ import { getLocale } from ' #/paraglide/runtime'
40+ < % } % >
41+ import appCss from ' ../styles.css?url'
42+ < % if (addOnEnabled[" apollo-client" ]) { % >
43+ import type { ApolloClientIntegration } from " @apollo/client-integration-tanstack-start" ;
44+ < % } % >
45+ < % if (addOnEnabled[" tanstack-query" ]) { % >
46+ import type { QueryClient } from ' @tanstack/react-query'
47+ < % if (addOnEnabled .tRPC ) { % >
48+ import type { TRPCRouter } from ' #/integrations/trpc/router'
49+ import type { TRPCOptionsProxy } from ' @trpc/tanstack-react-query'
50+ < % } % >
51+ < % } % >
52+ < % if (hasContext) { % >
53+ interface MyRouterContext < % if (addOnEnabled[" apollo-client" ]) {% > extends ApolloClientIntegration .RouterContext < % } % > {
54+ < % if (addOnEnabled[" tanstack-query" ]) { % >
55+ queryClient: QueryClient
56+ < % if (addOnEnabled .tRPC ) { % >
57+ trpc: TRPCOptionsProxy< TRPCRouter>
58+ < % } % >
59+ < % } % >
60+ }< % } % >
61+
62+ export const Route = < % if (hasContext) { % > createRootRouteWithContext< MyRouterContext> ()< % } else { % > createRootRoute< % } % > ({
63+ < % if (addOnEnabled .paraglide ) { % >
64+ beforeLoad: async () => {
65+ // Other redirect strategies are possible; see
66+ // https://github.com/TanStack/router/tree/main/examples/react/i18n-paraglide#offline-redirect
67+ if (typeof document !== ' undefined' ) {
68+ document .documentElement .setAttribute (' lang' , getLocale ())
69+ }
70+ },
71+ < % } % >
72+ head : () => ({
73+ meta: [
74+ {
75+ charSet: ' utf-8' ,
76+ },
77+ {
78+ name: ' viewport' ,
79+ content: ' width=device-width, initial-scale=1' ,
80+ },
81+ {
82+ title: ' TanStack Start Starter' ,
83+ },
84+ ],
85+ links: [
86+ {
87+ rel: ' stylesheet' ,
88+ href: appCss,
89+ },
90+ ],
91+ }),
92+ shellComponent: RootDocument
93+ })
94+
95+ function RootDocument ({ children }: { children: React .ReactNode }) {
96+ return (
97+ < % if (addOnEnabled .paraglide ) { % >< html lang= {getLocale ()}>< % } else { % >< html lang= " en" >< % } % >
98+ < head>
99+ < HeadContent / >
100+ < / head>
101+ < body>
102+ < % for (const integration of integrations .filter (i => i .type === ' provider' )) { % > << %= integration .jsName % >>
103+ < % } % > {children}
104+ < TanStackDevtools
105+ config= {{
106+ position: ' bottom-right' ,
107+ }}
108+ plugins= {[
109+ {
110+ name: ' Tanstack Router' ,
111+ render: < TanStackRouterDevtoolsPanel / > ,
112+ },
113+ < % for (const integration of integrations .filter (i => i .type === ' devtools' )) { % >< %= integration .jsName % > ,< % } % >
114+ ]}
115+ / >
116+ < % for (const integration of integrations .filter (i => i .type === ' layout' )) { % > << %= integration .jsName % > / >
117+ < % } % >< % for (const integration of integrations .filter (i => i .type === ' provider' ).reverse ()) { % >< / < %= integration .jsName % >>
118+ < % } % >< Scripts / >
119+ < / body>
120+ < / html>
121+ )
122+ }
30123< % } else { % >
31124< % let hasContext = addOnEnabled[" apollo-client" ] || addOnEnabled[" tanstack-query" ]; % >
32125import {
0 commit comments