diff --git a/e2e/react-start/basic-auth/src/routeTree.gen.ts b/e2e/react-start/basic-auth/src/routeTree.gen.ts index 19a8180edba..9e96fafa6af 100644 --- a/e2e/react-start/basic-auth/src/routeTree.gen.ts +++ b/e2e/react-start/basic-auth/src/routeTree.gen.ts @@ -219,6 +219,7 @@ import type { getRouter } from './router.tsx' import type { createStart } from '@tanstack/react-start' declare module '@tanstack/react-start' { interface Register { + ssr: true router: Awaited> } } diff --git a/e2e/react-start/basic-react-query/src/routeTree.gen.ts b/e2e/react-start/basic-react-query/src/routeTree.gen.ts index 68f522b0699..b0de841f01b 100644 --- a/e2e/react-start/basic-react-query/src/routeTree.gen.ts +++ b/e2e/react-start/basic-react-query/src/routeTree.gen.ts @@ -412,6 +412,7 @@ import type { getRouter } from './router.tsx' import type { createStart } from '@tanstack/react-start' declare module '@tanstack/react-start' { interface Register { + ssr: true router: Awaited> } } diff --git a/e2e/react-start/basic-tsr-config/src/routeTree.gen.ts b/e2e/react-start/basic-tsr-config/src/routeTree.gen.ts index d9eff184704..dceedffdc12 100644 --- a/e2e/react-start/basic-tsr-config/src/routeTree.gen.ts +++ b/e2e/react-start/basic-tsr-config/src/routeTree.gen.ts @@ -62,6 +62,7 @@ import type { getRouter } from './router.tsx' import type { createStart } from '@tanstack/react-start' declare module '@tanstack/react-start' { interface Register { + ssr: true router: Awaited> } } diff --git a/e2e/react-start/basic/src/routeTree.gen.ts b/e2e/react-start/basic/src/routeTree.gen.ts index c9a9b131a57..a88d7953940 100644 --- a/e2e/react-start/basic/src/routeTree.gen.ts +++ b/e2e/react-start/basic/src/routeTree.gen.ts @@ -1589,6 +1589,7 @@ import type { getRouter } from './router.tsx' import type { createStart } from '@tanstack/react-start' declare module '@tanstack/react-start' { interface Register { + ssr: true router: Awaited> } } diff --git a/e2e/react-start/custom-basepath/src/routeTree.gen.ts b/e2e/react-start/custom-basepath/src/routeTree.gen.ts index 0f66010092f..8113afd16dc 100644 --- a/e2e/react-start/custom-basepath/src/routeTree.gen.ts +++ b/e2e/react-start/custom-basepath/src/routeTree.gen.ts @@ -319,6 +319,7 @@ import type { getRouter } from './router.tsx' import type { createStart } from '@tanstack/react-start' declare module '@tanstack/react-start' { interface Register { + ssr: true router: Awaited> } } diff --git a/e2e/react-start/query-integration/src/routeTree.gen.ts b/e2e/react-start/query-integration/src/routeTree.gen.ts index 434f4b1298d..22c6f3293d1 100644 --- a/e2e/react-start/query-integration/src/routeTree.gen.ts +++ b/e2e/react-start/query-integration/src/routeTree.gen.ts @@ -125,6 +125,7 @@ import type { getRouter } from './router.tsx' import type { createStart } from '@tanstack/react-start' declare module '@tanstack/react-start' { interface Register { + ssr: true router: Awaited> } } diff --git a/e2e/react-start/scroll-restoration/src/routeTree.gen.ts b/e2e/react-start/scroll-restoration/src/routeTree.gen.ts index 669a919a5af..5f7f3095403 100644 --- a/e2e/react-start/scroll-restoration/src/routeTree.gen.ts +++ b/e2e/react-start/scroll-restoration/src/routeTree.gen.ts @@ -121,6 +121,7 @@ import type { getRouter } from './router.tsx' import type { createStart } from '@tanstack/react-start' declare module '@tanstack/react-start' { interface Register { + ssr: true router: Awaited> } } diff --git a/e2e/react-start/selective-ssr/src/routeTree.gen.ts b/e2e/react-start/selective-ssr/src/routeTree.gen.ts index b2073da8ce1..188cd5c91aa 100644 --- a/e2e/react-start/selective-ssr/src/routeTree.gen.ts +++ b/e2e/react-start/selective-ssr/src/routeTree.gen.ts @@ -106,6 +106,7 @@ import type { getRouter } from './router.tsx' import type { createStart } from '@tanstack/react-start' declare module '@tanstack/react-start' { interface Register { + ssr: true router: Awaited> } } diff --git a/e2e/react-start/serialization-adapters/src/routeTree.gen.ts b/e2e/react-start/serialization-adapters/src/routeTree.gen.ts index b48f3713bd5..b5af1618a37 100644 --- a/e2e/react-start/serialization-adapters/src/routeTree.gen.ts +++ b/e2e/react-start/serialization-adapters/src/routeTree.gen.ts @@ -126,6 +126,7 @@ import type { getRouter } from './router.tsx' import type { startInstance } from './start.tsx' declare module '@tanstack/react-start' { interface Register { + ssr: true router: Awaited> config: Awaited> } diff --git a/e2e/react-start/server-functions/src/routeTree.gen.ts b/e2e/react-start/server-functions/src/routeTree.gen.ts index f788702ef1c..6909bce9452 100644 --- a/e2e/react-start/server-functions/src/routeTree.gen.ts +++ b/e2e/react-start/server-functions/src/routeTree.gen.ts @@ -488,6 +488,7 @@ import type { getRouter } from './router.tsx' import type { createStart } from '@tanstack/react-start' declare module '@tanstack/react-start' { interface Register { + ssr: true router: Awaited> } } diff --git a/e2e/react-start/server-routes/src/routeTree.gen.ts b/e2e/react-start/server-routes/src/routeTree.gen.ts index c1f0cedfd3c..5813a7715f3 100644 --- a/e2e/react-start/server-routes/src/routeTree.gen.ts +++ b/e2e/react-start/server-routes/src/routeTree.gen.ts @@ -106,6 +106,7 @@ import type { getRouter } from './router.tsx' import type { createStart } from '@tanstack/react-start' declare module '@tanstack/react-start' { interface Register { + ssr: true router: Awaited> } } diff --git a/e2e/react-start/spa-mode/src/routeTree.gen.ts b/e2e/react-start/spa-mode/src/routeTree.gen.ts index b2073da8ce1..188cd5c91aa 100644 --- a/e2e/react-start/spa-mode/src/routeTree.gen.ts +++ b/e2e/react-start/spa-mode/src/routeTree.gen.ts @@ -106,6 +106,7 @@ import type { getRouter } from './router.tsx' import type { createStart } from '@tanstack/react-start' declare module '@tanstack/react-start' { interface Register { + ssr: true router: Awaited> } } diff --git a/e2e/react-start/virtual-routes/src/routeTree.gen.ts b/e2e/react-start/virtual-routes/src/routeTree.gen.ts index 2c45b5cecdc..540b02d9481 100644 --- a/e2e/react-start/virtual-routes/src/routeTree.gen.ts +++ b/e2e/react-start/virtual-routes/src/routeTree.gen.ts @@ -320,6 +320,7 @@ import type { getRouter } from './router.tsx' import type { createStart } from '@tanstack/react-start' declare module '@tanstack/react-start' { interface Register { + ssr: true router: Awaited> } } diff --git a/e2e/react-start/website/src/routeTree.gen.ts b/e2e/react-start/website/src/routeTree.gen.ts index d8a3e0cd08d..33b0aa6c4b3 100644 --- a/e2e/react-start/website/src/routeTree.gen.ts +++ b/e2e/react-start/website/src/routeTree.gen.ts @@ -307,6 +307,7 @@ import type { getRouter } from './router.tsx' import type { createStart } from '@tanstack/react-start' declare module '@tanstack/react-start' { interface Register { + ssr: true router: Awaited> } } diff --git a/e2e/solid-start/basic-tsr-config/src/app/routeTree.gen.ts b/e2e/solid-start/basic-tsr-config/src/app/routeTree.gen.ts index 9d968f66df2..4776246e1fc 100644 --- a/e2e/solid-start/basic-tsr-config/src/app/routeTree.gen.ts +++ b/e2e/solid-start/basic-tsr-config/src/app/routeTree.gen.ts @@ -62,6 +62,7 @@ import type { getRouter } from './router.tsx' import type { createStart } from '@tanstack/solid-start' declare module '@tanstack/solid-start' { interface Register { + ssr: true router: Awaited> } } diff --git a/e2e/solid-start/basic/src/routeTree.gen.ts b/e2e/solid-start/basic/src/routeTree.gen.ts index 0e5dc131184..9bbb8755f9c 100644 --- a/e2e/solid-start/basic/src/routeTree.gen.ts +++ b/e2e/solid-start/basic/src/routeTree.gen.ts @@ -863,6 +863,7 @@ import type { getRouter } from './router.tsx' import type { createStart } from '@tanstack/solid-start' declare module '@tanstack/solid-start' { interface Register { + ssr: true router: Awaited> } } diff --git a/e2e/solid-start/custom-basepath/src/routeTree.gen.ts b/e2e/solid-start/custom-basepath/src/routeTree.gen.ts index 507455c73b2..6064fd7604f 100644 --- a/e2e/solid-start/custom-basepath/src/routeTree.gen.ts +++ b/e2e/solid-start/custom-basepath/src/routeTree.gen.ts @@ -298,6 +298,7 @@ import type { getRouter } from './router.tsx' import type { createStart } from '@tanstack/solid-start' declare module '@tanstack/solid-start' { interface Register { + ssr: true router: Awaited> } } diff --git a/e2e/solid-start/scroll-restoration/src/routeTree.gen.ts b/e2e/solid-start/scroll-restoration/src/routeTree.gen.ts index 9d39430dd08..4b8d19fbefa 100644 --- a/e2e/solid-start/scroll-restoration/src/routeTree.gen.ts +++ b/e2e/solid-start/scroll-restoration/src/routeTree.gen.ts @@ -121,6 +121,7 @@ import type { getRouter } from './router.tsx' import type { createStart } from '@tanstack/solid-start' declare module '@tanstack/solid-start' { interface Register { + ssr: true router: Awaited> } } diff --git a/e2e/solid-start/selective-ssr/src/routeTree.gen.ts b/e2e/solid-start/selective-ssr/src/routeTree.gen.ts index 96dd9ad640b..423535df711 100644 --- a/e2e/solid-start/selective-ssr/src/routeTree.gen.ts +++ b/e2e/solid-start/selective-ssr/src/routeTree.gen.ts @@ -106,6 +106,7 @@ import type { getRouter } from './router.tsx' import type { createStart } from '@tanstack/solid-start' declare module '@tanstack/solid-start' { interface Register { + ssr: true router: Awaited> } } diff --git a/e2e/solid-start/server-functions/src/routeTree.gen.ts b/e2e/solid-start/server-functions/src/routeTree.gen.ts index 25189685bb9..a1b7f601e88 100644 --- a/e2e/solid-start/server-functions/src/routeTree.gen.ts +++ b/e2e/solid-start/server-functions/src/routeTree.gen.ts @@ -360,6 +360,7 @@ import type { getRouter } from './router.tsx' import type { createStart } from '@tanstack/solid-start' declare module '@tanstack/solid-start' { interface Register { + ssr: true router: Awaited> } } diff --git a/e2e/solid-start/server-routes/src/routeTree.gen.ts b/e2e/solid-start/server-routes/src/routeTree.gen.ts index e50fbe7ba1e..954a90936f1 100644 --- a/e2e/solid-start/server-routes/src/routeTree.gen.ts +++ b/e2e/solid-start/server-routes/src/routeTree.gen.ts @@ -106,6 +106,7 @@ import type { getRouter } from './router.tsx' import type { createStart } from '@tanstack/solid-start' declare module '@tanstack/solid-start' { interface Register { + ssr: true router: Awaited> } } diff --git a/e2e/solid-start/spa-mode/src/routeTree.gen.ts b/e2e/solid-start/spa-mode/src/routeTree.gen.ts index 96dd9ad640b..423535df711 100644 --- a/e2e/solid-start/spa-mode/src/routeTree.gen.ts +++ b/e2e/solid-start/spa-mode/src/routeTree.gen.ts @@ -106,6 +106,7 @@ import type { getRouter } from './router.tsx' import type { createStart } from '@tanstack/solid-start' declare module '@tanstack/solid-start' { interface Register { + ssr: true router: Awaited> } } diff --git a/e2e/solid-start/website/src/routeTree.gen.ts b/e2e/solid-start/website/src/routeTree.gen.ts index 91f0d2f7287..0b9ca527e54 100644 --- a/e2e/solid-start/website/src/routeTree.gen.ts +++ b/e2e/solid-start/website/src/routeTree.gen.ts @@ -284,6 +284,7 @@ import type { getRouter } from './router.tsx' import type { createStart } from '@tanstack/solid-start' declare module '@tanstack/solid-start' { interface Register { + ssr: true router: Awaited> } } diff --git a/examples/react/start-bare/src/routeTree.gen.ts b/examples/react/start-bare/src/routeTree.gen.ts index bb937ce84a1..421daf2790a 100644 --- a/examples/react/start-bare/src/routeTree.gen.ts +++ b/examples/react/start-bare/src/routeTree.gen.ts @@ -80,6 +80,7 @@ import type { getRouter } from './router.tsx' import type { createStart } from '@tanstack/react-start' declare module '@tanstack/react-start' { interface Register { + ssr: true router: Awaited> } } diff --git a/examples/react/start-basic-auth/src/routeTree.gen.ts b/examples/react/start-basic-auth/src/routeTree.gen.ts index b6882e6c516..6691c8a12f3 100644 --- a/examples/react/start-basic-auth/src/routeTree.gen.ts +++ b/examples/react/start-basic-auth/src/routeTree.gen.ts @@ -218,6 +218,7 @@ import type { getRouter } from './router.tsx' import type { createStart } from '@tanstack/react-start' declare module '@tanstack/react-start' { interface Register { + ssr: true router: Awaited> } } diff --git a/examples/react/start-basic-react-query/src/routeTree.gen.ts b/examples/react/start-basic-react-query/src/routeTree.gen.ts index 7dea7d32fa2..e713afe557e 100644 --- a/examples/react/start-basic-react-query/src/routeTree.gen.ts +++ b/examples/react/start-basic-react-query/src/routeTree.gen.ts @@ -424,6 +424,7 @@ import type { getRouter } from './router.tsx' import type { createStart } from '@tanstack/react-start' declare module '@tanstack/react-start' { interface Register { + ssr: true router: Awaited> } } diff --git a/examples/react/start-basic-static/src/routeTree.gen.ts b/examples/react/start-basic-static/src/routeTree.gen.ts index 4116787031e..bb27e7cefc6 100644 --- a/examples/react/start-basic-static/src/routeTree.gen.ts +++ b/examples/react/start-basic-static/src/routeTree.gen.ts @@ -368,6 +368,7 @@ import type { getRouter } from './router.tsx' import type { createStart } from '@tanstack/react-start' declare module '@tanstack/react-start' { interface Register { + ssr: true router: Awaited> } } diff --git a/examples/react/start-basic/src/routeTree.gen.ts b/examples/react/start-basic/src/routeTree.gen.ts index 011ecf91f23..d7e1332c9ac 100644 --- a/examples/react/start-basic/src/routeTree.gen.ts +++ b/examples/react/start-basic/src/routeTree.gen.ts @@ -441,6 +441,7 @@ import type { getRouter } from './router.tsx' import type { startInstance } from './start.tsx' declare module '@tanstack/react-start' { interface Register { + ssr: true router: Awaited> config: Awaited> } diff --git a/examples/react/start-convex-trellaux/src/routeTree.gen.ts b/examples/react/start-convex-trellaux/src/routeTree.gen.ts index 7b846980985..0b6ddaa12c4 100644 --- a/examples/react/start-convex-trellaux/src/routeTree.gen.ts +++ b/examples/react/start-convex-trellaux/src/routeTree.gen.ts @@ -80,6 +80,7 @@ import type { getRouter } from './router.tsx' import type { createStart } from '@tanstack/react-start' declare module '@tanstack/react-start' { interface Register { + ssr: true router: Awaited> } } diff --git a/examples/react/start-counter/src/routeTree.gen.ts b/examples/react/start-counter/src/routeTree.gen.ts index d9eff184704..dceedffdc12 100644 --- a/examples/react/start-counter/src/routeTree.gen.ts +++ b/examples/react/start-counter/src/routeTree.gen.ts @@ -62,6 +62,7 @@ import type { getRouter } from './router.tsx' import type { createStart } from '@tanstack/react-start' declare module '@tanstack/react-start' { interface Register { + ssr: true router: Awaited> } } diff --git a/examples/react/start-large/src/routeTree.gen.ts b/examples/react/start-large/src/routeTree.gen.ts index ac357b7aeac..03cc2b9080b 100644 --- a/examples/react/start-large/src/routeTree.gen.ts +++ b/examples/react/start-large/src/routeTree.gen.ts @@ -233,6 +233,7 @@ import type { getRouter } from './router.tsx' import type { createStart } from '@tanstack/react-start' declare module '@tanstack/react-start' { interface Register { + ssr: true router: Awaited> } } diff --git a/examples/react/start-material-ui/src/routeTree.gen.ts b/examples/react/start-material-ui/src/routeTree.gen.ts index bb937ce84a1..421daf2790a 100644 --- a/examples/react/start-material-ui/src/routeTree.gen.ts +++ b/examples/react/start-material-ui/src/routeTree.gen.ts @@ -80,6 +80,7 @@ import type { getRouter } from './router.tsx' import type { createStart } from '@tanstack/react-start' declare module '@tanstack/react-start' { interface Register { + ssr: true router: Awaited> } } diff --git a/examples/react/start-supabase-basic/src/routeTree.gen.ts b/examples/react/start-supabase-basic/src/routeTree.gen.ts index 19a8180edba..9e96fafa6af 100644 --- a/examples/react/start-supabase-basic/src/routeTree.gen.ts +++ b/examples/react/start-supabase-basic/src/routeTree.gen.ts @@ -219,6 +219,7 @@ import type { getRouter } from './router.tsx' import type { createStart } from '@tanstack/react-start' declare module '@tanstack/react-start' { interface Register { + ssr: true router: Awaited> } } diff --git a/examples/react/start-tailwind-v4/src/routeTree.gen.ts b/examples/react/start-tailwind-v4/src/routeTree.gen.ts index d9eff184704..dceedffdc12 100644 --- a/examples/react/start-tailwind-v4/src/routeTree.gen.ts +++ b/examples/react/start-tailwind-v4/src/routeTree.gen.ts @@ -62,6 +62,7 @@ import type { getRouter } from './router.tsx' import type { createStart } from '@tanstack/react-start' declare module '@tanstack/react-start' { interface Register { + ssr: true router: Awaited> } } diff --git a/examples/react/start-trellaux/src/routeTree.gen.ts b/examples/react/start-trellaux/src/routeTree.gen.ts index 7b846980985..0b6ddaa12c4 100644 --- a/examples/react/start-trellaux/src/routeTree.gen.ts +++ b/examples/react/start-trellaux/src/routeTree.gen.ts @@ -80,6 +80,7 @@ import type { getRouter } from './router.tsx' import type { createStart } from '@tanstack/react-start' declare module '@tanstack/react-start' { interface Register { + ssr: true router: Awaited> } } diff --git a/examples/react/start-workos/src/routeTree.gen.ts b/examples/react/start-workos/src/routeTree.gen.ts index ff9b7a5c87c..8e275a0f1b6 100644 --- a/examples/react/start-workos/src/routeTree.gen.ts +++ b/examples/react/start-workos/src/routeTree.gen.ts @@ -147,6 +147,7 @@ import type { getRouter } from './router.tsx' import type { createStart } from '@tanstack/react-start' declare module '@tanstack/react-start' { interface Register { + ssr: true router: Awaited> } } diff --git a/examples/solid/start-bare/src/routeTree.gen.ts b/examples/solid/start-bare/src/routeTree.gen.ts index 85bb67e7758..3cc45c071ea 100644 --- a/examples/solid/start-bare/src/routeTree.gen.ts +++ b/examples/solid/start-bare/src/routeTree.gen.ts @@ -80,6 +80,7 @@ import type { getRouter } from './router.tsx' import type { createStart } from '@tanstack/solid-start' declare module '@tanstack/solid-start' { interface Register { + ssr: true router: Awaited> } } diff --git a/examples/solid/start-basic-static/src/routeTree.gen.ts b/examples/solid/start-basic-static/src/routeTree.gen.ts index 2c6990916d1..71da6e9ae89 100644 --- a/examples/solid/start-basic-static/src/routeTree.gen.ts +++ b/examples/solid/start-basic-static/src/routeTree.gen.ts @@ -368,6 +368,7 @@ import type { getRouter } from './router.tsx' import type { createStart } from '@tanstack/solid-start' declare module '@tanstack/solid-start' { interface Register { + ssr: true router: Awaited> } } diff --git a/examples/solid/start-basic/src/routeTree.gen.ts b/examples/solid/start-basic/src/routeTree.gen.ts index c9e9fbeceb3..7ee820f3c9e 100644 --- a/examples/solid/start-basic/src/routeTree.gen.ts +++ b/examples/solid/start-basic/src/routeTree.gen.ts @@ -420,6 +420,7 @@ import type { getRouter } from './router.tsx' import type { createStart } from '@tanstack/solid-start' declare module '@tanstack/solid-start' { interface Register { + ssr: true router: Awaited> } } diff --git a/packages/router-core/src/router.ts b/packages/router-core/src/router.ts index 6ca77a4bcd2..f3eb7c88e8c 100644 --- a/packages/router-core/src/router.ts +++ b/packages/router-core/src/router.ts @@ -101,6 +101,12 @@ export interface Register { // ssr } +export type RegisteredSsr = TRegister extends { + ssr: infer TSSR +} + ? TSSR + : false + export type RegisteredRouter = TRegister extends { router: infer TRouter } diff --git a/packages/router-core/src/ssr/serializer/transformer.ts b/packages/router-core/src/ssr/serializer/transformer.ts index 564800811f0..9e8b2b11309 100644 --- a/packages/router-core/src/ssr/serializer/transformer.ts +++ b/packages/router-core/src/ssr/serializer/transformer.ts @@ -1,7 +1,11 @@ import { createPlugin } from 'seroval' import { GLOBAL_TSR } from '../constants' import type { Plugin, SerovalNode } from 'seroval' -import type { RegisteredConfigType, SSROption } from '../../router' +import type { + RegisteredConfigType, + RegisteredSsr, + SSROption, +} from '../../router' import type { LooseReturnType } from '../../utils' import type { AnyRoute, ResolveAllSSR } from '../../route' @@ -194,16 +198,17 @@ export type ValidateSerializableLifecycleResult< TParentRoute extends AnyRoute, TSSR, TFn, -> = false extends (TRegister extends { ssr: infer TSSR } ? TSSR : never) - ? any - : ValidateSerializableLifecycleResultSSR< - TRegister, - TParentRoute, - TSSR, - TFn - > extends infer TInput - ? TInput - : never +> = + false extends RegisteredSsr + ? any + : ValidateSerializableLifecycleResultSSR< + TRegister, + TParentRoute, + TSSR, + TFn + > extends infer TInput + ? TInput + : never export type ValidateSerializableLifecycleResultSSR< TRegister, diff --git a/packages/start-plugin-core/src/start-router-plugin/plugin.ts b/packages/start-plugin-core/src/start-router-plugin/plugin.ts index 8e7b382f611..a4cae88694b 100644 --- a/packages/start-plugin-core/src/start-router-plugin/plugin.ts +++ b/packages/start-plugin-core/src/start-router-plugin/plugin.ts @@ -71,6 +71,7 @@ function moduleDeclaration({ result.push( `declare module '@tanstack/${corePluginOpts.framework}-start' { interface Register { + ssr: true router: Awaited>`, ) if (startFilePath) {