Skip to content
Draft
9 changes: 9 additions & 0 deletions .changeset/thick-sloths-write.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
'@tanstack/start-client-core': patch
'@tanstack/start-server-core': patch
'@tanstack/react-start': patch
'@tanstack/solid-start': patch
'@tanstack/vue-start': patch
---

refactor(start): export and use its own `Register` interface
4 changes: 2 additions & 2 deletions docs/start/framework/react/guide/server-entry-point.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export default createServerEntry({

When your server needs to pass additional, typed data into request handlers (for example, authenticated user info, a database connection, or per-request flags), register a request context type via TypeScript module augmentation. The registered context is delivered as the second argument to the server `fetch` handler and is available throughout the server-side middleware chain — including global middleware, request/function middleware, server routes, server functions, and the router itself.

To add types for your request context, augment the `Register` interface from `@tanstack/react-router` with a `server.requestContext` property. The runtime `context` you pass to `handler.fetch` will then match that type. Example:
To add types for your request context, augment the `Register` interface from `@tanstack/react-start` with a `server.requestContext` property. The runtime `context` you pass to `handler.fetch` will then match that type. Example:

```tsx
import handler, { createServerEntry } from '@tanstack/react-start/server-entry'
Expand All @@ -74,7 +74,7 @@ type MyRequestContext = {
foo: number
}

declare module '@tanstack/react-router' {
declare module '@tanstack/react-start' {
interface Register {
server: {
requestContext: MyRequestContext
Expand Down
6 changes: 1 addition & 5 deletions docs/start/framework/solid/guide/server-entry-point.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
---
ref: docs/start/framework/react/guide/server-entry-point.md
replace:
{
'@tanstack/react-start': '@tanstack/solid-start',
'@tanstack/react-router': '@tanstack/solid-router',
'React': 'SolidJS',
}
{ '@tanstack/react-start': '@tanstack/solid-start', 'React': 'SolidJS' }
---
2 changes: 1 addition & 1 deletion e2e/react-start/basic-auth/src/routeTree.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ export const routeTree = rootRouteImport

import type { getRouter } from './router.tsx'
import type { createStart } from '@tanstack/react-start'
declare module '@tanstack/react-start' {
declare module '@tanstack/react-router' {
interface Register {
ssr: true
router: Awaited<ReturnType<typeof getRouter>>
Expand Down
2 changes: 1 addition & 1 deletion e2e/react-start/basic-cloudflare/src/routeTree.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export const routeTree = rootRouteImport

import type { getRouter } from './router.tsx'
import type { createStart } from '@tanstack/react-start'
declare module '@tanstack/react-start' {
declare module '@tanstack/react-router' {
interface Register {
ssr: true
router: Awaited<ReturnType<typeof getRouter>>
Expand Down
2 changes: 1 addition & 1 deletion e2e/react-start/basic-react-query/src/routeTree.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ export const routeTree = rootRouteImport

import type { getRouter } from './router.tsx'
import type { createStart } from '@tanstack/react-start'
declare module '@tanstack/react-start' {
declare module '@tanstack/react-router' {
interface Register {
ssr: true
router: Awaited<ReturnType<typeof getRouter>>
Expand Down
2 changes: 1 addition & 1 deletion e2e/react-start/basic-tsr-config/src/routeTree.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export const routeTree = rootRouteImport

import type { getRouter } from './router.tsx'
import type { createStart } from '@tanstack/react-start'
declare module '@tanstack/react-start' {
declare module '@tanstack/react-router' {
interface Register {
ssr: true
router: Awaited<ReturnType<typeof getRouter>>
Expand Down
2 changes: 1 addition & 1 deletion e2e/react-start/basic/src/routeTree.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1639,7 +1639,7 @@ export const routeTree = rootRouteImport

import type { getRouter } from './router.tsx'
import type { createStart } from '@tanstack/react-start'
declare module '@tanstack/react-start' {
declare module '@tanstack/react-router' {
interface Register {
ssr: true
router: Awaited<ReturnType<typeof getRouter>>
Expand Down
15 changes: 14 additions & 1 deletion e2e/react-start/basic/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,21 @@ import handler from '@tanstack/react-start/server-entry'

console.log("[server-entry]: using custom server entry in 'src/server.ts'")

declare module '@tanstack/react-start' {
interface Register {
server: {
/**
* This is just a test to make sure that the typing of the request context is working correctly in the custom server entry.
*/
requestContext: {
foo: string
}
}
}
}

export default {
fetch(request: Request) {
return handler.fetch(request)
return handler.fetch(request, { context: { foo: 'bar' } })
},
}
2 changes: 1 addition & 1 deletion e2e/react-start/csp/src/routeTree.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export const routeTree = rootRouteImport

import type { getRouter } from './router.tsx'
import type { createStart } from '@tanstack/react-start'
declare module '@tanstack/react-start' {
declare module '@tanstack/react-router' {
interface Register {
ssr: true
router: Awaited<ReturnType<typeof getRouter>>
Expand Down
2 changes: 1 addition & 1 deletion e2e/react-start/css-inline/src/routeTree.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ export const routeTree = rootRouteImport

import type { getRouter } from './router.tsx'
import type { createStart } from '@tanstack/react-start'
declare module '@tanstack/react-start' {
declare module '@tanstack/react-router' {
interface Register {
ssr: true
router: Awaited<ReturnType<typeof getRouter>>
Expand Down
2 changes: 1 addition & 1 deletion e2e/react-start/css-modules/src/routeTree.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export const routeTree = rootRouteImport

import type { getRouter } from './router.tsx'
import type { createStart } from '@tanstack/react-start'
declare module '@tanstack/react-start' {
declare module '@tanstack/react-router' {
interface Register {
ssr: true
router: Awaited<ReturnType<typeof getRouter>>
Expand Down
2 changes: 1 addition & 1 deletion e2e/react-start/custom-basepath/src/routeTree.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ export const routeTree = rootRouteImport

import type { getRouter } from './router.tsx'
import type { createStart } from '@tanstack/react-start'
declare module '@tanstack/react-start' {
declare module '@tanstack/react-router' {
interface Register {
ssr: true
router: Awaited<ReturnType<typeof getRouter>>
Expand Down
2 changes: 1 addition & 1 deletion e2e/react-start/custom-server-rsbuild/src/routeTree.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export const routeTree = rootRouteImport

import type { getRouter } from './router.tsx'
import type { createStart } from '@tanstack/react-start'
declare module '@tanstack/react-start' {
declare module '@tanstack/react-router' {
interface Register {
ssr: true
router: Awaited<ReturnType<typeof getRouter>>
Expand Down
2 changes: 1 addition & 1 deletion e2e/react-start/dev-ssr-styles/src/routeTree.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export const routeTree = rootRouteImport

import type { getRouter } from './router.tsx'
import type { createStart } from '@tanstack/react-start'
declare module '@tanstack/react-start' {
declare module '@tanstack/react-router' {
interface Register {
ssr: true
router: Awaited<ReturnType<typeof getRouter>>
Expand Down
2 changes: 1 addition & 1 deletion e2e/react-start/early-hints/src/routeTree.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ export const routeTree = rootRouteImport

import type { getRouter } from './router.tsx'
import type { createStart } from '@tanstack/react-start'
declare module '@tanstack/react-start' {
declare module '@tanstack/react-router' {
interface Register {
ssr: true
router: Awaited<ReturnType<typeof getRouter>>
Expand Down
2 changes: 1 addition & 1 deletion e2e/react-start/flamegraph-bench/src/routeTree.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -933,7 +933,7 @@ export const routeTree = rootRouteImport

import type { getRouter } from './router.tsx'
import type { createStart } from '@tanstack/react-start'
declare module '@tanstack/react-start' {
declare module '@tanstack/react-router' {
interface Register {
ssr: true
router: Awaited<ReturnType<typeof getRouter>>
Expand Down
2 changes: 1 addition & 1 deletion e2e/react-start/hmr/src/routeTree.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ export const routeTree = rootRouteImport

import type { getRouter } from './router.tsx'
import type { createStart } from '@tanstack/react-start'
declare module '@tanstack/react-start' {
declare module '@tanstack/react-router' {
interface Register {
ssr: true
router: Awaited<ReturnType<typeof getRouter>>
Expand Down
2 changes: 1 addition & 1 deletion e2e/react-start/i18n-paraglide/src/routeTree.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export const routeTree = rootRouteImport

import type { getRouter } from './router.tsx'
import type { createStart } from '@tanstack/react-start'
declare module '@tanstack/react-start' {
declare module '@tanstack/react-router' {
interface Register {
ssr: true
router: Awaited<ReturnType<typeof getRouter>>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export const routeTree = rootRouteImport

import type { getRouter } from './router.tsx'
import type { createStart } from '@tanstack/react-start'
declare module '@tanstack/react-start' {
declare module '@tanstack/react-router' {
interface Register {
ssr: true
router: Awaited<ReturnType<typeof getRouter>>
Expand Down
2 changes: 1 addition & 1 deletion e2e/react-start/query-integration/src/routeTree.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export const routeTree = rootRouteImport

import type { getRouter } from './router.tsx'
import type { createStart } from '@tanstack/react-start'
declare module '@tanstack/react-start' {
declare module '@tanstack/react-router' {
interface Register {
ssr: true
router: Awaited<ReturnType<typeof getRouter>>
Expand Down
2 changes: 1 addition & 1 deletion e2e/react-start/rsc/src/routeTree.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1030,7 +1030,7 @@ export const routeTree = rootRouteImport

import type { getRouter } from './router.tsx'
import type { createStart } from '@tanstack/react-start'
declare module '@tanstack/react-start' {
declare module '@tanstack/react-router' {
interface Register {
ssr: true
router: Awaited<ReturnType<typeof getRouter>>
Expand Down
2 changes: 1 addition & 1 deletion e2e/react-start/scroll-restoration/src/routeTree.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ export const routeTree = rootRouteImport

import type { getRouter } from './router.tsx'
import type { createStart } from '@tanstack/react-start'
declare module '@tanstack/react-start' {
declare module '@tanstack/react-router' {
interface Register {
ssr: true
router: Awaited<ReturnType<typeof getRouter>>
Expand Down
2 changes: 1 addition & 1 deletion e2e/react-start/selective-ssr/src/routeTree.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export const routeTree = rootRouteImport

import type { getRouter } from './router.tsx'
import type { createStart } from '@tanstack/react-start'
declare module '@tanstack/react-start' {
declare module '@tanstack/react-router' {
interface Register {
ssr: true
router: Awaited<ReturnType<typeof getRouter>>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ export const routeTree = rootRouteImport

import type { getRouter } from './router.tsx'
import type { startInstance } from './start.tsx'
declare module '@tanstack/react-start' {
declare module '@tanstack/react-router' {
interface Register {
ssr: true
router: Awaited<ReturnType<typeof getRouter>>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ export const routeTree = rootRouteImport

import type { getRouter } from './router.tsx'
import type { startInstance } from './start.ts'
declare module '@tanstack/react-start' {
declare module '@tanstack/react-router' {
interface Register {
ssr: true
router: Awaited<ReturnType<typeof getRouter>>
Expand Down
2 changes: 1 addition & 1 deletion e2e/react-start/server-functions/src/routeTree.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -979,7 +979,7 @@ export const routeTree = rootRouteImport

import type { getRouter } from './router.tsx'
import type { startInstance } from './start.ts'
declare module '@tanstack/react-start' {
declare module '@tanstack/react-router' {
interface Register {
ssr: true
router: Awaited<ReturnType<typeof getRouter>>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export const routeTree = rootRouteImport

import type { getRouter } from './router.tsx'
import type { startInstance } from './start.ts'
declare module '@tanstack/react-start' {
declare module '@tanstack/react-router' {
interface Register {
ssr: true
router: Awaited<ReturnType<typeof getRouter>>
Expand Down
2 changes: 1 addition & 1 deletion e2e/react-start/server-routes/src/routeTree.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ export const routeTree = rootRouteImport

import type { getRouter } from './router.tsx'
import type { createStart } from '@tanstack/react-start'
declare module '@tanstack/react-start' {
declare module '@tanstack/react-router' {
interface Register {
ssr: true
router: Awaited<ReturnType<typeof getRouter>>
Expand Down
2 changes: 1 addition & 1 deletion e2e/react-start/spa-mode/src/routeTree.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export const routeTree = rootRouteImport

import type { getRouter } from './router.tsx'
import type { createStart } from '@tanstack/react-start'
declare module '@tanstack/react-start' {
declare module '@tanstack/react-router' {
interface Register {
ssr: true
router: Awaited<ReturnType<typeof getRouter>>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export const routeTree = rootRouteImport

import type { getRouter } from './router.tsx'
import type { createStart } from '@tanstack/react-start'
declare module '@tanstack/react-start' {
declare module '@tanstack/react-router' {
interface Register {
ssr: true
router: Awaited<ReturnType<typeof getRouter>>
Expand Down
2 changes: 1 addition & 1 deletion e2e/react-start/start-manifest/src/routeTree.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ export const routeTree = rootRouteImport

import type { getRouter } from './router.tsx'
import type { createStart } from '@tanstack/react-start'
declare module '@tanstack/react-start' {
declare module '@tanstack/react-router' {
interface Register {
ssr: true
router: Awaited<ReturnType<typeof getRouter>>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export const routeTree = rootRouteImport

import type { getRouter } from './router.tsx'
import type { createStart } from '@tanstack/react-start'
declare module '@tanstack/react-start' {
declare module '@tanstack/react-router' {
interface Register {
ssr: true
router: Awaited<ReturnType<typeof getRouter>>
Expand Down
2 changes: 1 addition & 1 deletion e2e/react-start/streaming-ssr/src/routeTree.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ export const routeTree = rootRouteImport

import type { getRouter } from './router.tsx'
import type { createStart } from '@tanstack/react-start'
declare module '@tanstack/react-start' {
declare module '@tanstack/react-router' {
interface Register {
ssr: true
router: Awaited<ReturnType<typeof getRouter>>
Expand Down
2 changes: 1 addition & 1 deletion e2e/react-start/transform-asset-urls/src/routeTree.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export const routeTree = rootRouteImport

import type { getRouter } from './router.tsx'
import type { createStart } from '@tanstack/react-start'
declare module '@tanstack/react-start' {
declare module '@tanstack/react-router' {
interface Register {
ssr: true
router: Awaited<ReturnType<typeof getRouter>>
Expand Down
2 changes: 1 addition & 1 deletion e2e/react-start/virtual-routes/src/routeTree.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ export const routeTree = rootRouteImport

import type { getRouter } from './router.tsx'
import type { createStart } from '@tanstack/react-start'
declare module '@tanstack/react-start' {
declare module '@tanstack/react-router' {
interface Register {
ssr: true
router: Awaited<ReturnType<typeof getRouter>>
Expand Down
2 changes: 1 addition & 1 deletion e2e/react-start/website/src/routeTree.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ export const routeTree = rootRouteImport

import type { getRouter } from './router.tsx'
import type { createStart } from '@tanstack/react-start'
declare module '@tanstack/react-start' {
declare module '@tanstack/react-router' {
interface Register {
ssr: true
router: Awaited<ReturnType<typeof getRouter>>
Expand Down
2 changes: 1 addition & 1 deletion e2e/solid-start/basic-auth/src/routeTree.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ export const routeTree = rootRouteImport

import type { getRouter } from './router.tsx'
import type { createStart } from '@tanstack/solid-start'
declare module '@tanstack/solid-start' {
declare module '@tanstack/solid-router' {
interface Register {
ssr: true
router: Awaited<ReturnType<typeof getRouter>>
Expand Down
2 changes: 1 addition & 1 deletion e2e/solid-start/basic-cloudflare/src/routeTree.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export const routeTree = rootRouteImport

import type { getRouter } from './router.tsx'
import type { createStart } from '@tanstack/solid-start'
declare module '@tanstack/solid-start' {
declare module '@tanstack/solid-router' {
interface Register {
ssr: true
router: Awaited<ReturnType<typeof getRouter>>
Expand Down
2 changes: 1 addition & 1 deletion e2e/solid-start/basic-solid-query/src/routeTree.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ export const routeTree = rootRouteImport

import type { getRouter } from './router.tsx'
import type { createStart } from '@tanstack/solid-start'
declare module '@tanstack/solid-start' {
declare module '@tanstack/solid-router' {
interface Register {
ssr: true
router: Awaited<ReturnType<typeof getRouter>>
Expand Down
2 changes: 1 addition & 1 deletion e2e/solid-start/basic-tsr-config/src/app/routeTree.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export const routeTree = rootRouteImport

import type { getRouter } from './router.tsx'
import type { createStart } from '@tanstack/solid-start'
declare module '@tanstack/solid-start' {
declare module '@tanstack/solid-router' {
interface Register {
ssr: true
router: Awaited<ReturnType<typeof getRouter>>
Expand Down
Loading
Loading