diff --git a/docs/router/framework/react/guide/navigation.md b/docs/router/framework/react/guide/navigation.md
index 26b8a02ce3..3305a61bf3 100644
--- a/docs/router/framework/react/guide/navigation.md
+++ b/docs/router/framework/react/guide/navigation.md
@@ -28,7 +28,7 @@ type ToOptions<
TTo extends string = '',
> = {
// `from` is an optional route ID or path. If it is not supplied, only absolute paths will be auto-completed and type-safe. It's common to supply the route.fullPath of the origin route you are rendering from for convenience. If you don't know the origin route, leave this empty and work with absolute paths or unsafe relative paths.
- from: string
+ from?: string
// `to` can be an absolute route path or a relative path from the `from` option to a valid route path. ⚠️ Do not interpolate path params, hash or search params into the `to` options. Use the `params`, `search`, and `hash` options instead.
to: string
// `params` is either an object of path params to interpolate into the `to` option or a function that supplies the previous params and allows you to return new ones. This is the only way to interpolate dynamic parameters into the final URL. Depending on the `from` and `to` route, you may need to supply none, some or all of the path params. TypeScript will notify you of the required params if there are any.
@@ -183,7 +183,7 @@ Keep in mind that normally dynamic segment params are `string` values, but they
By default, all links are absolute unless a `from` route path is provided. This means that the above link will always navigate to the `/about` route regardless of what route you are currently on.
-If you want to make a link that is relative to the current route, you can provide a `from` route path:
+Relative links can be combined with a `from` route path. If a from route path isn't provided, relative paths default to the current active location.
```tsx
const postIdRoute = createRoute({
@@ -201,9 +201,9 @@ As seen above, it's common to provide the `route.fullPath` as the `from` route p
### Special relative paths: `"."` and `".."`
-Quite often you might want to reload the current location, for example, to rerun the loaders on the current and/or parent routes, or maybe there was a change in search parameters. This can be achieved by specifying a `to` route path of `"."` which will reload the current location. This is only applicable to the current location, and hence any `from` route path specified is ignored.
+Quite often you might want to reload the current location or another `from` path, for example, to rerun the loaders on the current and/or parent routes, or maybe navigate back to a parent route. This can be achieved by specifying a `to` route path of `"."` which will reload the current location or provided `from` path.
-Another common need is to navigate one route back relative to the current location or some other matched route in the current tree. By specifying a `to` route path of `".."` navigation will be resolved to either the first parent route preceding the current location or, if specified, preceding the `"from"` route path.
+Another common need is to navigate one route back relative to the current location or another path. By specifying a `to` route path of `".."` navigation will be resolved to the first parent route preceding the current location.
```tsx
export const Route = createFileRoute('/posts/$postId')({
@@ -214,7 +214,14 @@ function PostComponent() {
return (
Reload the current route of /posts/$postId
-
Navigate to /posts
+
Navigate back to /posts
+ // the below are all equivalent
+
Navigate back to /posts
+
+ Navigate back to /posts
+
+ // the below are all equivalent
+
Navigate to root
Navigate to root
diff --git a/docs/start/framework/react/build-from-scratch.md b/docs/start/framework/react/build-from-scratch.md
index 74989fb9ea..8f44051fde 100644
--- a/docs/start/framework/react/build-from-scratch.md
+++ b/docs/start/framework/react/build-from-scratch.md
@@ -58,13 +58,15 @@ npm i @tanstack/react-start @tanstack/react-router vite
You'll also need React:
```shell
-npm i react react-dom
+npm i react react-dom @vitejs/plugin-react
```
+Alternatively, you can also use `@vitejs/plugin-react-oxc` or `@vitejs/plugin-react-swc`.
+
and some TypeScript:
```shell
-npm i -D typescript @types/react @types/react-dom vite-tsconfig-paths @vitejs/plugin-react
+npm i -D typescript @types/react @types/react-dom vite-tsconfig-paths
```
## Update Configuration Files
@@ -84,9 +86,6 @@ We'll then update our `package.json` to use Vite's CLI and set `"type": "module"
Then configure TanStack Start's Vite plugin in `vite.config.ts`:
-> [!NOTE]
-> TanStack Start will stop auto-configuring React/Solid Vite plugins. You’ll get full control - choose `@vitejs/plugin-react`, `@vitejs/plugin-react-oxc`, etc. Set `customViteReactPlugin: true` to opt in to this feature right now!
-
```ts
// vite.config.ts
import { defineConfig } from 'vite'
@@ -100,7 +99,8 @@ export default defineConfig({
},
plugins: [
tsConfigPaths(),
- tanstackStart({ customViteReactPlugin: true }),
+ tanstackStart(),
+ // react's vite plugin must come after start's vite plugin
viteReact(),
],
})
diff --git a/docs/start/framework/react/hosting.md b/docs/start/framework/react/hosting.md
index aff63011e7..383d0bd9f8 100644
--- a/docs/start/framework/react/hosting.md
+++ b/docs/start/framework/react/hosting.md
@@ -48,11 +48,12 @@ Set the `target` value to `'netlify'` in the TanStack Start Vite plugin in `vite
```ts
// vite.config.ts
-import { tanstackStart } from '@tanstack/react-start/plugin/vite'
import { defineConfig } from 'vite'
+import { tanstackStart } from '@tanstack/react-start/plugin/vite'
+import viteReact from '@vitejs/plugin-react'
export default defineConfig({
- plugins: [tanstackStart({ target: 'netlify' })],
+ plugins: [tanstackStart({ target: 'netlify' }), viteReact()],
})
```
@@ -64,11 +65,12 @@ Set the `target` value to `'vercel'` in the TanStack Start Vite plugin in `vite.
```ts
// vite.config.ts
-import { tanstackStart } from '@tanstack/react-start/plugin/vite'
import { defineConfig } from 'vite'
+import { tanstackStart } from '@tanstack/react-start/plugin/vite'
+import viteReact from '@vitejs/plugin-react'
export default defineConfig({
- plugins: [tanstackStart({ target: 'vercel' })],
+ plugins: [tanstackStart({ target: 'vercel' }), viteReact()],
})
```
@@ -84,11 +86,12 @@ Set the `target` value to `cloudflare-module` in your `vite.config.ts` file.
```ts
// vite.config.ts
-import { tanstackStart } from '@tanstack/react-start/plugin/vite'
import { defineConfig } from 'vite'
+import { tanstackStart } from '@tanstack/react-start/plugin/vite'
+import viteReact from '@vitejs/plugin-react'
export default defineConfig({
- plugins: [tanstackStart({ target: 'cloudflare-module' })],
+ plugins: [tanstackStart({ target: 'cloudflare-module' }), viteReact()],
})
```
@@ -114,11 +117,12 @@ Set the `target` value to `node-server` in your `vite.config.ts` file.
```ts
// vite.config.ts
-import { tanstackStart } from '@tanstack/react-start/plugin/vite'
import { defineConfig } from 'vite'
+import { tanstackStart } from '@tanstack/react-start/plugin/vite'
+import viteReact from '@vitejs/plugin-react'
export default defineConfig({
- plugins: [tanstackStart({ target: 'node-server' })],
+ plugins: [tanstackStart({ target: 'node-server' }), viteReact()],
})
```
@@ -149,11 +153,12 @@ Set the `target` value to `bun` in your `vite.config.ts` file.
```ts
// vite.config.ts
-import { tanstackStart } from '@tanstack/react-start/plugin/vite'
import { defineConfig } from 'vite'
+import { tanstackStart } from '@tanstack/react-start/plugin/vite'
+import viteReact from '@vitejs/plugin-react'
export default defineConfig({
- plugins: [tanstackStart({ target: 'bun' })],
+ plugins: [tanstackStart({ target: 'bun' }), viteReact()],
})
```
diff --git a/docs/start/framework/react/how-to/write-isomorphic-client-server-code.md b/docs/start/framework/react/how-to/write-isomorphic-client-server-code.md
index 9835639c34..b488b13936 100644
--- a/docs/start/framework/react/how-to/write-isomorphic-client-server-code.md
+++ b/docs/start/framework/react/how-to/write-isomorphic-client-server-code.md
@@ -35,13 +35,13 @@ export const Route = createFileRoute('/products')({
### Server-Only APIs
-| API | Use Case | Client Behavior |
-| ------------------ | ------------------------- | ------------------------- |
-| `createServerFn()` | RPC calls, data mutations | Network request to server |
-| `serverOnly(fn)` | Utility functions | Throws error |
+| API | Use Case | Client Behavior |
+| ------------------------ | ------------------------- | ------------------------- |
+| `createServerFn()` | RPC calls, data mutations | Network request to server |
+| `createServerOnlyFn(fn)` | Utility functions | Throws error |
```tsx
-import { createServerFn, serverOnly } from '@tanstack/react-start'
+import { createServerFn, createServerOnlyFn } from '@tanstack/react-start'
// RPC: Server execution, callable from client
const updateUser = createServerFn({ method: 'POST' })
@@ -52,22 +52,22 @@ const updateUser = createServerFn({ method: 'POST' })
})
// Utility: Server-only, client crashes if called
-const getEnvVar = serverOnly(() => process.env.DATABASE_URL)
+const getEnvVar = createServerOnlyFn(() => process.env.DATABASE_URL)
```
### Client-Only APIs
-| API | Use Case | Server Behavior |
-| ---------------- | ------------------------------- | ---------------- |
-| `clientOnly(fn)` | Browser utilities | Throws error |
-| `
` | Components needing browser APIs | Renders fallback |
+| API | Use Case | Server Behavior |
+| ------------------------ | ------------------------------- | ---------------- |
+| `createClientOnlyFn(fn)` | Browser utilities | Throws error |
+| `` | Components needing browser APIs | Renders fallback |
```tsx
-import { clientOnly } from '@tanstack/react-start'
+import { createClientOnlyFn } from '@tanstack/react-start'
import { ClientOnly } from '@tanstack/react-router'
// Utility: Client-only, server crashes if called
-const saveToStorage = clientOnly((key: string, value: any) => {
+const saveToStorage = createClientOnlyFn((key: string, value: any) => {
localStorage.setItem(key, JSON.stringify(value))
})
@@ -96,7 +96,7 @@ const getDeviceInfo = createIsomorphicFn()
## Key Distinctions
-### `createServerFn()` vs `serverOnly()`
+### `createServerFn()` vs `createServerOnlyFn()`
```tsx
// createServerFn: RPC pattern - server execution, client callable
@@ -105,8 +105,8 @@ const fetchUser = createServerFn().handler(async () => await db.users.find())
// Usage from client component:
const user = await fetchUser() // ✅ Network request
-// serverOnly: Crashes if called from client
-const getSecret = serverOnly(() => process.env.SECRET)
+// createServerOnlyFn: Crashes if called from client
+const getSecret = createServerOnlyFn(() => process.env.SECRET)
// Usage from client:
const secret = getSecret() // ❌ Throws error
@@ -182,7 +182,7 @@ const storage = createIsomorphicFn()
const apiKey = process.env.SECRET_KEY
// ✅ Server-only access
-const apiKey = serverOnly(() => process.env.SECRET_KEY)
+const apiKey = createServerOnlyFn(() => process.env.SECRET_KEY)
```
### Incorrect Loader Assumptions
@@ -233,7 +233,7 @@ function CurrentTime() {
## Production Checklist
- [ ] **Bundle Analysis**: Verify server-only code isn't in client bundle
-- [ ] **Environment Variables**: Ensure secrets use `serverOnly()` or `createServerFn()`
+- [ ] **Environment Variables**: Ensure secrets use `createServerOnlyFn()` or `createServerFn()`
- [ ] **Loader Logic**: Remember loaders are isomorphic, not server-only
- [ ] **ClientOnly Fallbacks**: Provide appropriate fallbacks to prevent layout shift
- [ ] **Error Boundaries**: Handle server/client execution errors gracefully
diff --git a/docs/start/framework/react/learn-the-basics.md b/docs/start/framework/react/learn-the-basics.md
index d9f9939be6..8e4e49b4e8 100644
--- a/docs/start/framework/react/learn-the-basics.md
+++ b/docs/start/framework/react/learn-the-basics.md
@@ -49,7 +49,7 @@ The `routeTree.gen.ts` file is generated when you run TanStack Start (via `npm r
> [!NOTE]
> The server entry point is **optional** out of the box. If not provided, TanStack Start will automatically handle the server entry point for you using the below as a default.
-This is done via the `src/server.ts` file:
+This is done via the `src/server.ts` file.
```tsx
// src/server.ts
@@ -59,9 +59,23 @@ import {
} from '@tanstack/react-start/server'
import { createRouter } from './router'
-export default createStartHandler({
+const fetch = createStartHandler({
createRouter,
})(defaultStreamHandler)
+
+export default {
+ fetch,
+}
+```
+
+The entry point must conform to the following interface:
+
+```tsx
+export default {
+ fetch(req: Request): Promise {
+ // ...
+ },
+}
```
Whether we are statically generating our app or serving it dynamically, the `server.ts` file is the entry point for doing all SSR-related work.
diff --git a/docs/start/framework/react/middleware.md b/docs/start/framework/react/middleware.md
index ecae7a9a87..3f1aee6cd2 100644
--- a/docs/start/framework/react/middleware.md
+++ b/docs/start/framework/react/middleware.md
@@ -148,20 +148,12 @@ const loggingMiddleware = createMiddleware({ type: 'function' })
Despite server functions being mostly server-side bound operations, there is still plenty of client-side logic surrounding the outgoing RPC request from the client. This means that we can also define client-side logic in middleware that will execute on the client side around any nested middleware and ultimately the RPC function and its response to the client.
-## Client-side Payload Validation
-
-By default, middleware validation is only performed on the server to keep the client bundle size small. However, you may also choose to validate data on the client side by passing the `validateClient: true` option to the `createMiddleware` function. This will cause the data to be validated on the client side before being sent to the server, potentially saving a round trip.
-
-> Why can't I pass a different validation schema for the client?
->
-> The client-side validation schema is derived from the server-side schema. This is because the client-side validation schema is used to validate the data before it is sent to the server. If the client-side schema were different from the server-side schema, the server would receive data that it did not expect, which could lead to unexpected behavior.
-
```tsx
import { createMiddleware } from '@tanstack/react-start'
import { zodValidator } from '@tanstack/zod-adapter'
import { z } from 'zod'
-const workspaceMiddleware = createMiddleware({ validateClient: true })
+const workspaceMiddleware = createMiddleware()
.validator(zodValidator(mySchema))
.server(({ next, data }) => {
console.log('Workspace ID:', data.workspaceId)
@@ -425,4 +417,4 @@ const fn = createServerFn()
Middleware functionality is tree-shaken based on the environment for each bundle produced.
- On the server, nothing is tree-shaken, so all code used in middleware will be included in the server bundle.
-- On the client, all server-specific code is removed from the client bundle. This means any code used in the `server` method is always removed from the client bundle. If `validateClient` is set to `true`, the client-side validation code will be included in the client bundle, otherwise `data` validation code will also be removed.
+- On the client, all server-specific code is removed from the client bundle. This means any code used in the `server` method is always removed from the client bundle. `data` validation code will also be removed.
diff --git a/docs/start/framework/react/migrate-from-next-js.md b/docs/start/framework/react/migrate-from-next-js.md
index ea080417f7..95a83e93d4 100644
--- a/docs/start/framework/react/migrate-from-next-js.md
+++ b/docs/start/framework/react/migrate-from-next-js.md
@@ -85,10 +85,11 @@ Now that you've installed the necessary dependencies, update your project config
```ts
// vite.config.ts
-import tailwindcss from '@tailwindcss/vite'
-import { tanstackStart } from '@tanstack/react-start/plugin/vite'
import { defineConfig } from 'vite'
+import { tanstackStart } from '@tanstack/react-start/plugin/vite'
+import viteReact from '@vitejs/plugin-react'
import tsconfigPaths from 'vite-tsconfig-paths'
+import tailwindcss from '@tailwindcss/vite'
export default defineConfig({
server: {
@@ -99,11 +100,12 @@ export default defineConfig({
// Enables Vite to resolve imports using path aliases.
tsconfigPaths(),
tanstackStart({
- tsr: {
+ router: {
// Specifies the directory TanStack Router uses for your routes.
routesDirectory: 'src/app', // Defaults to "src/routes"
},
}),
+ viteReact(),
],
})
```
diff --git a/docs/start/framework/react/server-functions.md b/docs/start/framework/react/server-functions.md
index 2c6a075b35..017efb5ecb 100644
--- a/docs/start/framework/react/server-functions.md
+++ b/docs/start/framework/react/server-functions.md
@@ -61,7 +61,6 @@ import { createServerFn } from '@tanstack/react-start'
export const getData = createServerFn({
method: 'GET', // HTTP method to use
- response: 'data', // Response handling mode
}).handler(async () => {
// Function implementation
})
@@ -79,18 +78,6 @@ method?: 'GET' | 'POST'
By default, server functions use `GET` if not specified.
-**`response`**
-
-Controls how responses are processed and returned:
-
-```tsx
-response?: 'data' | 'full' | 'raw'
-```
-
-- `'data'` (default): Automatically parses JSON responses and returns just the data
-- `'full'`: Returns a response object with result data, error information, and context
-- `'raw'`: Returns the raw Response object directly, enabling streaming responses and custom headers
-
## Where can I call server functions?
- From server-side code
@@ -360,7 +347,7 @@ function Test() {
## Server Function Context
-In addition to the single parameter that server functions accept, you can also access server request context from within any server function using utilities from `@tanstack/react-start/server`. Under the hood, we use [Unjs](https://unjs.io/)'s `h3` package to perform cross-platform HTTP requests.
+In addition to the single parameter that server functions accept, you can also access server request context from within any server function using utilities from `@tanstack/react-start/server`.
There are many context functions available to you for things like:
@@ -369,23 +356,20 @@ There are many context functions available to you for things like:
- Accessing/setting sessions/cookies
- Setting response status codes and status messages
- Dealing with multi-part form data
-- Reading/Setting custom server context properties
-
-For a full list of available context functions, see all of the available [h3 Methods](https://h3.unjs.io/utils/request) or inspect the [@tanstack/start-server-core Source Code](https://github.com/TanStack/router/tree/main/packages/start-server-core/src).
For starters, here are a few examples:
## Accessing the Request Context
-Let's use the `getWebRequest` function to access the request itself from within a server function:
+Let's use the `getRequest` function to access the request itself from within a server function:
```tsx
import { createServerFn } from '@tanstack/react-start'
-import { getWebRequest } from '@tanstack/react-start/server'
+import { getRequest } from '@tanstack/react-start/server'
export const getServerTime = createServerFn({ method: 'GET' }).handler(
async () => {
- const request = getWebRequest()
+ const request = getRequest()
console.log(request.method) // GET
@@ -396,15 +380,15 @@ export const getServerTime = createServerFn({ method: 'GET' }).handler(
## Accessing Headers
-Use the `getHeaders` function to access all headers from within a server function:
+Use the `getRequestHeaders` function to access all headers from within a server function:
```tsx
import { createServerFn } from '@tanstack/react-start'
-import { getHeaders } from '@tanstack/react-start/server'
+import { getRequestHeaders } from '@tanstack/react-start/server'
export const getServerTime = createServerFn({ method: 'GET' }).handler(
async () => {
- console.log(getHeaders())
+ console.log(getRequestHeaders())
// {
// "accept": "*/*",
// "accept-encoding": "gzip, deflate, br",
@@ -417,15 +401,15 @@ export const getServerTime = createServerFn({ method: 'GET' }).handler(
)
```
-You can also access individual headers using the `getHeader` function:
+You can also access individual headers using the `getRequestHeader` function:
```tsx
import { createServerFn } from '@tanstack/react-start'
-import { getHeader } from '@tanstack/react-start/server'
+import { getRequestHeader } from '@tanstack/react-start/server'
export const getServerTime = createServerFn({ method: 'GET' }).handler(
async () => {
- console.log(getHeader('User-Agent')) // Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3
+ console.log(getRequestHeader('User-Agent')) // Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3
},
)
```
@@ -466,15 +450,15 @@ By default, server functions assume that any non-Response object returned is eit
## Responding with Custom Headers
-To respond with custom headers, you can use the `setHeader` function:
+To respond with custom headers, you can use the `setResponseHeader` function:
```tsx
import { createServerFn } from '@tanstack/react-start'
-import { setHeader } from '@tanstack/react-start/server'
+import { setResponseHeader } from '@tanstack/react-start/server'
export const getServerTime = createServerFn({ method: 'GET' }).handler(
async () => {
- setHeader('X-Custom-Header', 'value')
+ setResponseHeader('X-Custom-Header', 'value')
return new Date().toISOString()
},
)
@@ -498,28 +482,26 @@ export const getServerTime = createServerFn({ method: 'GET' }).handler(
## Returning Raw Response objects
-To return a raw Response object, return a Response object from the server function and set `response: 'raw'`:
+To return a raw Response object, return a Response object from the server function:
```tsx
import { createServerFn } from '@tanstack/react-start'
export const getServerTime = createServerFn({
method: 'GET',
- response: 'raw',
}).handler(async () => {
// Read a file from s3
return fetch('https://example.com/time.txt')
})
```
-The response: 'raw' option also allows for streaming responses among other things:
+This also allows fro streaming responses among other things:
```tsx
import { createServerFn } from '@tanstack/react-start'
export const streamEvents = createServerFn({
method: 'GET',
- response: 'raw',
}).handler(async ({ signal }) => {
// Create a ReadableStream to send chunks of data
const stream = new ReadableStream({
@@ -569,7 +551,7 @@ export const streamEvents = createServerFn({
})
```
-The `response: 'raw'` option is particularly useful for:
+Returning raw responses is particularly useful for:
- Streaming APIs where data is sent incrementally
- Server-sent events
@@ -748,8 +730,6 @@ export const auth = createServerFn({ method: 'GET' }).handler(async () => {
})
```
-> ⚠️ Do not use `@tanstack/react-start/server`'s `sendRedirect` function to send soft redirects from within server functions. This will send the redirect using the `Location` header and will force a full page hard navigation on the client.
-
## Redirect Headers
You can also set custom headers on a redirect by passing a `headers` option:
diff --git a/docs/start/framework/react/server-routes.md b/docs/start/framework/react/server-routes.md
index 0f2a92199a..2f4cb39519 100644
--- a/docs/start/framework/react/server-routes.md
+++ b/docs/start/framework/react/server-routes.md
@@ -99,37 +99,11 @@ In the examples above, you may have noticed that the file naming conventions are
## Handling Server Route Requests
-Server route requests are handled by Start's `createStartHandler` in your `server.ts` entry file.
-
-```tsx
-// server.ts
-import {
- createStartHandler,
- defaultStreamHandler,
-} from '@tanstack/react-start/server'
-import { createRouter } from './router'
-
-export default createStartHandler({
- createRouter,
-})(defaultStreamHandler)
-```
+Server route requests are handled by Start automatically by default or by Start's `createStartHandler` in your custom `src/server.ts` entry point file.
The start handler is responsible for matching an incoming request to a server route and executing the appropriate middleware and handler.
-Remember, if you need to customize the server handler, you can do so by creating a custom handler and then passing the event to the start handler:
-
-```tsx
-// server.ts
-import { createStartHandler } from '@tanstack/react-start/server'
-
-export default defineHandler((event) => {
- const startHandler = createStartHandler({
- createRouter,
- })(defaultStreamHandler)
-
- return startHandler(event)
-})
-```
+If you need to customize the server handler, you can do so by creating a custom handler and then passing the event to the start handler. See [The Server Entry Point](../learn-the-basics#the-server-entry-point-optional).
## Defining a Server Route
@@ -366,15 +340,15 @@ Sometimes you may need to set headers in the response. You can do this by either
// Hello, World!
```
-- Or using the `setHeaders` helper function from `@tanstack/react-start/server`.
+- Or using the `setResponseHeaders` helper function from `@tanstack/react-start/server`.
```ts
// routes/hello.ts
- import { setHeaders } from '@tanstack/react-start/server'
+ import { setResponseHeaders } from '@tanstack/react-start/server'
export const ServerRoute = createServerFileRoute().methods({
GET: async ({ request }) => {
- setHeaders({
+ setResponseHeaders({
'Content-Type': 'text/plain',
})
return new Response('Hello, World!')
diff --git a/docs/start/framework/react/static-prerendering.md b/docs/start/framework/react/static-prerendering.md
index 995c5c4728..3f1c0048fd 100644
--- a/docs/start/framework/react/static-prerendering.md
+++ b/docs/start/framework/react/static-prerendering.md
@@ -13,6 +13,7 @@ TanStack Start can prerender your application to static HTML files, which can th
// vite.config.ts
import { tanstackStart } from '@tanstack/react-start/plugin/vite'
+import viteReact from '@vitejs/plugin-react'
export default defineConfig({
plugins: [
@@ -53,6 +54,7 @@ export default defineConfig({
},
],
}),
+ viteReact(),
],
})
```
diff --git a/docs/start/framework/react/static-server-functions.md b/docs/start/framework/react/static-server-functions.md
index 92c7adc932..79c79d6313 100644
--- a/docs/start/framework/react/static-server-functions.md
+++ b/docs/start/framework/react/static-server-functions.md
@@ -3,50 +3,31 @@ id: static-server-functions
title: Static Server Functions
---
+> [!WARNING]
+> Static Server Functions are experimental!
+
## What are Static Server Functions?
-Static server functions are server functions that are executed at build time and cached as static assets when using prerendering/static-generation. They can be set to "static" mode by passing the `type: 'static'` option to `createServerFn`:
+Static server functions are server functions that are executed at build time and cached as static assets when using prerendering/static-generation. They can be set to "static" mode by applying the `staticFunctionMiddleware` middleware to `createServerFn`:
```tsx
-const myServerFn = createServerFn({ type: 'static' }).handler(async () => {
+import { createServerFn } from '@tanstack/react-start'
+import { staticFunctionMiddleware } from '@tanstack/start-static-server-functions'
+
+const myServerFn = createServerFn({ method: 'GET' })..middleware([staticFunctionMiddleware]).handler(async () => {
return 'Hello, world!'
})
```
+Ensure that `staticFunctionMiddleware` is the final middleware!
+
This pattern goes as follows:
- Build-time
- - During build-time prerendering, a server function with `type: 'static'` is executed
+ - During build-time prerendering, a server function with `staticFunctionMiddleware` is executed
- The result is cached with your build output as a static JSON file under a derived key (function ID + params/payload hash)
- The result is returned as normal during prerendering/static-generation and used to prerender the page
- Runtime
- Initially, the prerendered page's html is served and the server function data is embedded in the html
- When the client mounts, the embedded server function data is hydrated
- For future client-side invocations, the server function is replaced with a fetch call to the static JSON file
-
-## Customizing the Server Functions Static Cache
-
-By default, the static server function cache implementation stores and retrieves static data in the build output directory via node's `fs` module and likewise fetches the data at runtime using a `fetch` call to the same static file.
-
-This interface can be customized by importing and calling the `createServerFnStaticCache` function to create a custom cache implementation and then calling `setServerFnStaticCache` to set it:
-
-```tsx
-import {
- createServerFnStaticCache,
- setServerFnStaticCache,
-} from '@tanstack/react-start/client'
-
-const myCustomStaticCache = createServerFnStaticCache({
- setItem: async (ctx, data) => {
- // Store the static data in your custom cache
- },
- getItem: async (ctx) => {
- // Retrieve the static data from your custom cache
- },
- fetchItem: async (ctx) => {
- // During runtime, fetch the static data from your custom cache
- },
-})
-
-setServerFnStaticCache(myCustomStaticCache)
-```
diff --git a/docs/start/framework/react/tailwind-integration.md b/docs/start/framework/react/tailwind-integration.md
index 90d674ca78..b57a95fb38 100644
--- a/docs/start/framework/react/tailwind-integration.md
+++ b/docs/start/framework/react/tailwind-integration.md
@@ -29,12 +29,13 @@ import { defineConfig } from 'vite'
import tsConfigPaths from 'vite-tsconfig-paths'
import { tanstackStart } from '@tanstack/react-start/plugin/vite'
import tailwindcss from '@tailwindcss/vite'
+import viteReact from '@vitejs/plugin-react'
export default defineConfig({
server: {
port: 3000,
},
- plugins: [tsConfigPaths(), tanstackStart(), tailwindcss()],
+ plugins: [tsConfigPaths(), tanstackStart(), viteReact(), tailwindcss()],
})
```
diff --git a/docs/start/framework/solid/build-from-scratch.md b/docs/start/framework/solid/build-from-scratch.md
index b83876b70a..54a6c7f8bd 100644
--- a/docs/start/framework/solid/build-from-scratch.md
+++ b/docs/start/framework/solid/build-from-scratch.md
@@ -59,7 +59,7 @@ npm i @tanstack/solid-start @tanstack/solid-router vite
You'll also need Solid:
```shell
-npm i solid-js
+npm i solid-js vite-plugin-solid
```
and some TypeScript:
@@ -85,9 +85,6 @@ We'll then update our `package.json` to use Vite's CLI and set `"type": "module"
Then configure TanStack Start's Vite plugin in `vite.config.ts`:
-> [!NOTE]
-> TanStack Start will stop auto-configuring React/Solid Vite plugins. You’ll get full control - choose `vite-plugin-solid`. Set `customViteSolidPlugin: true` to opt in to this feature right now!
-
```ts
// vite.config.ts
import { defineConfig } from 'vite'
@@ -101,7 +98,8 @@ export default defineConfig({
},
plugins: [
tsConfigPaths(),
- tanstackStart({ customViteSolidPlugin: true }),
+ tanstackStart(),
+ // solid's vite plugin must come after start's vite plugin
viteSolid({ ssr: true }),
],
})
diff --git a/docs/start/framework/solid/hosting.md b/docs/start/framework/solid/hosting.md
index f6d15dd188..b4ec6b3987 100644
--- a/docs/start/framework/solid/hosting.md
+++ b/docs/start/framework/solid/hosting.md
@@ -48,11 +48,12 @@ Set the `target` value to `netlify` in your `vite.config.ts` file.
```ts
// vite.config.ts
-import { tanstackStart } from '@tanstack/solid-start/plugin/vite'
import { defineConfig } from 'vite'
+import { tanstackStart } from '@tanstack/solid-start/plugin/vite'
+import { tanstackStart } from '@tanstack/solid-start/plugin/vite'
export default defineConfig({
- plugins: [tanstackStart({ target: 'netlify' })],
+ plugins: [tanstackStart({ target: 'netlify' }), viteSolid({ ssr: true })],
})
```
@@ -64,11 +65,12 @@ Deploying your TanStack Start application to Vercel is easy and straightforward.
```ts
// vite.config.ts
-import { tanstackStart } from '@tanstack/solid-start/plugin/vite'
import { defineConfig } from 'vite'
+import { tanstackStart } from '@tanstack/solid-start/plugin/vite'
+import viteSolid from 'vite-plugin-solid'
export default defineConfig({
- plugins: [tanstackStart({ target: 'vercel' })],
+ plugins: [tanstackStart({ target: 'vercel' }), viteSolid({ ssr: true })],
})
```
@@ -84,11 +86,15 @@ Set the `target` value to `cloudflare-pages` in your `vite.config.ts` file.
```ts
// vite.config.ts
-import { tanstackStart } from '@tanstack/solid-start/plugin/vite'
import { defineConfig } from 'vite'
+import { tanstackStart } from '@tanstack/solid-start/plugin/vite'
+import viteSolid from 'vite-plugin-solid'
export default defineConfig({
- plugins: [tanstackStart({ target: 'cloudflare-module' })],
+ plugins: [
+ tanstackStart({ target: 'cloudflare-module' }),
+ viteSolid({ ssr: true }),
+ ],
})
```
@@ -110,11 +116,12 @@ Set the `target` value to `node-server` in your `vite.config.ts` file.
```ts
// vite.config.ts
-import { tanstackStart } from '@tanstack/solid-start/plugin/vite'
import { defineConfig } from 'vite'
+import { tanstackStart } from '@tanstack/solid-start/plugin/vite'
+import viteSolid from 'vite-plugin-solid'
export default defineConfig({
- plugins: [tanstackStart({ target: 'node-server' })],
+ plugins: [tanstackStart({ target: 'node-server' }), viteSolid({ ssr: true })],
})
```
@@ -142,11 +149,12 @@ Set the `target` value to `bun` in your `vite.config.ts` file.
```ts
// vite.config.ts
-import { tanstackStart } from '@tanstack/solid-start/plugin/vite'
import { defineConfig } from 'vite'
+import { tanstackStart } from '@tanstack/solid-start/plugin/vite'
+import viteSolid from 'vite-plugin-solid'
export default defineConfig({
- plugins: [tanstackStart({ target: 'bun' })],
+ plugins: [tanstackStart({ target: 'bun' }), viteSolid({ ssr: true })],
})
```
diff --git a/docs/start/framework/solid/learn-the-basics.md b/docs/start/framework/solid/learn-the-basics.md
index a7a7d2c545..a417eacb2c 100644
--- a/docs/start/framework/solid/learn-the-basics.md
+++ b/docs/start/framework/solid/learn-the-basics.md
@@ -60,9 +60,23 @@ import {
import { createRouter } from './router'
-export default createStartHandler({
+const fetch = createStartHandler({
createRouter,
})(defaultStreamHandler)
+
+export default {
+ fetch,
+}
+```
+
+The entry point must conform to the following interface:
+
+```tsx
+export default {
+ fetch(req: Request): Promise {
+ // ...
+ },
+}
```
Whether we are statically generating our app or serving it dynamically, the `server.ts` file is the entry point for doing all SSR-related work.
diff --git a/docs/start/framework/solid/tailwind-integration.md b/docs/start/framework/solid/tailwind-integration.md
index 8e7683acbc..b4b23e57de 100644
--- a/docs/start/framework/solid/tailwind-integration.md
+++ b/docs/start/framework/solid/tailwind-integration.md
@@ -29,12 +29,18 @@ import { defineConfig } from 'vite'
import tsConfigPaths from 'vite-tsconfig-paths'
import { tanstackStart } from '@tanstack/solid-start/plugin/vite'
import tailwindcss from '@tailwindcss/vite'
+import viteSolid from 'vite-plugin-solid'
export default defineConfig({
server: {
port: 3000,
},
- plugins: [tsConfigPaths(), tanstackStart(), tailwindcss()],
+ plugins: [
+ tsConfigPaths(),
+ tanstackStart(),
+ viteSolid({ ssr: true }),
+ tailwindcss(),
+ ],
})
```
diff --git a/e2e/react-router/sentry-integration/tests/fixture.ts b/e2e/e2e-utils/src/fixture.ts
similarity index 100%
rename from e2e/react-router/sentry-integration/tests/fixture.ts
rename to e2e/e2e-utils/src/fixture.ts
diff --git a/e2e/e2e-utils/src/index.ts b/e2e/e2e-utils/src/index.ts
index 59cbb0bc62..2a4219ddcf 100644
--- a/e2e/e2e-utils/src/index.ts
+++ b/e2e/e2e-utils/src/index.ts
@@ -4,3 +4,4 @@ export { toRuntimePath } from './to-runtime-path'
export { resolveRuntimeSuffix } from './resolve-runtime-suffix'
export { e2eStartDummyServer, e2eStopDummyServer } from './e2eSetupTeardown'
export type { Post } from './posts'
+export { test } from './fixture'
diff --git a/e2e/react-router/basic-file-based-code-splitting/package.json b/e2e/react-router/basic-file-based-code-splitting/package.json
index f77929bac7..f6b16f53d8 100644
--- a/e2e/react-router/basic-file-based-code-splitting/package.json
+++ b/e2e/react-router/basic-file-based-code-splitting/package.json
@@ -29,6 +29,6 @@
"@types/react": "^19.0.8",
"@types/react-dom": "^19.0.3",
"@vitejs/plugin-react": "^4.3.4",
- "vite": "^6.3.5"
+ "vite": "^7.1.1"
}
}
diff --git a/e2e/react-router/basic-file-based/package.json b/e2e/react-router/basic-file-based/package.json
index bd25d40f69..4b528e0735 100644
--- a/e2e/react-router/basic-file-based/package.json
+++ b/e2e/react-router/basic-file-based/package.json
@@ -30,6 +30,6 @@
"@types/react-dom": "^19.0.3",
"@vitejs/plugin-react": "^4.3.4",
"combinate": "^1.1.11",
- "vite": "^6.3.5"
+ "vite": "^7.1.1"
}
}
diff --git a/e2e/react-router/basic-react-query-file-based/package.json b/e2e/react-router/basic-react-query-file-based/package.json
index d19c42b64b..07f8813421 100644
--- a/e2e/react-router/basic-react-query-file-based/package.json
+++ b/e2e/react-router/basic-react-query-file-based/package.json
@@ -30,6 +30,6 @@
"@types/react": "^19.0.8",
"@types/react-dom": "^19.0.3",
"@vitejs/plugin-react": "^4.3.4",
- "vite": "^6.3.5"
+ "vite": "^7.1.1"
}
}
diff --git a/e2e/react-router/basic-react-query/package.json b/e2e/react-router/basic-react-query/package.json
index b1d3692705..e3e11f2383 100644
--- a/e2e/react-router/basic-react-query/package.json
+++ b/e2e/react-router/basic-react-query/package.json
@@ -28,6 +28,6 @@
"@types/react": "^19.0.8",
"@types/react-dom": "^19.0.3",
"@vitejs/plugin-react": "^4.3.4",
- "vite": "^6.3.5"
+ "vite": "^7.1.1"
}
}
diff --git a/e2e/react-router/basic-scroll-restoration/package.json b/e2e/react-router/basic-scroll-restoration/package.json
index dab75904e2..e84569ebb3 100644
--- a/e2e/react-router/basic-scroll-restoration/package.json
+++ b/e2e/react-router/basic-scroll-restoration/package.json
@@ -27,6 +27,6 @@
"@types/react": "^19.0.8",
"@types/react-dom": "^19.0.3",
"@vitejs/plugin-react": "^4.3.4",
- "vite": "^6.3.5"
+ "vite": "^7.1.1"
}
}
diff --git a/e2e/react-router/basic-virtual-file-based/package.json b/e2e/react-router/basic-virtual-file-based/package.json
index ccfaa1ff49..49e8a3fe1a 100644
--- a/e2e/react-router/basic-virtual-file-based/package.json
+++ b/e2e/react-router/basic-virtual-file-based/package.json
@@ -29,6 +29,6 @@
"@types/react": "^19.0.8",
"@types/react-dom": "^19.0.3",
"@vitejs/plugin-react": "^4.3.4",
- "vite": "^6.3.5"
+ "vite": "^7.1.1"
}
}
diff --git a/e2e/react-router/basic-virtual-named-export-config-file-based/package.json b/e2e/react-router/basic-virtual-named-export-config-file-based/package.json
index cc0549be9c..74d013545f 100644
--- a/e2e/react-router/basic-virtual-named-export-config-file-based/package.json
+++ b/e2e/react-router/basic-virtual-named-export-config-file-based/package.json
@@ -29,6 +29,6 @@
"@types/react": "^19.0.8",
"@types/react-dom": "^19.0.3",
"@vitejs/plugin-react": "^4.3.4",
- "vite": "^6.3.5"
+ "vite": "^7.1.1"
}
}
diff --git a/e2e/react-router/basic/package.json b/e2e/react-router/basic/package.json
index bf74680fad..0cb559c6b9 100644
--- a/e2e/react-router/basic/package.json
+++ b/e2e/react-router/basic/package.json
@@ -26,6 +26,6 @@
"@types/react": "^19.0.8",
"@types/react-dom": "^19.0.3",
"@vitejs/plugin-react": "^4.3.4",
- "vite": "^6.3.5"
+ "vite": "^7.1.1"
}
}
diff --git a/e2e/react-router/generator-cli-only/package.json b/e2e/react-router/generator-cli-only/package.json
index 10b802ae62..08f90293f3 100644
--- a/e2e/react-router/generator-cli-only/package.json
+++ b/e2e/react-router/generator-cli-only/package.json
@@ -27,6 +27,6 @@
"@types/react": "^19.0.8",
"@types/react-dom": "^19.0.3",
"@vitejs/plugin-react": "^4.3.4",
- "vite": "^6.3.5"
+ "vite": "^7.1.1"
}
}
diff --git a/e2e/react-router/js-only-file-based/package.json b/e2e/react-router/js-only-file-based/package.json
index f8881a588a..46a351989d 100644
--- a/e2e/react-router/js-only-file-based/package.json
+++ b/e2e/react-router/js-only-file-based/package.json
@@ -27,6 +27,6 @@
"@types/react": "^19.0.8",
"@types/react-dom": "^19.0.3",
"@vitejs/plugin-react": "^4.3.4",
- "vite": "^6.3.5"
+ "vite": "^7.1.1"
}
}
diff --git a/e2e/react-router/scroll-restoration-sandbox-vite/package.json b/e2e/react-router/scroll-restoration-sandbox-vite/package.json
index 1a28218b4f..8469b9a79c 100644
--- a/e2e/react-router/scroll-restoration-sandbox-vite/package.json
+++ b/e2e/react-router/scroll-restoration-sandbox-vite/package.json
@@ -32,6 +32,6 @@
"@types/react": "^19.0.8",
"@types/react-dom": "^19.0.3",
"@vitejs/plugin-react": "^4.3.4",
- "vite": "^6.3.5"
+ "vite": "^7.1.1"
}
}
diff --git a/e2e/react-router/sentry-integration/package.json b/e2e/react-router/sentry-integration/package.json
index e653d74ffb..44fa594fa0 100644
--- a/e2e/react-router/sentry-integration/package.json
+++ b/e2e/react-router/sentry-integration/package.json
@@ -29,6 +29,6 @@
"@types/react": "^19.0.8",
"@types/react-dom": "^19.0.3",
"@vitejs/plugin-react": "^4.3.4",
- "vite": "^6.3.5"
+ "vite": "^7.1.1"
}
}
diff --git a/e2e/react-router/sentry-integration/tests/app.spec.ts b/e2e/react-router/sentry-integration/tests/app.spec.ts
index 9a3b53a966..1de2800c80 100644
--- a/e2e/react-router/sentry-integration/tests/app.spec.ts
+++ b/e2e/react-router/sentry-integration/tests/app.spec.ts
@@ -1,6 +1,5 @@
import { expect } from '@playwright/test'
-
-import { test } from './fixture'
+import { test } from '@tanstack/router-e2e-utils'
test.beforeEach(async ({ page }) => {
await page.goto('/')
diff --git a/e2e/react-start/basic-auth/package.json b/e2e/react-start/basic-auth/package.json
index f5ee14762e..4578e784a3 100644
--- a/e2e/react-start/basic-auth/package.json
+++ b/e2e/react-start/basic-auth/package.json
@@ -21,7 +21,7 @@
"react-dom": "^19.0.0",
"redaxios": "^0.5.1",
"tailwind-merge": "^2.6.0",
- "vite": "^6.3.5"
+ "vite": "^7.1.1"
},
"devDependencies": {
"@playwright/test": "^1.50.1",
diff --git a/e2e/react-start/basic-auth/vite.config.ts b/e2e/react-start/basic-auth/vite.config.ts
index 1df337cd40..dc57f144e4 100644
--- a/e2e/react-start/basic-auth/vite.config.ts
+++ b/e2e/react-start/basic-auth/vite.config.ts
@@ -1,6 +1,7 @@
import { defineConfig } from 'vite'
import tsConfigPaths from 'vite-tsconfig-paths'
import { tanstackStart } from '@tanstack/react-start/plugin/vite'
+import viteReact from '@vitejs/plugin-react'
export default defineConfig({
plugins: [
@@ -8,5 +9,6 @@ export default defineConfig({
projects: ['./tsconfig.json'],
}),
tanstackStart(),
+ viteReact(),
],
})
diff --git a/e2e/react-start/basic-react-query/package.json b/e2e/react-start/basic-react-query/package.json
index 284e0626f7..ac0c200bd6 100644
--- a/e2e/react-start/basic-react-query/package.json
+++ b/e2e/react-start/basic-react-query/package.json
@@ -7,7 +7,7 @@
"dev": "vite dev --port 3000",
"dev:e2e": "vite dev",
"build": "vite build && tsc --noEmit",
- "start": "node .output/server/index.mjs",
+ "start": "pnpx srvx --prod -s ../client dist/server/server.js",
"test:e2e": "rm -rf port*.txt; playwright test --project=chromium"
},
"dependencies": {
@@ -21,7 +21,7 @@
"react-dom": "^19.0.0",
"redaxios": "^0.5.1",
"tailwind-merge": "^2.6.0",
- "vite": "^6.3.5"
+ "vite": "^7.1.1"
},
"devDependencies": {
"@playwright/test": "^1.50.1",
@@ -32,6 +32,7 @@
"@vitejs/plugin-react": "^4.3.4",
"autoprefixer": "^10.4.20",
"postcss": "^8.5.1",
+ "srvx": "^0.8.6",
"tailwindcss": "^3.4.17",
"typescript": "^5.7.2",
"vite-tsconfig-paths": "^5.1.4"
diff --git a/e2e/react-start/basic-react-query/vite.config.ts b/e2e/react-start/basic-react-query/vite.config.ts
index 1df337cd40..dc57f144e4 100644
--- a/e2e/react-start/basic-react-query/vite.config.ts
+++ b/e2e/react-start/basic-react-query/vite.config.ts
@@ -1,6 +1,7 @@
import { defineConfig } from 'vite'
import tsConfigPaths from 'vite-tsconfig-paths'
import { tanstackStart } from '@tanstack/react-start/plugin/vite'
+import viteReact from '@vitejs/plugin-react'
export default defineConfig({
plugins: [
@@ -8,5 +9,6 @@ export default defineConfig({
projects: ['./tsconfig.json'],
}),
tanstackStart(),
+ viteReact(),
],
})
diff --git a/e2e/react-start/basic-rsc/package.json b/e2e/react-start/basic-rsc/package.json
index 9c820c9ccd..30ac070db2 100644
--- a/e2e/react-start/basic-rsc/package.json
+++ b/e2e/react-start/basic-rsc/package.json
@@ -17,7 +17,7 @@
"react-dom": "^19.0.0",
"redaxios": "^0.5.1",
"tailwind-merge": "^2.6.0",
- "vite": "^6.3.5"
+ "vite": "^7.1.1"
},
"devDependencies": {
"@types/react": "^19.0.8",
diff --git a/e2e/react-start/basic-rsc/vite.config.ts b/e2e/react-start/basic-rsc/vite.config.ts
index 1df337cd40..dc57f144e4 100644
--- a/e2e/react-start/basic-rsc/vite.config.ts
+++ b/e2e/react-start/basic-rsc/vite.config.ts
@@ -1,6 +1,7 @@
import { defineConfig } from 'vite'
import tsConfigPaths from 'vite-tsconfig-paths'
import { tanstackStart } from '@tanstack/react-start/plugin/vite'
+import viteReact from '@vitejs/plugin-react'
export default defineConfig({
plugins: [
@@ -8,5 +9,6 @@ export default defineConfig({
projects: ['./tsconfig.json'],
}),
tanstackStart(),
+ viteReact(),
],
})
diff --git a/e2e/react-start/basic-tsr-config/package.json b/e2e/react-start/basic-tsr-config/package.json
index 6e36695183..a41ed7d467 100644
--- a/e2e/react-start/basic-tsr-config/package.json
+++ b/e2e/react-start/basic-tsr-config/package.json
@@ -7,7 +7,7 @@
"dev": "vite dev --port 3000",
"dev:e2e": "vite dev",
"build": "rimraf ./count.txt && vite build && tsc --noEmit",
- "start": "node .output/server/index.mjs",
+ "start": "pnpx srvx --prod -s ../client dist/server/server.js",
"test:e2e": "rm -rf port*.txt; playwright test --project=chromium"
},
"dependencies": {
@@ -15,13 +15,14 @@
"@tanstack/react-start": "workspace:^",
"react": "^19.0.0",
"react-dom": "^19.0.0",
- "vite": "^6.3.5"
+ "vite": "^7.1.1"
},
"devDependencies": {
"@tanstack/router-e2e-utils": "workspace:^",
"@types/node": "^22.10.2",
"@types/react": "^19.0.8",
"@types/react-dom": "^19.0.3",
+ "srvx": "^0.8.6",
"typescript": "^5.7.2"
}
}
diff --git a/e2e/react-start/basic-tsr-config/tests/app.spec.ts b/e2e/react-start/basic-tsr-config/tests/app.spec.ts
index e3488df952..07a562fcb3 100644
--- a/e2e/react-start/basic-tsr-config/tests/app.spec.ts
+++ b/e2e/react-start/basic-tsr-config/tests/app.spec.ts
@@ -2,9 +2,14 @@ import { expect, test } from '@playwright/test'
test('opening the app', async ({ page }) => {
await page.goto('/')
-
- await expect(page.getByTestId('add-button')).toContainText('Add 1 to 0?')
- await page.getByTestId('add-button').click()
await page.waitForLoadState('networkidle')
- await expect(page.getByTestId('add-button')).toContainText('Add 1 to 1?')
+
+ const button = page.getByTestId('add-button')
+
+ await expect(button).toContainText('Add 1 to 0?')
+
+ await button.click()
+ await page.waitForLoadState('networkidle')
+
+ await expect(button).toContainText('Add 1 to 1?')
})
diff --git a/e2e/react-start/basic-tsr-config/vite.config.ts b/e2e/react-start/basic-tsr-config/vite.config.ts
index 69045b5a44..92aabad3ba 100644
--- a/e2e/react-start/basic-tsr-config/vite.config.ts
+++ b/e2e/react-start/basic-tsr-config/vite.config.ts
@@ -7,9 +7,7 @@ export default defineConfig({
},
plugins: [
tanstackStart({
- tsr: {
- srcDirectory: './src/app',
- },
+ srcDirectory: './src/app',
}),
],
})
diff --git a/e2e/react-start/basic/package.json b/e2e/react-start/basic/package.json
index 57309b87a4..b3f2fe4b23 100644
--- a/e2e/react-start/basic/package.json
+++ b/e2e/react-start/basic/package.json
@@ -7,7 +7,7 @@
"dev": "vite dev --port 3000",
"dev:e2e": "vite dev",
"build": "vite build && tsc --noEmit",
- "start": "node .output/server/index.mjs",
+ "start": "pnpx srvx --prod -s ../client dist/server/server.js",
"test:e2e": "rm -rf port*.txt; playwright test --project=chromium"
},
"dependencies": {
@@ -17,9 +17,7 @@
"react": "^19.0.0",
"react-dom": "^19.0.0",
"redaxios": "^0.5.1",
- "tailwind-merge": "^2.6.0",
- "vite": "6.3.5",
- "zod": "^3.24.2"
+ "tailwind-merge": "^2.6.0"
},
"devDependencies": {
"@playwright/test": "^1.50.1",
@@ -31,8 +29,11 @@
"autoprefixer": "^10.4.20",
"combinate": "^1.1.11",
"postcss": "^8.5.1",
+ "srvx": "^0.8.6",
"tailwindcss": "^3.4.17",
"typescript": "^5.7.2",
- "vite-tsconfig-paths": "^5.1.4"
+ "vite": "^7.1.1",
+ "vite-tsconfig-paths": "^5.1.4",
+ "zod": "^3.24.2"
}
}
diff --git a/e2e/react-start/basic/src/server.ts b/e2e/react-start/basic/src/server.ts
index 77cb4a1316..3ce20fd461 100644
--- a/e2e/react-start/basic/src/server.ts
+++ b/e2e/react-start/basic/src/server.ts
@@ -8,6 +8,10 @@ import { createRouter } from './router'
console.log("[server-entry]: using custom server entry in 'src/server.ts'")
-export default createStartHandler({
+const fetch = createStartHandler({
createRouter,
})(defaultStreamHandler)
+
+export default {
+ fetch,
+}
diff --git a/e2e/react-start/basic/tests/fixture.ts b/e2e/react-start/basic/tests/fixture.ts
deleted file mode 100644
index abb7b1d564..0000000000
--- a/e2e/react-start/basic/tests/fixture.ts
+++ /dev/null
@@ -1,28 +0,0 @@
-import { test as base, expect } from '@playwright/test'
-
-export interface TestFixtureOptions {
- whitelistErrors: Array
-}
-export const test = base.extend({
- whitelistErrors: [[], { option: true }],
- page: async ({ page, whitelistErrors }, use) => {
- const errorMessages: Array = []
- page.on('console', (m) => {
- if (m.type() === 'error') {
- const text = m.text()
- for (const whitelistError of whitelistErrors) {
- if (
- (typeof whitelistError === 'string' &&
- text.includes(whitelistError)) ||
- (whitelistError instanceof RegExp && whitelistError.test(text))
- ) {
- return
- }
- }
- errorMessages.push(text)
- }
- })
- await use(page)
- expect(errorMessages).toEqual([])
- },
-})
diff --git a/e2e/react-start/basic/tests/navigation.spec.ts b/e2e/react-start/basic/tests/navigation.spec.ts
index 5d21f2adbe..6ecc900716 100644
--- a/e2e/react-start/basic/tests/navigation.spec.ts
+++ b/e2e/react-start/basic/tests/navigation.spec.ts
@@ -1,5 +1,12 @@
-import { expect, test } from '@playwright/test'
+import { expect } from '@playwright/test'
+import { test } from '@tanstack/router-e2e-utils'
+
+test.use({
+ whitelistErrors: [
+ /Failed to load resource: the server responded with a status of 404/,
+ ],
+})
test('Navigating to post', async ({ page }) => {
await page.goto('/')
diff --git a/e2e/react-start/basic/tests/not-found.spec.ts b/e2e/react-start/basic/tests/not-found.spec.ts
index 0d83ab5280..ab1c94eee9 100644
--- a/e2e/react-start/basic/tests/not-found.spec.ts
+++ b/e2e/react-start/basic/tests/not-found.spec.ts
@@ -1,6 +1,6 @@
import { expect } from '@playwright/test'
import combinateImport from 'combinate'
-import { test } from './fixture'
+import { test } from '@tanstack/router-e2e-utils'
// somehow playwright does not correctly import default exports
const combinate = (combinateImport as any).default as typeof combinateImport
diff --git a/e2e/react-start/basic/tests/params.spec.ts b/e2e/react-start/basic/tests/params.spec.ts
index b22c3e2655..737c82f35d 100644
--- a/e2e/react-start/basic/tests/params.spec.ts
+++ b/e2e/react-start/basic/tests/params.spec.ts
@@ -1,9 +1,16 @@
-import { expect, test } from '@playwright/test'
+import { expect } from '@playwright/test'
+
+import { test } from '@tanstack/router-e2e-utils'
test.beforeEach(async ({ page }) => {
await page.goto('/')
})
+test.use({
+ whitelistErrors: [
+ /Failed to load resource: the server responded with a status of 404/,
+ ],
+})
test.describe('Unicode route rendering', () => {
test('should render non-latin route correctly', async ({ page, baseURL }) => {
await page.goto('/대한민국')
diff --git a/e2e/react-start/basic/tests/redirect.spec.ts b/e2e/react-start/basic/tests/redirect.spec.ts
index 87e93a42e6..78c57d6a00 100644
--- a/e2e/react-start/basic/tests/redirect.spec.ts
+++ b/e2e/react-start/basic/tests/redirect.spec.ts
@@ -4,9 +4,9 @@ import combinateImport from 'combinate'
import {
getDummyServerPort,
getTestServerPort,
+ test,
} from '@tanstack/router-e2e-utils'
import packageJson from '../package.json' with { type: 'json' }
-import { test } from './fixture'
// somehow playwright does not correctly import default exports
const combinate = (combinateImport as any).default as typeof combinateImport
@@ -184,6 +184,8 @@ test.describe('redirects', () => {
await page.goto(`/redirect/${target}/serverFn/via-useServerFn?${q}`)
+ await page.waitForLoadState('networkidle')
+
const button = page.getByTestId('redirect-on-click')
let fullPageLoad = false
diff --git a/e2e/react-start/basic/tests/search-params.spec.ts b/e2e/react-start/basic/tests/search-params.spec.ts
index 23cd97517d..d7ce617890 100644
--- a/e2e/react-start/basic/tests/search-params.spec.ts
+++ b/e2e/react-start/basic/tests/search-params.spec.ts
@@ -1,5 +1,5 @@
import { expect } from '@playwright/test'
-import { test } from './fixture'
+import { test } from '@tanstack/router-e2e-utils'
import type { Response } from '@playwright/test'
function expectRedirect(response: Response | null, endsWith: string) {
diff --git a/e2e/react-start/basic/tests/streaming.spec.ts b/e2e/react-start/basic/tests/streaming.spec.ts
index 252bb192aa..15f60b7deb 100644
--- a/e2e/react-start/basic/tests/streaming.spec.ts
+++ b/e2e/react-start/basic/tests/streaming.spec.ts
@@ -1,4 +1,5 @@
-import { expect, test } from '@playwright/test'
+import { expect } from '@playwright/test'
+import { test } from '@tanstack/router-e2e-utils'
test('Navigating to deferred route', async ({ page }) => {
await page.goto('/')
diff --git a/e2e/react-start/basic/vite.config.ts b/e2e/react-start/basic/vite.config.ts
index 5443069826..4124c73694 100644
--- a/e2e/react-start/basic/vite.config.ts
+++ b/e2e/react-start/basic/vite.config.ts
@@ -1,6 +1,7 @@
import { defineConfig } from 'vite'
import tsConfigPaths from 'vite-tsconfig-paths'
import { tanstackStart } from '@tanstack/react-start/plugin/vite'
+import viteReact from '@vitejs/plugin-react'
export default defineConfig({
server: {
@@ -10,6 +11,7 @@ export default defineConfig({
tsConfigPaths({
projects: ['./tsconfig.json'],
}),
- tanstackStart({ tsr: { verboseFileRoutes: false } }),
+ tanstackStart({ router: { verboseFileRoutes: false } }),
+ viteReact(),
],
})
diff --git a/e2e/react-start/clerk-basic/package.disabled.json b/e2e/react-start/clerk-basic/package.disabled.json
index d819677f46..43d26930a6 100644
--- a/e2e/react-start/clerk-basic/package.disabled.json
+++ b/e2e/react-start/clerk-basic/package.disabled.json
@@ -11,7 +11,7 @@
"test:e2e": "exit 0; rm -rf port*.txt; playwright test --project=chromium"
},
"dependencies": {
- "@clerk/tanstack-react-start": "^0.12.0",
+ "@clerk/tanstack-react-start": "^0.19.0",
"@tanstack/react-router": "workspace:^",
"@tanstack/react-router-devtools": "workspace:^",
"@tanstack/react-start": "workspace:^",
@@ -19,7 +19,7 @@
"react-dom": "^19.0.0",
"redaxios": "^0.5.1",
"tailwind-merge": "^2.6.0",
- "vite": "^6.3.5"
+ "vite": "^7.1.1"
},
"devDependencies": {
"@playwright/test": "^1.50.1",
diff --git a/e2e/react-start/clerk-basic/src/routeTree.gen.ts b/e2e/react-start/clerk-basic/src/routeTree.gen.ts
index 00f53c8623..8ac0e6e8c3 100644
--- a/e2e/react-start/clerk-basic/src/routeTree.gen.ts
+++ b/e2e/react-start/clerk-basic/src/routeTree.gen.ts
@@ -8,11 +8,7 @@
// You should NOT make any changes in this file as it will be overwritten.
// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified.
-import type { CreateFileRoute, FileRoutesByPath } from '@tanstack/react-router'
-
-// Import Routes
-
-import { Route as rootRoute } from './routes/__root'
+import { Route as rootRouteImport } from './routes/__root'
import { Route as AuthedRouteImport } from './routes/_authed'
import { Route as IndexRouteImport } from './routes/index'
import { Route as AuthedPostsRouteImport } from './routes/_authed/posts'
@@ -20,151 +16,125 @@ import { Route as AuthedPostsIndexRouteImport } from './routes/_authed/posts.ind
import { Route as AuthedProfileSplatRouteImport } from './routes/_authed/profile.$'
import { Route as AuthedPostsPostIdRouteImport } from './routes/_authed/posts.$postId'
-// Create/Update Routes
-
const AuthedRoute = AuthedRouteImport.update({
id: '/_authed',
- getParentRoute: () => rootRoute,
+ getParentRoute: () => rootRouteImport,
} as any)
-
const IndexRoute = IndexRouteImport.update({
id: '/',
path: '/',
- getParentRoute: () => rootRoute,
+ getParentRoute: () => rootRouteImport,
} as any)
-
const AuthedPostsRoute = AuthedPostsRouteImport.update({
id: '/posts',
path: '/posts',
getParentRoute: () => AuthedRoute,
} as any)
-
const AuthedPostsIndexRoute = AuthedPostsIndexRouteImport.update({
id: '/',
path: '/',
getParentRoute: () => AuthedPostsRoute,
} as any)
-
const AuthedProfileSplatRoute = AuthedProfileSplatRouteImport.update({
id: '/profile/$',
path: '/profile/$',
getParentRoute: () => AuthedRoute,
} as any)
-
const AuthedPostsPostIdRoute = AuthedPostsPostIdRouteImport.update({
id: '/$postId',
path: '/$postId',
getParentRoute: () => AuthedPostsRoute,
} as any)
-// Populate the FileRoutesByPath interface
+export interface FileRoutesByFullPath {
+ '/': typeof IndexRoute
+ '/posts': typeof AuthedPostsRouteWithChildren
+ '/posts/$postId': typeof AuthedPostsPostIdRoute
+ '/profile/$': typeof AuthedProfileSplatRoute
+ '/posts/': typeof AuthedPostsIndexRoute
+}
+export interface FileRoutesByTo {
+ '/': typeof IndexRoute
+ '/posts/$postId': typeof AuthedPostsPostIdRoute
+ '/profile/$': typeof AuthedProfileSplatRoute
+ '/posts': typeof AuthedPostsIndexRoute
+}
+export interface FileRoutesById {
+ __root__: typeof rootRouteImport
+ '/': typeof IndexRoute
+ '/_authed': typeof AuthedRouteWithChildren
+ '/_authed/posts': typeof AuthedPostsRouteWithChildren
+ '/_authed/posts/$postId': typeof AuthedPostsPostIdRoute
+ '/_authed/profile/$': typeof AuthedProfileSplatRoute
+ '/_authed/posts/': typeof AuthedPostsIndexRoute
+}
+export interface FileRouteTypes {
+ fileRoutesByFullPath: FileRoutesByFullPath
+ fullPaths: '/' | '/posts' | '/posts/$postId' | '/profile/$' | '/posts/'
+ fileRoutesByTo: FileRoutesByTo
+ to: '/' | '/posts/$postId' | '/profile/$' | '/posts'
+ id:
+ | '__root__'
+ | '/'
+ | '/_authed'
+ | '/_authed/posts'
+ | '/_authed/posts/$postId'
+ | '/_authed/profile/$'
+ | '/_authed/posts/'
+ fileRoutesById: FileRoutesById
+}
+export interface RootRouteChildren {
+ IndexRoute: typeof IndexRoute
+ AuthedRoute: typeof AuthedRouteWithChildren
+}
declare module '@tanstack/react-router' {
interface FileRoutesByPath {
- '/': {
- id: '/'
- path: '/'
- fullPath: '/'
- preLoaderRoute: typeof IndexRouteImport
- parentRoute: typeof rootRoute
- }
'/_authed': {
id: '/_authed'
path: ''
fullPath: ''
preLoaderRoute: typeof AuthedRouteImport
- parentRoute: typeof rootRoute
+ parentRoute: typeof rootRouteImport
+ }
+ '/': {
+ id: '/'
+ path: '/'
+ fullPath: '/'
+ preLoaderRoute: typeof IndexRouteImport
+ parentRoute: typeof rootRouteImport
}
'/_authed/posts': {
id: '/_authed/posts'
path: '/posts'
fullPath: '/posts'
preLoaderRoute: typeof AuthedPostsRouteImport
- parentRoute: typeof AuthedRouteImport
- }
- '/_authed/posts/$postId': {
- id: '/_authed/posts/$postId'
- path: '/$postId'
- fullPath: '/posts/$postId'
- preLoaderRoute: typeof AuthedPostsPostIdRouteImport
- parentRoute: typeof AuthedPostsRouteImport
- }
- '/_authed/profile/$': {
- id: '/_authed/profile/$'
- path: '/profile/$'
- fullPath: '/profile/$'
- preLoaderRoute: typeof AuthedProfileSplatRouteImport
- parentRoute: typeof AuthedRouteImport
+ parentRoute: typeof AuthedRoute
}
'/_authed/posts/': {
id: '/_authed/posts/'
path: '/'
fullPath: '/posts/'
preLoaderRoute: typeof AuthedPostsIndexRouteImport
- parentRoute: typeof AuthedPostsRouteImport
+ parentRoute: typeof AuthedPostsRoute
+ }
+ '/_authed/profile/$': {
+ id: '/_authed/profile/$'
+ path: '/profile/$'
+ fullPath: '/profile/$'
+ preLoaderRoute: typeof AuthedProfileSplatRouteImport
+ parentRoute: typeof AuthedRoute
+ }
+ '/_authed/posts/$postId': {
+ id: '/_authed/posts/$postId'
+ path: '/$postId'
+ fullPath: '/posts/$postId'
+ preLoaderRoute: typeof AuthedPostsPostIdRouteImport
+ parentRoute: typeof AuthedPostsRoute
}
}
}
-// Add type-safety to the createFileRoute function across the route tree
-
-declare module './routes/index' {
- const createFileRoute: CreateFileRoute<
- '/',
- FileRoutesByPath['/']['parentRoute'],
- FileRoutesByPath['/']['id'],
- FileRoutesByPath['/']['path'],
- FileRoutesByPath['/']['fullPath']
- >
-}
-declare module './routes/_authed' {
- const createFileRoute: CreateFileRoute<
- '/_authed',
- FileRoutesByPath['/_authed']['parentRoute'],
- FileRoutesByPath['/_authed']['id'],
- FileRoutesByPath['/_authed']['path'],
- FileRoutesByPath['/_authed']['fullPath']
- >
-}
-declare module './routes/_authed/posts' {
- const createFileRoute: CreateFileRoute<
- '/_authed/posts',
- FileRoutesByPath['/_authed/posts']['parentRoute'],
- FileRoutesByPath['/_authed/posts']['id'],
- FileRoutesByPath['/_authed/posts']['path'],
- FileRoutesByPath['/_authed/posts']['fullPath']
- >
-}
-declare module './routes/_authed/posts.$postId' {
- const createFileRoute: CreateFileRoute<
- '/_authed/posts/$postId',
- FileRoutesByPath['/_authed/posts/$postId']['parentRoute'],
- FileRoutesByPath['/_authed/posts/$postId']['id'],
- FileRoutesByPath['/_authed/posts/$postId']['path'],
- FileRoutesByPath['/_authed/posts/$postId']['fullPath']
- >
-}
-declare module './routes/_authed/profile.$' {
- const createFileRoute: CreateFileRoute<
- '/_authed/profile/$',
- FileRoutesByPath['/_authed/profile/$']['parentRoute'],
- FileRoutesByPath['/_authed/profile/$']['id'],
- FileRoutesByPath['/_authed/profile/$']['path'],
- FileRoutesByPath['/_authed/profile/$']['fullPath']
- >
-}
-declare module './routes/_authed/posts.index' {
- const createFileRoute: CreateFileRoute<
- '/_authed/posts/',
- FileRoutesByPath['/_authed/posts/']['parentRoute'],
- FileRoutesByPath['/_authed/posts/']['id'],
- FileRoutesByPath['/_authed/posts/']['path'],
- FileRoutesByPath['/_authed/posts/']['fullPath']
- >
-}
-
-// Create and export the route tree
-
interface AuthedPostsRouteChildren {
AuthedPostsPostIdRoute: typeof AuthedPostsPostIdRoute
AuthedPostsIndexRoute: typeof AuthedPostsIndexRoute
@@ -192,103 +162,10 @@ const AuthedRouteChildren: AuthedRouteChildren = {
const AuthedRouteWithChildren =
AuthedRoute._addFileChildren(AuthedRouteChildren)
-export interface FileRoutesByFullPath {
- '/': typeof IndexRoute
- '': typeof AuthedRouteWithChildren
- '/posts': typeof AuthedPostsRouteWithChildren
- '/posts/$postId': typeof AuthedPostsPostIdRoute
- '/profile/$': typeof AuthedProfileSplatRoute
- '/posts/': typeof AuthedPostsIndexRoute
-}
-
-export interface FileRoutesByTo {
- '/': typeof IndexRoute
- '': typeof AuthedRouteWithChildren
- '/posts/$postId': typeof AuthedPostsPostIdRoute
- '/profile/$': typeof AuthedProfileSplatRoute
- '/posts': typeof AuthedPostsIndexRoute
-}
-
-export interface FileRoutesById {
- __root__: typeof rootRoute
- '/': typeof IndexRoute
- '/_authed': typeof AuthedRouteWithChildren
- '/_authed/posts': typeof AuthedPostsRouteWithChildren
- '/_authed/posts/$postId': typeof AuthedPostsPostIdRoute
- '/_authed/profile/$': typeof AuthedProfileSplatRoute
- '/_authed/posts/': typeof AuthedPostsIndexRoute
-}
-
-export interface FileRouteTypes {
- fileRoutesByFullPath: FileRoutesByFullPath
- fullPaths: '/' | '' | '/posts' | '/posts/$postId' | '/profile/$' | '/posts/'
- fileRoutesByTo: FileRoutesByTo
- to: '/' | '' | '/posts/$postId' | '/profile/$' | '/posts'
- id:
- | '__root__'
- | '/'
- | '/_authed'
- | '/_authed/posts'
- | '/_authed/posts/$postId'
- | '/_authed/profile/$'
- | '/_authed/posts/'
- fileRoutesById: FileRoutesById
-}
-
-export interface RootRouteChildren {
- IndexRoute: typeof IndexRoute
- AuthedRoute: typeof AuthedRouteWithChildren
-}
-
const rootRouteChildren: RootRouteChildren = {
IndexRoute: IndexRoute,
AuthedRoute: AuthedRouteWithChildren,
}
-
-export const routeTree = rootRoute
+export const routeTree = rootRouteImport
._addFileChildren(rootRouteChildren)
._addFileTypes()
-
-/* ROUTE_MANIFEST_START
-{
- "routes": {
- "__root__": {
- "filePath": "__root.tsx",
- "children": [
- "/",
- "/_authed"
- ]
- },
- "/": {
- "filePath": "index.tsx"
- },
- "/_authed": {
- "filePath": "_authed.tsx",
- "children": [
- "/_authed/posts",
- "/_authed/profile/$"
- ]
- },
- "/_authed/posts": {
- "filePath": "_authed/posts.tsx",
- "parent": "/_authed",
- "children": [
- "/_authed/posts/$postId",
- "/_authed/posts/"
- ]
- },
- "/_authed/posts/$postId": {
- "filePath": "_authed/posts.$postId.tsx",
- "parent": "/_authed/posts"
- },
- "/_authed/profile/$": {
- "filePath": "_authed/profile.$.tsx",
- "parent": "/_authed"
- },
- "/_authed/posts/": {
- "filePath": "_authed/posts.index.tsx",
- "parent": "/_authed/posts"
- }
- }
-}
-ROUTE_MANIFEST_END */
diff --git a/e2e/react-start/clerk-basic/src/routes/__root.tsx b/e2e/react-start/clerk-basic/src/routes/__root.tsx
index 51f8705b28..f2a475c95f 100644
--- a/e2e/react-start/clerk-basic/src/routes/__root.tsx
+++ b/e2e/react-start/clerk-basic/src/routes/__root.tsx
@@ -17,13 +17,13 @@ import { TanStackRouterDevtools } from '@tanstack/react-router-devtools'
import { createServerFn } from '@tanstack/react-start'
import * as React from 'react'
import { getAuth } from '@clerk/tanstack-react-start/server'
-import { getWebRequest } from '@tanstack/react-start/server'
+import { getRequest } from '@tanstack/react-start/server'
import { DefaultCatchBoundary } from '~/components/DefaultCatchBoundary.js'
import { NotFound } from '~/components/NotFound.js'
import appCss from '~/styles/app.css?url'
const fetchClerkAuth = createServerFn({ method: 'GET' }).handler(async () => {
- const user = await getAuth(getWebRequest()!)
+ const user = await getAuth(getRequest()!)
return {
user,
diff --git a/e2e/react-start/clerk-basic/src/routes/_authed.tsx b/e2e/react-start/clerk-basic/src/routes/_authed.tsx
index 6242975272..226ae0829f 100644
--- a/e2e/react-start/clerk-basic/src/routes/_authed.tsx
+++ b/e2e/react-start/clerk-basic/src/routes/_authed.tsx
@@ -1,6 +1,7 @@
+import { createFileRoute } from '@tanstack/react-router'
import { SignIn } from '@clerk/tanstack-react-start'
-export const Route = createFileRoute({
+export const Route = createFileRoute('/_authed')({
beforeLoad: ({ context }) => {
if (!context.user.userId) {
throw new Error('Not authenticated')
diff --git a/e2e/react-start/clerk-basic/src/routes/_authed/posts.$postId.tsx b/e2e/react-start/clerk-basic/src/routes/_authed/posts.$postId.tsx
index 49cad9b374..27296b9658 100644
--- a/e2e/react-start/clerk-basic/src/routes/_authed/posts.$postId.tsx
+++ b/e2e/react-start/clerk-basic/src/routes/_authed/posts.$postId.tsx
@@ -1,10 +1,10 @@
-import { ErrorComponent } from '@tanstack/react-router'
+import { ErrorComponent, createFileRoute } from '@tanstack/react-router'
import type { ErrorComponentProps } from '@tanstack/react-router'
import { NotFound } from '~/components/NotFound.js'
import { fetchPost } from '~/utils/posts.js'
-export const Route = createFileRoute({
+export const Route = createFileRoute('/_authed/posts/$postId')({
loader: ({ params: { postId } }) => fetchPost({ data: postId }),
errorComponent: PostErrorComponent,
component: PostComponent,
diff --git a/e2e/react-start/clerk-basic/src/routes/_authed/posts.index.tsx b/e2e/react-start/clerk-basic/src/routes/_authed/posts.index.tsx
index 13529228bb..de01fe5dde 100644
--- a/e2e/react-start/clerk-basic/src/routes/_authed/posts.index.tsx
+++ b/e2e/react-start/clerk-basic/src/routes/_authed/posts.index.tsx
@@ -1,4 +1,5 @@
-export const Route = createFileRoute({
+import { createFileRoute } from '@tanstack/react-router'
+export const Route = createFileRoute('/_authed/posts/')({
component: PostsIndexComponent,
})
diff --git a/e2e/react-start/clerk-basic/src/routes/_authed/posts.tsx b/e2e/react-start/clerk-basic/src/routes/_authed/posts.tsx
index 6c37957e8c..c01f12c49a 100644
--- a/e2e/react-start/clerk-basic/src/routes/_authed/posts.tsx
+++ b/e2e/react-start/clerk-basic/src/routes/_authed/posts.tsx
@@ -1,8 +1,8 @@
-import { Link, Outlet } from '@tanstack/react-router'
+import { Link, Outlet, createFileRoute } from '@tanstack/react-router'
import { fetchPosts } from '~/utils/posts.js'
-export const Route = createFileRoute({
+export const Route = createFileRoute('/_authed/posts')({
loader: () => fetchPosts(),
component: PostsComponent,
})
diff --git a/e2e/react-start/clerk-basic/src/routes/_authed/profile.$.tsx b/e2e/react-start/clerk-basic/src/routes/_authed/profile.$.tsx
index 6c37957e8c..1e5a8b1429 100644
--- a/e2e/react-start/clerk-basic/src/routes/_authed/profile.$.tsx
+++ b/e2e/react-start/clerk-basic/src/routes/_authed/profile.$.tsx
@@ -1,8 +1,8 @@
-import { Link, Outlet } from '@tanstack/react-router'
+import { Link, Outlet, createFileRoute } from '@tanstack/react-router'
import { fetchPosts } from '~/utils/posts.js'
-export const Route = createFileRoute({
+export const Route = createFileRoute('/_authed/profile/$')({
loader: () => fetchPosts(),
component: PostsComponent,
})
diff --git a/e2e/react-start/clerk-basic/src/routes/index.tsx b/e2e/react-start/clerk-basic/src/routes/index.tsx
index 66baf1e9f1..00ce18725b 100644
--- a/e2e/react-start/clerk-basic/src/routes/index.tsx
+++ b/e2e/react-start/clerk-basic/src/routes/index.tsx
@@ -1,4 +1,5 @@
-export const Route = createFileRoute({
+import { createFileRoute } from '@tanstack/react-router'
+export const Route = createFileRoute('/')({
component: Home,
})
diff --git a/e2e/react-start/clerk-basic/src/server.ts b/e2e/react-start/clerk-basic/src/server.ts
new file mode 100644
index 0000000000..39afb5c85f
--- /dev/null
+++ b/e2e/react-start/clerk-basic/src/server.ts
@@ -0,0 +1,15 @@
+import {
+ createStartHandler,
+ defaultStreamHandler,
+} from '@tanstack/react-start/server'
+import { createClerkHandler } from '@clerk/tanstack-react-start/server'
+import { createRouter } from './router'
+
+const startHandler = createStartHandler({
+ createRouter,
+})
+const fetch = createClerkHandler(startHandler)(defaultStreamHandler)
+
+export default {
+ fetch,
+}
diff --git a/e2e/react-start/clerk-basic/src/server.tsx b/e2e/react-start/clerk-basic/src/server.tsx
deleted file mode 100644
index 2987216e24..0000000000
--- a/e2e/react-start/clerk-basic/src/server.tsx
+++ /dev/null
@@ -1,18 +0,0 @@
-import {
- createStartHandler,
- defaultStreamHandler,
- defineEventHandler,
-} from '@tanstack/react-start/server'
-import { createClerkHandler } from '@clerk/tanstack-react-start/server'
-import { createRouter } from './router'
-
-export default defineEventHandler((event) => {
- const startHandler = createStartHandler({
- createRouter,
- })
-
- const withClerkHandler =
- createClerkHandler(startHandler)(defaultStreamHandler)
-
- return withClerkHandler(event)
-})
diff --git a/e2e/react-start/clerk-basic/vite.config.ts b/e2e/react-start/clerk-basic/vite.config.ts
index 1df337cd40..dc57f144e4 100644
--- a/e2e/react-start/clerk-basic/vite.config.ts
+++ b/e2e/react-start/clerk-basic/vite.config.ts
@@ -1,6 +1,7 @@
import { defineConfig } from 'vite'
import tsConfigPaths from 'vite-tsconfig-paths'
import { tanstackStart } from '@tanstack/react-start/plugin/vite'
+import viteReact from '@vitejs/plugin-react'
export default defineConfig({
plugins: [
@@ -8,5 +9,6 @@ export default defineConfig({
projects: ['./tsconfig.json'],
}),
tanstackStart(),
+ viteReact(),
],
})
diff --git a/e2e/react-start/custom-basepath/express-server.ts b/e2e/react-start/custom-basepath/express-server.ts
new file mode 100644
index 0000000000..6fa802e447
--- /dev/null
+++ b/e2e/react-start/custom-basepath/express-server.ts
@@ -0,0 +1,44 @@
+import express from 'express'
+import { toNodeHandler } from 'srvx/node'
+
+const DEVELOPMENT = process.env.NODE_ENV === 'development'
+const PORT = Number.parseInt(process.env.PORT || '3000')
+
+const app = express()
+
+if (DEVELOPMENT) {
+ const viteDevServer = await import('vite').then((vite) =>
+ vite.createServer({
+ server: { middlewareMode: true },
+ }),
+ )
+ app.use(viteDevServer.middlewares)
+ app.use(async (req, res, next) => {
+ try {
+ const { default: serverEntry } =
+ await viteDevServer.ssrLoadModule('./src/server.ts')
+ const handler = toNodeHandler(serverEntry.fetch)
+ await handler(req, res)
+ } catch (error) {
+ if (typeof error === 'object' && error instanceof Error) {
+ viteDevServer.ssrFixStacktrace(error)
+ }
+ next(error)
+ }
+ })
+} else {
+ const { default: handler } = await import('./dist/server/server.js')
+ const nodeHandler = toNodeHandler(handler.fetch)
+ app.use('/custom/basepath', express.static('dist/client'))
+ app.use(async (req, res, next) => {
+ try {
+ await nodeHandler(req, res)
+ } catch (error) {
+ next(error)
+ }
+ })
+}
+
+app.listen(PORT, () => {
+ console.log(`Server is running on http://localhost:${PORT}`)
+})
diff --git a/e2e/react-start/custom-basepath/package.json b/e2e/react-start/custom-basepath/package.json
index ef1a13b2c6..9a89b00d26 100644
--- a/e2e/react-start/custom-basepath/package.json
+++ b/e2e/react-start/custom-basepath/package.json
@@ -4,35 +4,36 @@
"sideEffects": false,
"type": "module",
"scripts": {
- "dev": "vite dev --port 3000",
- "dev:e2e": "vite dev",
+ "dev": "cross-env NODE_ENV=development tsx express-server.ts",
"build": "vite build && tsc --noEmit",
- "start": "node .output/server/index.mjs",
+ "start": "tsx express-server.ts",
"test:e2e": "rm -rf port*.txt; playwright test --project=chromium"
},
"dependencies": {
"@tanstack/react-router": "workspace:^",
"@tanstack/react-router-devtools": "workspace:^",
"@tanstack/react-start": "workspace:^",
+ "express": "^4.21.2",
"react": "^19.0.0",
"react-dom": "^19.0.0",
- "redaxios": "^0.5.1",
- "tailwind-merge": "^2.6.0",
- "vite": "6.3.5",
- "zod": "^3.24.2"
+ "redaxios": "^0.5.1"
},
"devDependencies": {
"@playwright/test": "^1.50.1",
"@tanstack/router-e2e-utils": "workspace:^",
+ "@types/express": "^5.0.3",
"@types/node": "^22.10.2",
"@types/react": "^19.0.8",
"@types/react-dom": "^19.0.3",
"@vitejs/plugin-react": "^4.3.4",
"autoprefixer": "^10.4.20",
- "combinate": "^1.1.11",
+ "cross-env": "^10.0.0",
"postcss": "^8.5.1",
+ "srvx": "^0.8.6",
"tailwindcss": "^3.4.17",
+ "tsx": "^4.20.3",
"typescript": "^5.7.2",
+ "vite": "^7.1.1",
"vite-tsconfig-paths": "^5.1.4"
}
}
diff --git a/e2e/react-start/custom-basepath/src/server.ts b/e2e/react-start/custom-basepath/src/server.ts
new file mode 100644
index 0000000000..1d97780586
--- /dev/null
+++ b/e2e/react-start/custom-basepath/src/server.ts
@@ -0,0 +1,14 @@
+import {
+ createStartHandler,
+ defaultStreamHandler,
+} from '@tanstack/react-start/server'
+
+import { createRouter } from './router'
+
+const fetch = createStartHandler({
+ createRouter,
+})(defaultStreamHandler)
+
+export default {
+ fetch,
+}
diff --git a/e2e/react-start/custom-basepath/vite.config.ts b/e2e/react-start/custom-basepath/vite.config.ts
index c304ad647b..7e200dc074 100644
--- a/e2e/react-start/custom-basepath/vite.config.ts
+++ b/e2e/react-start/custom-basepath/vite.config.ts
@@ -1,6 +1,7 @@
import { defineConfig } from 'vite'
import tsConfigPaths from 'vite-tsconfig-paths'
import { tanstackStart } from '@tanstack/react-start/plugin/vite'
+import viteReact from '@vitejs/plugin-react'
export default defineConfig({
base: '/custom/basepath',
@@ -11,6 +12,9 @@ export default defineConfig({
tsConfigPaths({
projects: ['./tsconfig.json'],
}),
- tanstackStart(),
+ tanstackStart({
+ vite: { installDevServerMiddleware: true },
+ }),
+ viteReact(),
],
})
diff --git a/e2e/react-start/query-integration/package.json b/e2e/react-start/query-integration/package.json
index 7916c849f6..34080d78bf 100644
--- a/e2e/react-start/query-integration/package.json
+++ b/e2e/react-start/query-integration/package.json
@@ -7,7 +7,7 @@
"dev": "vite dev --port 3000",
"dev:e2e": "vite dev",
"build": "vite build && tsc --noEmit",
- "start": "node .output/server/index.mjs",
+ "start": "pnpx srvx --prod -s ../client dist/server/server.js",
"test:e2e": "rm -rf port*.txt; playwright test --project=chromium"
},
"dependencies": {
diff --git a/e2e/react-start/query-integration/tests/app.spec.ts b/e2e/react-start/query-integration/tests/app.spec.ts
index 5c78722d20..b55f0db801 100644
--- a/e2e/react-start/query-integration/tests/app.spec.ts
+++ b/e2e/react-start/query-integration/tests/app.spec.ts
@@ -1,5 +1,5 @@
import { expect } from '@playwright/test'
-import { test } from './fixture'
+import { test } from '@tanstack/router-e2e-utils'
// if the query would not be streamed to the client, it would re-execute on the client
// and thus cause a hydration mismatch since the query function returns 'client' when executed on the client
diff --git a/e2e/react-start/query-integration/tests/fixture.ts b/e2e/react-start/query-integration/tests/fixture.ts
deleted file mode 100644
index abb7b1d564..0000000000
--- a/e2e/react-start/query-integration/tests/fixture.ts
+++ /dev/null
@@ -1,28 +0,0 @@
-import { test as base, expect } from '@playwright/test'
-
-export interface TestFixtureOptions {
- whitelistErrors: Array
-}
-export const test = base.extend({
- whitelistErrors: [[], { option: true }],
- page: async ({ page, whitelistErrors }, use) => {
- const errorMessages: Array = []
- page.on('console', (m) => {
- if (m.type() === 'error') {
- const text = m.text()
- for (const whitelistError of whitelistErrors) {
- if (
- (typeof whitelistError === 'string' &&
- text.includes(whitelistError)) ||
- (whitelistError instanceof RegExp && whitelistError.test(text))
- ) {
- return
- }
- }
- errorMessages.push(text)
- }
- })
- await use(page)
- expect(errorMessages).toEqual([])
- },
-})
diff --git a/e2e/react-start/scroll-restoration/package.json b/e2e/react-start/scroll-restoration/package.json
index 6f9393c929..f4b18512c1 100644
--- a/e2e/react-start/scroll-restoration/package.json
+++ b/e2e/react-start/scroll-restoration/package.json
@@ -7,7 +7,7 @@
"dev": "vite dev --port 3000",
"dev:e2e": "vite dev",
"build": "vite build && tsc --noEmit",
- "start": "node .output/server/index.mjs",
+ "start": "pnpx srvx --prod -s ../client dist/server/server.js",
"test:e2e": "rm -rf port*.txt; playwright test --project=chromium"
},
"dependencies": {
@@ -19,7 +19,7 @@
"react-dom": "^19.0.0",
"redaxios": "^0.5.1",
"tailwind-merge": "^2.6.0",
- "vite": "^6.3.5",
+ "vite": "^7.1.1",
"zod": "^3.24.2"
},
"devDependencies": {
@@ -32,6 +32,7 @@
"autoprefixer": "^10.4.20",
"combinate": "^1.1.11",
"postcss": "^8.5.1",
+ "srvx": "^0.8.6",
"tailwindcss": "^3.4.17",
"typescript": "^5.7.2",
"vite-tsconfig-paths": "^5.1.4"
diff --git a/e2e/react-start/scroll-restoration/vite.config.ts b/e2e/react-start/scroll-restoration/vite.config.ts
index 5b91efb751..33948491fe 100644
--- a/e2e/react-start/scroll-restoration/vite.config.ts
+++ b/e2e/react-start/scroll-restoration/vite.config.ts
@@ -1,7 +1,12 @@
import { defineConfig } from 'vite'
import tsConfigPaths from 'vite-tsconfig-paths'
import { tanstackStart } from '@tanstack/react-start/plugin/vite'
+import viteReact from '@vitejs/plugin-react'
export default defineConfig({
- plugins: [tsConfigPaths({ projects: ['./tsconfig.json'] }), tanstackStart()],
+ plugins: [
+ tsConfigPaths({ projects: ['./tsconfig.json'] }),
+ tanstackStart(),
+ viteReact(),
+ ],
})
diff --git a/e2e/react-start/selective-ssr/package.json b/e2e/react-start/selective-ssr/package.json
index 995641c88f..f7f29a329f 100644
--- a/e2e/react-start/selective-ssr/package.json
+++ b/e2e/react-start/selective-ssr/package.json
@@ -7,7 +7,7 @@
"dev": "vite dev --port 3000",
"dev:e2e": "vite dev",
"build": "vite build && tsc --noEmit",
- "start": "node .output/server/index.mjs",
+ "start": "pnpx srvx --prod -s ../client dist/server/server.js",
"test:e2e": "rm -rf port*.txt; playwright test --project=chromium"
},
"dependencies": {
@@ -16,16 +16,18 @@
"@tanstack/react-start": "workspace:^",
"react": "^19.0.0",
"react-dom": "^19.0.0",
- "vite": "^6.3.5",
+ "vite": "^7.1.1",
"vite-tsconfig-paths": "^5.1.4",
"zod": "^3.24.2"
},
"devDependencies": {
"@tanstack/router-e2e-utils": "workspace:^",
+ "@vitejs/plugin-react": "^4.3.4",
"@types/node": "^22.10.2",
"@types/react": "^19.0.8",
"@types/react-dom": "^19.0.3",
"postcss": "^8.5.1",
+ "srvx": "^0.8.6",
"tailwindcss": "^3.4.17",
"typescript": "^5.7.2"
}
diff --git a/e2e/react-start/selective-ssr/tests/app.spec.ts b/e2e/react-start/selective-ssr/tests/app.spec.ts
index b013dfb169..aea216d506 100644
--- a/e2e/react-start/selective-ssr/tests/app.spec.ts
+++ b/e2e/react-start/selective-ssr/tests/app.spec.ts
@@ -1,5 +1,5 @@
import { expect } from '@playwright/test'
-import { test } from './fixture'
+import { test } from '@tanstack/router-e2e-utils'
const testCount = 7
diff --git a/e2e/react-start/selective-ssr/tests/fixture.ts b/e2e/react-start/selective-ssr/tests/fixture.ts
deleted file mode 100644
index abb7b1d564..0000000000
--- a/e2e/react-start/selective-ssr/tests/fixture.ts
+++ /dev/null
@@ -1,28 +0,0 @@
-import { test as base, expect } from '@playwright/test'
-
-export interface TestFixtureOptions {
- whitelistErrors: Array
-}
-export const test = base.extend({
- whitelistErrors: [[], { option: true }],
- page: async ({ page, whitelistErrors }, use) => {
- const errorMessages: Array = []
- page.on('console', (m) => {
- if (m.type() === 'error') {
- const text = m.text()
- for (const whitelistError of whitelistErrors) {
- if (
- (typeof whitelistError === 'string' &&
- text.includes(whitelistError)) ||
- (whitelistError instanceof RegExp && whitelistError.test(text))
- ) {
- return
- }
- }
- errorMessages.push(text)
- }
- })
- await use(page)
- expect(errorMessages).toEqual([])
- },
-})
diff --git a/e2e/react-start/selective-ssr/vite.config.ts b/e2e/react-start/selective-ssr/vite.config.ts
index c3b722c89b..04033010e8 100644
--- a/e2e/react-start/selective-ssr/vite.config.ts
+++ b/e2e/react-start/selective-ssr/vite.config.ts
@@ -1,6 +1,7 @@
import { defineConfig } from 'vite'
import { tanstackStart } from '@tanstack/react-start/plugin/vite'
import tsConfigPaths from 'vite-tsconfig-paths'
+import viteReact from '@vitejs/plugin-react'
export default defineConfig({
server: {
@@ -11,5 +12,6 @@ export default defineConfig({
projects: ['./tsconfig.json'],
}),
tanstackStart(),
+ viteReact(),
],
})
diff --git a/e2e/react-start/serialization-adapters/.gitignore b/e2e/react-start/serialization-adapters/.gitignore
new file mode 100644
index 0000000000..08eba9e706
--- /dev/null
+++ b/e2e/react-start/serialization-adapters/.gitignore
@@ -0,0 +1,20 @@
+node_modules
+package-lock.json
+yarn.lock
+
+.DS_Store
+.cache
+.env
+.vercel
+.output
+/build/
+/api/
+/server/build
+/public/build# Sentry Config File
+.env.sentry-build-plugin
+/test-results/
+/playwright-report/
+/blob-report/
+/playwright/.cache/
+
+count.txt
diff --git a/e2e/react-start/serialization-adapters/.prettierignore b/e2e/react-start/serialization-adapters/.prettierignore
new file mode 100644
index 0000000000..2be5eaa6ec
--- /dev/null
+++ b/e2e/react-start/serialization-adapters/.prettierignore
@@ -0,0 +1,4 @@
+**/build
+**/public
+pnpm-lock.yaml
+routeTree.gen.ts
\ No newline at end of file
diff --git a/e2e/react-start/serialization-adapters/package.json b/e2e/react-start/serialization-adapters/package.json
new file mode 100644
index 0000000000..bb66301e8d
--- /dev/null
+++ b/e2e/react-start/serialization-adapters/package.json
@@ -0,0 +1,34 @@
+{
+ "name": "tanstack-react-start-e2e-serialization-adapters",
+ "private": true,
+ "sideEffects": false,
+ "type": "module",
+ "scripts": {
+ "dev": "vite dev --port 3000",
+ "dev:e2e": "vite dev",
+ "build": "vite build && tsc --noEmit",
+ "start": "pnpx srvx --prod -s ../client dist/server/server.js",
+ "test:e2e": "rm -rf port*.txt; playwright test --project=chromium"
+ },
+ "dependencies": {
+ "@tanstack/react-router": "workspace:^",
+ "@tanstack/react-router-devtools": "workspace:^",
+ "@tanstack/react-start": "workspace:^",
+ "react": "^19.0.0",
+ "react-dom": "^19.0.0",
+ "vite": "^7.1.1",
+ "vite-tsconfig-paths": "^5.1.4",
+ "zod": "^3.24.2"
+ },
+ "devDependencies": {
+ "@tanstack/router-e2e-utils": "workspace:^",
+ "@vitejs/plugin-react": "^4.3.4",
+ "@types/node": "^22.10.2",
+ "@types/react": "^19.0.8",
+ "@types/react-dom": "^19.0.3",
+ "postcss": "^8.5.1",
+ "srvx": "^0.8.6",
+ "tailwindcss": "^3.4.17",
+ "typescript": "^5.7.2"
+ }
+}
diff --git a/e2e/react-start/serialization-adapters/playwright.config.ts b/e2e/react-start/serialization-adapters/playwright.config.ts
new file mode 100644
index 0000000000..badd6db0eb
--- /dev/null
+++ b/e2e/react-start/serialization-adapters/playwright.config.ts
@@ -0,0 +1,34 @@
+import { defineConfig, devices } from '@playwright/test'
+import { getTestServerPort } from '@tanstack/router-e2e-utils'
+import packageJson from './package.json' with { type: 'json' }
+
+const PORT = await getTestServerPort(packageJson.name)
+const baseURL = `http://localhost:${PORT}`
+/**
+ * See https://playwright.dev/docs/test-configuration.
+ */
+export default defineConfig({
+ testDir: './tests',
+ workers: 1,
+
+ reporter: [['line']],
+
+ use: {
+ /* Base URL to use in actions like `await page.goto('/')`. */
+ baseURL,
+ },
+
+ webServer: {
+ command: `VITE_SERVER_PORT=${PORT} pnpm build && NODE_ENV=production PORT=${PORT} VITE_SERVER_PORT=${PORT} pnpm start`,
+ url: baseURL,
+ reuseExistingServer: !process.env.CI,
+ stdout: 'pipe',
+ },
+
+ projects: [
+ {
+ name: 'chromium',
+ use: { ...devices['Desktop Chrome'] },
+ },
+ ],
+})
diff --git a/e2e/react-start/serialization-adapters/postcss.config.mjs b/e2e/react-start/serialization-adapters/postcss.config.mjs
new file mode 100644
index 0000000000..2e7af2b7f1
--- /dev/null
+++ b/e2e/react-start/serialization-adapters/postcss.config.mjs
@@ -0,0 +1,6 @@
+export default {
+ plugins: {
+ tailwindcss: {},
+ autoprefixer: {},
+ },
+}
diff --git a/e2e/react-start/serialization-adapters/src/CustomError.ts b/e2e/react-start/serialization-adapters/src/CustomError.ts
new file mode 100644
index 0000000000..9fcf85b36f
--- /dev/null
+++ b/e2e/react-start/serialization-adapters/src/CustomError.ts
@@ -0,0 +1,31 @@
+import { createSerializationAdapter } from '@tanstack/react-router'
+
+export class CustomError extends Error {
+ public foo: string
+ public bar: bigint
+
+ constructor(message: string, options: { foo: string; bar: bigint }) {
+ super(message)
+
+ Object.setPrototypeOf(this, new.target.prototype)
+
+ this.name = this.constructor.name
+ this.foo = options.foo
+ this.bar = options.bar
+ }
+}
+
+export const customErrorAdapter = createSerializationAdapter({
+ key: 'custom-error',
+ test: (v) => v instanceof CustomError,
+ toSerializable: ({ message, foo, bar }) => {
+ return {
+ message,
+ foo,
+ bar,
+ }
+ },
+ fromSerializable: ({ message, foo, bar }) => {
+ return new CustomError(message, { foo, bar })
+ },
+})
diff --git a/e2e/react-start/serialization-adapters/src/data.tsx b/e2e/react-start/serialization-adapters/src/data.tsx
new file mode 100644
index 0000000000..ea1922fedc
--- /dev/null
+++ b/e2e/react-start/serialization-adapters/src/data.tsx
@@ -0,0 +1,127 @@
+import { createSerializationAdapter } from '@tanstack/react-router'
+
+export class Foo {
+ constructor(public value: string) {}
+}
+
+export interface Car {
+ __type: 'car'
+ make: string
+ model: string
+ year: number
+ honk: () => { message: string; make: string; model: string; year: number }
+}
+
+export function makeCar(opts: {
+ make: string
+ model: string
+ year: number
+}): Car {
+ return {
+ ...opts,
+ __type: 'car',
+ honk: () => {
+ return { message: `Honk! Honk!`, ...opts }
+ },
+ }
+}
+
+export const fooAdapter = createSerializationAdapter({
+ key: 'foo',
+ test: (value: any) => value instanceof Foo,
+ toSerializable: (foo) => foo.value,
+ fromSerializable: (value) => new Foo(value),
+})
+
+export const carAdapter = createSerializationAdapter({
+ key: 'car',
+ test: (value: any): value is Car =>
+ '__type' in (value as Car) && value.__type === 'car',
+ toSerializable: (car) => ({
+ make: car.make,
+ model: car.model,
+ year: car.year,
+ }),
+ fromSerializable: (value: { make: string; model: string; year: number }) =>
+ makeCar(value),
+})
+
+export function makeData() {
+ function makeFoo(suffix: string = '') {
+ return new Foo(typeof window === 'undefined' ? 'server' : 'client' + suffix)
+ }
+ return {
+ foo: {
+ singleInstance: makeFoo(),
+ array: [makeFoo('0'), makeFoo('1'), makeFoo('2')],
+ map: new Map([
+ [0, makeFoo('0')],
+ [1, makeFoo('1')],
+ [2, makeFoo('2')],
+ ]),
+ mapOfArrays: new Map([
+ [0, [makeFoo('0-a'), makeFoo('0-b')]],
+ [1, [makeFoo('1-a'), makeFoo('1-b')]],
+ [2, [makeFoo('2-a'), makeFoo('2-b')]],
+ ]),
+ },
+ car: {
+ singleInstance: makeCar({
+ make: 'Toyota',
+ model: 'Camry',
+ year: 2020,
+ }),
+ array: [
+ makeCar({ make: 'Honda', model: 'Accord', year: 2019 }),
+ makeCar({ make: 'Ford', model: 'Mustang', year: 2021 }),
+ ],
+ map: new Map([
+ [0, makeCar({ make: 'Chevrolet', model: 'Malibu', year: 2018 })],
+ [1, makeCar({ make: 'Nissan', model: 'Altima', year: 2020 })],
+ [2, makeCar({ make: 'Hyundai', model: 'Sonata', year: 2021 })],
+ ]),
+ mapOfArrays: new Map([
+ [0, [makeCar({ make: 'Kia', model: 'Optima', year: 2019 })]],
+ [1, [makeCar({ make: 'Subaru', model: 'Legacy', year: 2020 })]],
+ [2, [makeCar({ make: 'Volkswagen', model: 'Passat', year: 2021 })]],
+ ]),
+ },
+ }
+}
+
+export function RenderData({
+ id,
+ data,
+}: {
+ id: string
+ data: ReturnType
+}) {
+ const localData = makeData()
+ return (
+
+
Car
+
expected
+
+ {JSON.stringify({
+ make: localData.car.singleInstance.make,
+ model: localData.car.singleInstance.model,
+ year: localData.car.singleInstance.year,
+ })}
+
+
actual
+
+ {JSON.stringify({
+ make: data.car.singleInstance.make,
+ model: data.car.singleInstance.model,
+ year: data.car.singleInstance.year,
+ })}
+
+
Foo
+
+ {JSON.stringify({
+ value: data.foo.singleInstance.value,
+ })}
+
+
+ )
+}
diff --git a/e2e/react-start/serialization-adapters/src/routeTree.gen.ts b/e2e/react-start/serialization-adapters/src/routeTree.gen.ts
new file mode 100644
index 0000000000..872003fb09
--- /dev/null
+++ b/e2e/react-start/serialization-adapters/src/routeTree.gen.ts
@@ -0,0 +1,123 @@
+/* eslint-disable */
+
+// @ts-nocheck
+
+// noinspection JSUnusedGlobalSymbols
+
+// This file was automatically generated by TanStack Router.
+// You should NOT make any changes in this file as it will be overwritten.
+// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified.
+
+import { Route as rootRouteImport } from './routes/__root'
+import { Route as IndexRouteImport } from './routes/index'
+import { Route as SsrStreamRouteImport } from './routes/ssr/stream'
+import { Route as SsrDataOnlyRouteImport } from './routes/ssr/data-only'
+import { Route as ServerFunctionCustomErrorRouteImport } from './routes/server-function/custom-error'
+
+const IndexRoute = IndexRouteImport.update({
+ id: '/',
+ path: '/',
+ getParentRoute: () => rootRouteImport,
+} as any)
+const SsrStreamRoute = SsrStreamRouteImport.update({
+ id: '/ssr/stream',
+ path: '/ssr/stream',
+ getParentRoute: () => rootRouteImport,
+} as any)
+const SsrDataOnlyRoute = SsrDataOnlyRouteImport.update({
+ id: '/ssr/data-only',
+ path: '/ssr/data-only',
+ getParentRoute: () => rootRouteImport,
+} as any)
+const ServerFunctionCustomErrorRoute =
+ ServerFunctionCustomErrorRouteImport.update({
+ id: '/server-function/custom-error',
+ path: '/server-function/custom-error',
+ getParentRoute: () => rootRouteImport,
+ } as any)
+
+export interface FileRoutesByFullPath {
+ '/': typeof IndexRoute
+ '/server-function/custom-error': typeof ServerFunctionCustomErrorRoute
+ '/ssr/data-only': typeof SsrDataOnlyRoute
+ '/ssr/stream': typeof SsrStreamRoute
+}
+export interface FileRoutesByTo {
+ '/': typeof IndexRoute
+ '/server-function/custom-error': typeof ServerFunctionCustomErrorRoute
+ '/ssr/data-only': typeof SsrDataOnlyRoute
+ '/ssr/stream': typeof SsrStreamRoute
+}
+export interface FileRoutesById {
+ __root__: typeof rootRouteImport
+ '/': typeof IndexRoute
+ '/server-function/custom-error': typeof ServerFunctionCustomErrorRoute
+ '/ssr/data-only': typeof SsrDataOnlyRoute
+ '/ssr/stream': typeof SsrStreamRoute
+}
+export interface FileRouteTypes {
+ fileRoutesByFullPath: FileRoutesByFullPath
+ fullPaths:
+ | '/'
+ | '/server-function/custom-error'
+ | '/ssr/data-only'
+ | '/ssr/stream'
+ fileRoutesByTo: FileRoutesByTo
+ to: '/' | '/server-function/custom-error' | '/ssr/data-only' | '/ssr/stream'
+ id:
+ | '__root__'
+ | '/'
+ | '/server-function/custom-error'
+ | '/ssr/data-only'
+ | '/ssr/stream'
+ fileRoutesById: FileRoutesById
+}
+export interface RootRouteChildren {
+ IndexRoute: typeof IndexRoute
+ ServerFunctionCustomErrorRoute: typeof ServerFunctionCustomErrorRoute
+ SsrDataOnlyRoute: typeof SsrDataOnlyRoute
+ SsrStreamRoute: typeof SsrStreamRoute
+}
+
+declare module '@tanstack/react-router' {
+ interface FileRoutesByPath {
+ '/': {
+ id: '/'
+ path: '/'
+ fullPath: '/'
+ preLoaderRoute: typeof IndexRouteImport
+ parentRoute: typeof rootRouteImport
+ }
+ '/ssr/stream': {
+ id: '/ssr/stream'
+ path: '/ssr/stream'
+ fullPath: '/ssr/stream'
+ preLoaderRoute: typeof SsrStreamRouteImport
+ parentRoute: typeof rootRouteImport
+ }
+ '/ssr/data-only': {
+ id: '/ssr/data-only'
+ path: '/ssr/data-only'
+ fullPath: '/ssr/data-only'
+ preLoaderRoute: typeof SsrDataOnlyRouteImport
+ parentRoute: typeof rootRouteImport
+ }
+ '/server-function/custom-error': {
+ id: '/server-function/custom-error'
+ path: '/server-function/custom-error'
+ fullPath: '/server-function/custom-error'
+ preLoaderRoute: typeof ServerFunctionCustomErrorRouteImport
+ parentRoute: typeof rootRouteImport
+ }
+ }
+}
+
+const rootRouteChildren: RootRouteChildren = {
+ IndexRoute: IndexRoute,
+ ServerFunctionCustomErrorRoute: ServerFunctionCustomErrorRoute,
+ SsrDataOnlyRoute: SsrDataOnlyRoute,
+ SsrStreamRoute: SsrStreamRoute,
+}
+export const routeTree = rootRouteImport
+ ._addFileChildren(rootRouteChildren)
+ ._addFileTypes()
diff --git a/e2e/react-start/serialization-adapters/src/router.tsx b/e2e/react-start/serialization-adapters/src/router.tsx
new file mode 100644
index 0000000000..04154bc28f
--- /dev/null
+++ b/e2e/react-start/serialization-adapters/src/router.tsx
@@ -0,0 +1,28 @@
+import {
+ createRouterConfig,
+ createRouter as createTanStackRouter,
+} from '@tanstack/react-router'
+import { routeTree } from './routeTree.gen'
+import { carAdapter, fooAdapter } from './data'
+import { customErrorAdapter } from './CustomError'
+
+const config = createRouterConfig({
+ serializationAdapters: [fooAdapter, carAdapter, customErrorAdapter],
+})
+
+export function createRouter() {
+ const router = createTanStackRouter({
+ ...config,
+ routeTree,
+ scrollRestoration: true,
+ })
+
+ return router
+}
+
+declare module '@tanstack/react-router' {
+ interface Register {
+ config: typeof config
+ router: ReturnType
+ }
+}
diff --git a/e2e/react-start/serialization-adapters/src/routes/__root.tsx b/e2e/react-start/serialization-adapters/src/routes/__root.tsx
new file mode 100644
index 0000000000..2f30dfa3f1
--- /dev/null
+++ b/e2e/react-start/serialization-adapters/src/routes/__root.tsx
@@ -0,0 +1,72 @@
+///
+import * as React from 'react'
+import {
+ ClientOnly,
+ HeadContent,
+ Link,
+ Scripts,
+ createRootRoute,
+ useRouterState,
+} from '@tanstack/react-router'
+import { TanStackRouterDevtools } from '@tanstack/react-router-devtools'
+import appCss from '~/styles/app.css?url'
+
+export const Route = createRootRoute({
+ head: () => ({
+ meta: [
+ {
+ charSet: 'utf-8',
+ },
+ {
+ name: 'viewport',
+ content: 'width=device-width, initial-scale=1',
+ },
+ {
+ title: 'Serialization Adapters E2E Test',
+ },
+ ],
+ links: [{ rel: 'stylesheet', href: appCss }],
+ }),
+ shellComponent: RootDocument,
+})
+
+function RootDocument({ children }: { children: React.ReactNode }) {
+ const { isLoading, status } = useRouterState({
+ select: (state) => ({ isLoading: state.isLoading, status: state.status }),
+ structuralSharing: true,
+ })
+ return (
+
+
+
+
+
+
+
Serialization Adapters E2E Test
+
+ Home
+
+
+
+
+
+ router isLoading:{' '}
+ {isLoading ? 'true' : 'false'}
+
+
+ router status: {status}
+
+
+
+ {children}
+
+
+
+
+ )
+}
diff --git a/e2e/react-start/serialization-adapters/src/routes/index.tsx b/e2e/react-start/serialization-adapters/src/routes/index.tsx
new file mode 100644
index 0000000000..0c39c4d020
--- /dev/null
+++ b/e2e/react-start/serialization-adapters/src/routes/index.tsx
@@ -0,0 +1,40 @@
+import { Link, createFileRoute } from '@tanstack/react-router'
+
+export const Route = createFileRoute('/')({
+ component: Home,
+})
+
+function Home() {
+ return (
+ <>
+
+
SSR
+
+ Data Only
+
+
+
+ Stream
+
+
+
+
Server Functions
+
+ Custom Error Serialization
+
+
+ >
+ )
+}
diff --git a/e2e/react-start/serialization-adapters/src/routes/server-function/custom-error.tsx b/e2e/react-start/serialization-adapters/src/routes/server-function/custom-error.tsx
new file mode 100644
index 0000000000..784181ee5a
--- /dev/null
+++ b/e2e/react-start/serialization-adapters/src/routes/server-function/custom-error.tsx
@@ -0,0 +1,69 @@
+import { createFileRoute } from '@tanstack/react-router'
+import { createServerFn } from '@tanstack/react-start'
+import { setResponseStatus } from '@tanstack/react-start/server'
+import { useState } from 'react'
+import { z } from 'zod'
+import { CustomError } from '~/CustomError'
+
+const schema = z.object({ hello: z.string() })
+const serverFnThrowing = createServerFn()
+ .validator(schema)
+ .handler(async ({ data }) => {
+ if (data.hello === 'world') {
+ return 'Hello, world!'
+ }
+ setResponseStatus(499)
+ throw new CustomError('Invalid input', { foo: 'bar', bar: BigInt(123) })
+ })
+
+export const Route = createFileRoute('/server-function/custom-error')({
+ component: RouteComponent,
+})
+
+function RouteComponent() {
+ const [validResponse, setValidResponse] = useState(null)
+ const [invalidResponse, setInvalidResponse] = useState(
+ null,
+ )
+
+ return (
+
+
+ serverFnThrowing({ data: { hello: 'world' } }).then(setValidResponse)
+ }
+ >
+ trigger valid input
+
+
+ {JSON.stringify(validResponse)}
+
+
+
+
+ serverFnThrowing({ data: { hello: 'error' } }).catch((err) => {
+ if (err instanceof CustomError) {
+ setInvalidResponse(err)
+ } else {
+ throw new Error('expected CustomError')
+ }
+ })
+ }
+ >
+ trigger invalid input
+
+
+ {invalidResponse
+ ? JSON.stringify({
+ message: invalidResponse.message,
+ foo: invalidResponse.foo,
+ bar: invalidResponse.bar.toString(),
+ })
+ : JSON.stringify(validResponse)}
+
+
+ )
+}
diff --git a/e2e/react-start/serialization-adapters/src/routes/ssr/data-only.tsx b/e2e/react-start/serialization-adapters/src/routes/ssr/data-only.tsx
new file mode 100644
index 0000000000..c2626f42e2
--- /dev/null
+++ b/e2e/react-start/serialization-adapters/src/routes/ssr/data-only.tsx
@@ -0,0 +1,51 @@
+import { Outlet, createFileRoute } from '@tanstack/react-router'
+import { RenderData, makeData } from '~/data'
+
+export const Route = createFileRoute('/ssr/data-only')({
+ ssr: 'data-only',
+ beforeLoad: () => {
+ return makeData()
+ },
+ loader: ({ context }) => {
+ return context
+ },
+ component: () => {
+ const context = Route.useRouteContext()
+ const loaderData = Route.useLoaderData()
+
+ const localData = makeData()
+ const expectedHonkState = localData.car.singleInstance.honk()
+
+ const honkState = loaderData.car.singleInstance.honk()
+
+ return (
+
+
data-only
+
+ context:
+
+
+ loader:
+
+
+
honk
+
+ expected:{' '}
+
+ {JSON.stringify(expectedHonkState)}
+
+
+
+ actual:{' '}
+
+ {JSON.stringify(honkState)}
+
+
+
+
+
+
+ )
+ },
+ pendingComponent: () => posts Loading...
,
+})
diff --git a/e2e/react-start/serialization-adapters/src/routes/ssr/stream.tsx b/e2e/react-start/serialization-adapters/src/routes/ssr/stream.tsx
new file mode 100644
index 0000000000..75926f8342
--- /dev/null
+++ b/e2e/react-start/serialization-adapters/src/routes/ssr/stream.tsx
@@ -0,0 +1,31 @@
+import { Await, createFileRoute } from '@tanstack/react-router'
+import { Suspense } from 'react'
+import { RenderData, makeData } from '~/data'
+
+export const Route = createFileRoute('/ssr/stream')({
+ loader: () => {
+ const dataPromise = new Promise>((r) =>
+ setTimeout(() => r(makeData()), 1000),
+ )
+ return {
+ someString: 'hello world',
+ dataPromise,
+ }
+ },
+ component: RouteComponent,
+})
+
+function RouteComponent() {
+ const loaderData = Route.useLoaderData()
+ return (
+
+
Stream
+
{loaderData.someString}
+
Loading... }>
+
+ {(data) => }
+
+
+
+ )
+}
diff --git a/e2e/react-start/serialization-adapters/src/styles/app.css b/e2e/react-start/serialization-adapters/src/styles/app.css
new file mode 100644
index 0000000000..c53c870665
--- /dev/null
+++ b/e2e/react-start/serialization-adapters/src/styles/app.css
@@ -0,0 +1,22 @@
+@tailwind base;
+@tailwind components;
+@tailwind utilities;
+
+@layer base {
+ html {
+ color-scheme: light dark;
+ }
+
+ * {
+ @apply border-gray-200 dark:border-gray-800;
+ }
+
+ html,
+ body {
+ @apply text-gray-900 bg-gray-50 dark:bg-gray-950 dark:text-gray-200;
+ }
+
+ .using-mouse * {
+ outline: none !important;
+ }
+}
diff --git a/e2e/react-start/serialization-adapters/tailwind.config.mjs b/e2e/react-start/serialization-adapters/tailwind.config.mjs
new file mode 100644
index 0000000000..e49f4eb776
--- /dev/null
+++ b/e2e/react-start/serialization-adapters/tailwind.config.mjs
@@ -0,0 +1,4 @@
+/** @type {import('tailwindcss').Config} */
+export default {
+ content: ['./src/**/*.{js,jsx,ts,tsx}'],
+}
diff --git a/e2e/react-start/serialization-adapters/tests/app.spec.ts b/e2e/react-start/serialization-adapters/tests/app.spec.ts
new file mode 100644
index 0000000000..2cfaaf727d
--- /dev/null
+++ b/e2e/react-start/serialization-adapters/tests/app.spec.ts
@@ -0,0 +1,76 @@
+import { expect } from '@playwright/test'
+import { test } from '@tanstack/router-e2e-utils'
+import type { Page } from '@playwright/test'
+
+async function awaitPageLoaded(page: Page) {
+ // wait for page to be loaded by waiting for the ClientOnly component to be rendered
+
+ await expect(page.getByTestId('router-isLoading')).toContainText('false')
+ await expect(page.getByTestId('router-status')).toContainText('idle')
+}
+async function checkData(page: Page, id: string) {
+ const expectedData = await page
+ .getByTestId(`${id}-car-expected`)
+ .textContent()
+ expect(expectedData).not.toBeNull()
+ await expect(page.getByTestId(`${id}-car-actual`)).toContainText(
+ expectedData!,
+ )
+
+ await expect(page.getByTestId(`${id}-foo`)).toContainText(
+ '{"value":"server"}',
+ )
+}
+test.use({
+ whitelistErrors: [
+ /Failed to load resource: the server responded with a status of 499/,
+ ],
+})
+test.describe('SSR serialization adapters', () => {
+ test(`data-only`, async ({ page }) => {
+ await page.goto('/ssr/data-only')
+ await awaitPageLoaded(page)
+
+ await Promise.all(
+ ['context', 'loader'].map(async (id) => checkData(page, id)),
+ )
+
+ const expectedHonkData = await page
+ .getByTestId('honk-expected-state')
+ .textContent()
+ expect(expectedHonkData).not.toBeNull()
+ await expect(page.getByTestId('honk-actual-state')).toContainText(
+ expectedHonkData!,
+ )
+ })
+
+ test('stream', async ({ page }) => {
+ await page.goto('/ssr/stream')
+ await awaitPageLoaded(page)
+ await checkData(page, 'stream')
+ })
+})
+
+test.describe('server functions serialization adapters', () => {
+ test('custom error', async ({ page }) => {
+ await page.goto('/server-function/custom-error')
+ await awaitPageLoaded(page)
+
+ await expect(
+ page.getByTestId('server-function-valid-response'),
+ ).toContainText('null')
+ await expect(
+ page.getByTestId('server-function-invalid-response'),
+ ).toContainText('null')
+
+ await page.getByTestId('server-function-valid-input').click()
+ await expect(
+ page.getByTestId('server-function-valid-response'),
+ ).toContainText('Hello, world!')
+
+ await page.getByTestId('server-function-invalid-input').click()
+ await expect(
+ page.getByTestId('server-function-invalid-response'),
+ ).toContainText('{"message":"Invalid input","foo":"bar","bar":"123"}')
+ })
+})
diff --git a/e2e/react-start/serialization-adapters/tsconfig.json b/e2e/react-start/serialization-adapters/tsconfig.json
new file mode 100644
index 0000000000..3a9fb7cd71
--- /dev/null
+++ b/e2e/react-start/serialization-adapters/tsconfig.json
@@ -0,0 +1,22 @@
+{
+ "include": ["**/*.ts", "**/*.tsx"],
+ "compilerOptions": {
+ "strict": true,
+ "esModuleInterop": true,
+ "jsx": "react-jsx",
+ "module": "ESNext",
+ "moduleResolution": "Bundler",
+ "lib": ["DOM", "DOM.Iterable", "ES2022"],
+ "isolatedModules": true,
+ "resolveJsonModule": true,
+ "skipLibCheck": true,
+ "target": "ES2022",
+ "allowJs": true,
+ "forceConsistentCasingInFileNames": true,
+ "baseUrl": ".",
+ "paths": {
+ "~/*": ["./src/*"]
+ },
+ "noEmit": true
+ }
+}
diff --git a/e2e/react-start/serialization-adapters/vite.config.ts b/e2e/react-start/serialization-adapters/vite.config.ts
new file mode 100644
index 0000000000..04033010e8
--- /dev/null
+++ b/e2e/react-start/serialization-adapters/vite.config.ts
@@ -0,0 +1,17 @@
+import { defineConfig } from 'vite'
+import { tanstackStart } from '@tanstack/react-start/plugin/vite'
+import tsConfigPaths from 'vite-tsconfig-paths'
+import viteReact from '@vitejs/plugin-react'
+
+export default defineConfig({
+ server: {
+ port: 3000,
+ },
+ plugins: [
+ tsConfigPaths({
+ projects: ['./tsconfig.json'],
+ }),
+ tanstackStart(),
+ viteReact(),
+ ],
+})
diff --git a/e2e/react-start/server-context/.gitignore b/e2e/react-start/server-context/.gitignore
new file mode 100644
index 0000000000..ca63f49885
--- /dev/null
+++ b/e2e/react-start/server-context/.gitignore
@@ -0,0 +1,18 @@
+node_modules
+package-lock.json
+yarn.lock
+
+.DS_Store
+.cache
+.env
+.vercel
+.output
+/build/
+/api/
+/server/build
+/public/build# Sentry Config File
+.env.sentry-build-plugin
+/test-results/
+/playwright-report/
+/blob-report/
+/playwright/.cache/
diff --git a/e2e/react-start/server-context/.prettierignore b/e2e/react-start/server-context/.prettierignore
new file mode 100644
index 0000000000..2be5eaa6ec
--- /dev/null
+++ b/e2e/react-start/server-context/.prettierignore
@@ -0,0 +1,4 @@
+**/build
+**/public
+pnpm-lock.yaml
+routeTree.gen.ts
\ No newline at end of file
diff --git a/e2e/react-start/server-context/package.json b/e2e/react-start/server-context/package.json
new file mode 100644
index 0000000000..30a21e94fc
--- /dev/null
+++ b/e2e/react-start/server-context/package.json
@@ -0,0 +1,41 @@
+{
+ "name": "tanstack-react-start-e2e-server-context",
+ "private": true,
+ "sideEffects": false,
+ "type": "module",
+ "scripts": {
+ "dev": "vite dev --port 3000",
+ "dev:e2e": "vite dev",
+ "build": "vite build && tsc --noEmit",
+ "start": "pnpx srvx --prod -s ../client dist/server/server.js",
+ "test:e2e": "playwright test --project=chromium"
+ },
+ "dependencies": {
+ "@tanstack/react-router": "workspace:^",
+ "@tanstack/react-router-devtools": "workspace:^",
+ "@tanstack/react-start": "workspace:^",
+ "js-cookie": "^3.0.5",
+ "react": "^19.0.0",
+ "react-dom": "^19.0.0",
+ "redaxios": "^0.5.1",
+ "tailwind-merge": "^2.6.0",
+ "vite": "^7.1.1",
+ "zod": "^3.24.2"
+ },
+ "devDependencies": {
+ "@playwright/test": "^1.50.1",
+ "@tanstack/router-e2e-utils": "workspace:^",
+ "@types/js-cookie": "^3.0.6",
+ "@types/node": "^22.10.2",
+ "@types/react": "^19.0.8",
+ "@types/react-dom": "^19.0.3",
+ "@vitejs/plugin-react": "^4.3.4",
+ "autoprefixer": "^10.4.20",
+ "combinate": "^1.1.11",
+ "postcss": "^8.5.1",
+ "srvx": "^0.8.6",
+ "tailwindcss": "^3.4.17",
+ "typescript": "^5.7.2",
+ "vite-tsconfig-paths": "^5.1.4"
+ }
+}
diff --git a/e2e/react-start/server-context/playwright.config.ts b/e2e/react-start/server-context/playwright.config.ts
new file mode 100644
index 0000000000..8330e023ee
--- /dev/null
+++ b/e2e/react-start/server-context/playwright.config.ts
@@ -0,0 +1,35 @@
+import { defineConfig, devices } from '@playwright/test'
+import { getTestServerPort } from '@tanstack/router-e2e-utils'
+import packageJson from './package.json' with { type: 'json' }
+
+export const PORT = await getTestServerPort(packageJson.name)
+const baseURL = `http://localhost:${PORT}`
+
+/**
+ * See https://playwright.dev/docs/test-configuration.
+ */
+export default defineConfig({
+ testDir: './tests',
+ workers: 1,
+
+ reporter: [['line']],
+
+ use: {
+ /* Base URL to use in actions like `await page.goto('/')`. */
+ baseURL,
+ },
+
+ webServer: {
+ command: `VITE_SERVER_PORT=${PORT} pnpm build && PORT=${PORT} VITE_SERVER_PORT=${PORT} pnpm start`,
+ url: baseURL,
+ reuseExistingServer: !process.env.CI,
+ stdout: 'pipe',
+ },
+
+ projects: [
+ {
+ name: 'chromium',
+ use: { ...devices['Desktop Chrome'] },
+ },
+ ],
+})
diff --git a/e2e/react-start/server-context/postcss.config.mjs b/e2e/react-start/server-context/postcss.config.mjs
new file mode 100644
index 0000000000..2e7af2b7f1
--- /dev/null
+++ b/e2e/react-start/server-context/postcss.config.mjs
@@ -0,0 +1,6 @@
+export default {
+ plugins: {
+ tailwindcss: {},
+ autoprefixer: {},
+ },
+}
diff --git a/e2e/react-start/server-context/public/favicon.ico b/e2e/react-start/server-context/public/favicon.ico
new file mode 100644
index 0000000000..1a1751676f
Binary files /dev/null and b/e2e/react-start/server-context/public/favicon.ico differ
diff --git a/e2e/react-start/server-context/public/favicon.png b/e2e/react-start/server-context/public/favicon.png
new file mode 100644
index 0000000000..1e77bc0609
Binary files /dev/null and b/e2e/react-start/server-context/public/favicon.png differ
diff --git a/e2e/react-start/server-context/src/components/DefaultCatchBoundary.tsx b/e2e/react-start/server-context/src/components/DefaultCatchBoundary.tsx
new file mode 100644
index 0000000000..15f316681c
--- /dev/null
+++ b/e2e/react-start/server-context/src/components/DefaultCatchBoundary.tsx
@@ -0,0 +1,53 @@
+import {
+ ErrorComponent,
+ Link,
+ rootRouteId,
+ useMatch,
+ useRouter,
+} from '@tanstack/react-router'
+import type { ErrorComponentProps } from '@tanstack/react-router'
+
+export function DefaultCatchBoundary({ error }: ErrorComponentProps) {
+ const router = useRouter()
+ const isRoot = useMatch({
+ strict: false,
+ select: (state) => state.id === rootRouteId,
+ })
+
+ console.error(error)
+
+ return (
+
+
+
+ {
+ router.invalidate()
+ }}
+ className={`px-2 py-1 bg-gray-600 dark:bg-gray-700 rounded text-white uppercase font-extrabold`}
+ >
+ Try Again
+
+ {isRoot ? (
+
+ Home
+
+ ) : (
+ {
+ e.preventDefault()
+ window.history.back()
+ }}
+ >
+ Go Back
+
+ )}
+
+
+ )
+}
diff --git a/e2e/react-start/server-context/src/components/NotFound.tsx b/e2e/react-start/server-context/src/components/NotFound.tsx
new file mode 100644
index 0000000000..af4e0e7494
--- /dev/null
+++ b/e2e/react-start/server-context/src/components/NotFound.tsx
@@ -0,0 +1,25 @@
+import { Link } from '@tanstack/react-router'
+
+export function NotFound({ children }: { children?: any }) {
+ return (
+
+
+ {children ||
The page you are looking for does not exist.
}
+
+
+ window.history.back()}
+ className="bg-emerald-500 text-white px-2 py-1 rounded uppercase font-black text-sm"
+ >
+ Go back
+
+
+ Start Over
+
+
+
+ )
+}
diff --git a/e2e/react-start/server-context/src/routeTree.gen.ts b/e2e/react-start/server-context/src/routeTree.gen.ts
new file mode 100644
index 0000000000..655763ee3c
--- /dev/null
+++ b/e2e/react-start/server-context/src/routeTree.gen.ts
@@ -0,0 +1,161 @@
+/* eslint-disable */
+
+// @ts-nocheck
+
+// noinspection JSUnusedGlobalSymbols
+
+// This file was automatically generated by TanStack Router.
+// You should NOT make any changes in this file as it will be overwritten.
+// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified.
+
+import { createServerRootRoute } from '@tanstack/react-start/server'
+
+import { Route as rootRouteImport } from './routes/__root'
+import {
+ Route as FooRouteImport,
+ ServerRoute as FooServerRouteImport,
+} from './routes/foo'
+import { Route as IndexRouteImport } from './routes/index'
+import { Route as FooBarRouteImport } from './routes/foo/bar'
+
+const rootServerRouteImport = createServerRootRoute()
+
+const FooRoute = FooRouteImport.update({
+ id: '/foo',
+ path: '/foo',
+ getParentRoute: () => rootRouteImport,
+} as any)
+const IndexRoute = IndexRouteImport.update({
+ id: '/',
+ path: '/',
+ getParentRoute: () => rootRouteImport,
+} as any)
+const FooBarRoute = FooBarRouteImport.update({
+ id: '/bar',
+ path: '/bar',
+ getParentRoute: () => FooRoute,
+} as any)
+const FooServerRoute = FooServerRouteImport.update({
+ id: '/foo',
+ path: '/foo',
+ getParentRoute: () => rootServerRouteImport,
+} as any)
+
+export interface FileRoutesByFullPath {
+ '/': typeof IndexRoute
+ '/foo': typeof FooRouteWithChildren
+ '/foo/bar': typeof FooBarRoute
+}
+export interface FileRoutesByTo {
+ '/': typeof IndexRoute
+ '/foo': typeof FooRouteWithChildren
+ '/foo/bar': typeof FooBarRoute
+}
+export interface FileRoutesById {
+ __root__: typeof rootRouteImport
+ '/': typeof IndexRoute
+ '/foo': typeof FooRouteWithChildren
+ '/foo/bar': typeof FooBarRoute
+}
+export interface FileRouteTypes {
+ fileRoutesByFullPath: FileRoutesByFullPath
+ fullPaths: '/' | '/foo' | '/foo/bar'
+ fileRoutesByTo: FileRoutesByTo
+ to: '/' | '/foo' | '/foo/bar'
+ id: '__root__' | '/' | '/foo' | '/foo/bar'
+ fileRoutesById: FileRoutesById
+}
+export interface RootRouteChildren {
+ IndexRoute: typeof IndexRoute
+ FooRoute: typeof FooRouteWithChildren
+}
+export interface FileServerRoutesByFullPath {
+ '/foo': typeof FooServerRouteWithChildren
+}
+export interface FileServerRoutesByTo {
+ '/foo': typeof FooServerRouteWithChildren
+}
+export interface FileServerRoutesById {
+ __root__: typeof rootServerRouteImport
+ '/foo': typeof FooServerRouteWithChildren
+}
+export interface FileServerRouteTypes {
+ fileServerRoutesByFullPath: FileServerRoutesByFullPath
+ fullPaths: '/foo'
+ fileServerRoutesByTo: FileServerRoutesByTo
+ to: '/foo'
+ id: '__root__' | '/foo'
+ fileServerRoutesById: FileServerRoutesById
+}
+export interface RootServerRouteChildren {
+ FooServerRoute: typeof FooServerRouteWithChildren
+}
+
+declare module '@tanstack/react-router' {
+ interface FileRoutesByPath {
+ '/foo': {
+ id: '/foo'
+ path: '/foo'
+ fullPath: '/foo'
+ preLoaderRoute: typeof FooRouteImport
+ parentRoute: typeof rootRouteImport
+ }
+ '/': {
+ id: '/'
+ path: '/'
+ fullPath: '/'
+ preLoaderRoute: typeof IndexRouteImport
+ parentRoute: typeof rootRouteImport
+ }
+ '/foo/bar': {
+ id: '/foo/bar'
+ path: '/bar'
+ fullPath: '/foo/bar'
+ preLoaderRoute: typeof FooBarRouteImport
+ parentRoute: typeof FooRoute
+ }
+ }
+}
+declare module '@tanstack/react-start/server' {
+ interface ServerFileRoutesByPath {
+ '/foo': {
+ id: '/foo'
+ path: '/foo'
+ fullPath: '/foo'
+ preLoaderRoute: typeof FooServerRouteImport
+ parentRoute: typeof rootServerRouteImport
+ }
+ }
+}
+
+interface FooRouteChildren {
+ FooBarRoute: typeof FooBarRoute
+}
+
+const FooRouteChildren: FooRouteChildren = {
+ FooBarRoute: FooBarRoute,
+}
+
+const FooRouteWithChildren = FooRoute._addFileChildren(FooRouteChildren)
+
+interface FooServerRouteChildren {}
+
+const FooServerRouteChildren: FooServerRouteChildren = {}
+
+const FooServerRouteWithChildren = FooServerRoute._addFileChildren(
+ FooServerRouteChildren,
+)
+
+const rootRouteChildren: RootRouteChildren = {
+ IndexRoute: IndexRoute,
+ FooRoute: FooRouteWithChildren,
+}
+export const routeTree = rootRouteImport
+ ._addFileChildren(rootRouteChildren)
+ ._addFileTypes()
+const rootServerRouteChildren: RootServerRouteChildren = {
+ FooServerRoute: FooServerRouteWithChildren,
+}
+export const serverRouteTree = rootServerRouteImport
+ ._addFileChildren(rootServerRouteChildren)
+ ._addFileTypes()
diff --git a/e2e/react-start/server-context/src/router.tsx b/e2e/react-start/server-context/src/router.tsx
new file mode 100644
index 0000000000..c76eb0210c
--- /dev/null
+++ b/e2e/react-start/server-context/src/router.tsx
@@ -0,0 +1,22 @@
+import { createRouter as createTanStackRouter } from '@tanstack/react-router'
+import { routeTree } from './routeTree.gen'
+import { DefaultCatchBoundary } from './components/DefaultCatchBoundary'
+import { NotFound } from './components/NotFound'
+
+export function createRouter() {
+ const router = createTanStackRouter({
+ routeTree,
+ defaultPreload: 'intent',
+ defaultErrorComponent: DefaultCatchBoundary,
+ defaultNotFoundComponent: () => ,
+ scrollRestoration: true,
+ })
+
+ return router
+}
+
+declare module '@tanstack/react-router' {
+ interface Register {
+ router: ReturnType
+ }
+}
diff --git a/e2e/react-start/server-context/src/routes/__root.tsx b/e2e/react-start/server-context/src/routes/__root.tsx
new file mode 100644
index 0000000000..64f5cbaf34
--- /dev/null
+++ b/e2e/react-start/server-context/src/routes/__root.tsx
@@ -0,0 +1,82 @@
+///
+import * as React from 'react'
+import {
+ HeadContent,
+ Link,
+ Outlet,
+ Scripts,
+ createRootRoute,
+} from '@tanstack/react-router'
+
+import { DefaultCatchBoundary } from '~/components/DefaultCatchBoundary'
+import { NotFound } from '~/components/NotFound'
+import appCss from '~/styles/app.css?url'
+
+export const Route = createRootRoute({
+ head: () => ({
+ meta: [
+ {
+ charSet: 'utf-8',
+ },
+ {
+ name: 'viewport',
+ content: 'width=device-width, initial-scale=1',
+ },
+ ],
+ links: [{ rel: 'stylesheet', href: appCss }],
+ }),
+ errorComponent: (props) => {
+ return (
+
+
+
+ )
+ },
+ notFoundComponent: () => ,
+ component: RootComponent,
+})
+
+function RootComponent() {
+ return (
+
+
+
+ )
+}
+
+const RouterDevtools =
+ process.env.NODE_ENV === 'production'
+ ? () => null // Render nothing in production
+ : React.lazy(() =>
+ // Lazy load in development
+ import('@tanstack/react-router-devtools').then((res) => ({
+ default: res.TanStackRouterDevtools,
+ })),
+ )
+
+function RootDocument({ children }: { children: React.ReactNode }) {
+ return (
+
+
+
+
+
+
+
+ Home
+
+
+
+ {children}
+
+
+
+
+ )
+}
diff --git a/e2e/react-start/server-context/src/routes/foo.ts b/e2e/react-start/server-context/src/routes/foo.ts
new file mode 100644
index 0000000000..8c6136a25c
--- /dev/null
+++ b/e2e/react-start/server-context/src/routes/foo.ts
@@ -0,0 +1,31 @@
+import { createServerFileRoute } from '@tanstack/react-start/server'
+import { createMiddleware, json } from '@tanstack/react-start'
+import { createFileRoute } from '@tanstack/react-router'
+
+const testParentMiddleware = createMiddleware({ type: 'request' }).server(
+ async ({ next }) => {
+ const result = await next({ context: { testParent: true } })
+ return result
+ },
+)
+
+const testMiddleware = createMiddleware({ type: 'request' })
+ .middleware([testParentMiddleware])
+ .server(async ({ next }) => {
+ const result = await next({ context: { test: true } })
+ return result
+ })
+
+export const ServerRoute = createServerFileRoute('/foo')
+ .middleware([testMiddleware])
+ .methods({
+ GET: ({ request, context }) => {
+ return json({
+ url: request.url,
+ context: context,
+ expectedContext: { testParent: true, test: true },
+ })
+ },
+ })
+
+export const Route = createFileRoute('/foo')({})
diff --git a/e2e/react-start/server-context/src/routes/foo/bar.ts b/e2e/react-start/server-context/src/routes/foo/bar.ts
new file mode 100644
index 0000000000..e37e8b6803
--- /dev/null
+++ b/e2e/react-start/server-context/src/routes/foo/bar.ts
@@ -0,0 +1,9 @@
+import { createFileRoute } from '@tanstack/react-router'
+
+export const Route = createFileRoute('/foo/bar')({
+ component: RouteComponent,
+})
+
+function RouteComponent() {
+ return Hello "/foo/bar"!
+}
diff --git a/e2e/react-start/server-context/src/routes/index.tsx b/e2e/react-start/server-context/src/routes/index.tsx
new file mode 100644
index 0000000000..ef9dc9ab85
--- /dev/null
+++ b/e2e/react-start/server-context/src/routes/index.tsx
@@ -0,0 +1,20 @@
+import { Link, createFileRoute } from '@tanstack/react-router'
+
+export const Route = createFileRoute('/')({
+ component: Home,
+})
+
+function Home() {
+ return (
+
+
Server Routes E2E tests
+
+
+
+ server function middleware context is merged correctly
+
+
+
+
+ )
+}
diff --git a/e2e/react-start/server-context/src/styles/app.css b/e2e/react-start/server-context/src/styles/app.css
new file mode 100644
index 0000000000..c53c870665
--- /dev/null
+++ b/e2e/react-start/server-context/src/styles/app.css
@@ -0,0 +1,22 @@
+@tailwind base;
+@tailwind components;
+@tailwind utilities;
+
+@layer base {
+ html {
+ color-scheme: light dark;
+ }
+
+ * {
+ @apply border-gray-200 dark:border-gray-800;
+ }
+
+ html,
+ body {
+ @apply text-gray-900 bg-gray-50 dark:bg-gray-950 dark:text-gray-200;
+ }
+
+ .using-mouse * {
+ outline: none !important;
+ }
+}
diff --git a/e2e/react-start/server-context/tailwind.config.mjs b/e2e/react-start/server-context/tailwind.config.mjs
new file mode 100644
index 0000000000..e49f4eb776
--- /dev/null
+++ b/e2e/react-start/server-context/tailwind.config.mjs
@@ -0,0 +1,4 @@
+/** @type {import('tailwindcss').Config} */
+export default {
+ content: ['./src/**/*.{js,jsx,ts,tsx}'],
+}
diff --git a/e2e/react-start/server-context/tests/server-routes.spec.ts b/e2e/react-start/server-context/tests/server-routes.spec.ts
new file mode 100644
index 0000000000..33176a23fd
--- /dev/null
+++ b/e2e/react-start/server-context/tests/server-routes.spec.ts
@@ -0,0 +1,18 @@
+import { expect } from '@playwright/test'
+import { test } from '@tanstack/router-e2e-utils'
+
+test('merge-server-fn-middleware-context', async ({ page }) => {
+ await page.goto('/merge-server-fn-middleware-context')
+
+ await page.waitForLoadState('networkidle')
+
+ await page.getByTestId('test-middleware-context-btn').click()
+ await page.waitForLoadState('networkidle')
+
+ await expect(page.getByTestId('has-test-parent')).toContainText('true')
+ await expect(page.getByTestId('has-test')).toContainText('true')
+
+ const contextResult = await page.getByTestId('context-result').textContent()
+ expect(contextResult).toContain('testParent')
+ expect(contextResult).toContain('test')
+})
diff --git a/e2e/react-start/server-context/tsconfig.json b/e2e/react-start/server-context/tsconfig.json
new file mode 100644
index 0000000000..d35a4b17f4
--- /dev/null
+++ b/e2e/react-start/server-context/tsconfig.json
@@ -0,0 +1,23 @@
+{
+ "include": ["**/*.ts", "**/*.tsx", "public/script*.js"],
+ "compilerOptions": {
+ "strict": true,
+ "esModuleInterop": true,
+ "jsx": "react-jsx",
+ "module": "ESNext",
+ "moduleResolution": "Bundler",
+ "lib": ["DOM", "DOM.Iterable", "ES2022"],
+ "isolatedModules": true,
+ "resolveJsonModule": true,
+ "skipLibCheck": true,
+ "target": "ES2022",
+ "allowJs": true,
+ "forceConsistentCasingInFileNames": true,
+ "baseUrl": ".",
+ "paths": {
+ "~/*": ["./src/*"]
+ },
+ "noEmit": true,
+ "types": ["vite/client"]
+ }
+}
diff --git a/e2e/react-start/server-context/vite.config.ts b/e2e/react-start/server-context/vite.config.ts
new file mode 100644
index 0000000000..dc57f144e4
--- /dev/null
+++ b/e2e/react-start/server-context/vite.config.ts
@@ -0,0 +1,14 @@
+import { defineConfig } from 'vite'
+import tsConfigPaths from 'vite-tsconfig-paths'
+import { tanstackStart } from '@tanstack/react-start/plugin/vite'
+import viteReact from '@vitejs/plugin-react'
+
+export default defineConfig({
+ plugins: [
+ tsConfigPaths({
+ projects: ['./tsconfig.json'],
+ }),
+ tanstackStart(),
+ viteReact(),
+ ],
+})
diff --git a/e2e/react-start/server-functions/package.json b/e2e/react-start/server-functions/package.json
index bf735283d8..2a74346351 100644
--- a/e2e/react-start/server-functions/package.json
+++ b/e2e/react-start/server-functions/package.json
@@ -7,7 +7,7 @@
"dev": "vite dev --port 3000",
"dev:e2e": "vite dev",
"build": "vite build && tsc --noEmit",
- "start": "node .output/server/index.mjs",
+ "start": "pnpx srvx --prod -s ../client dist/server/server.js",
"test:e2e": "rm -rf port*.txt; playwright test --project=chromium"
},
"dependencies": {
@@ -19,7 +19,7 @@
"react-dom": "^19.0.0",
"redaxios": "^0.5.1",
"tailwind-merge": "^2.6.0",
- "vite": "^6.3.5",
+ "vite": "^7.1.1",
"zod": "^3.24.2"
},
"devDependencies": {
@@ -33,6 +33,7 @@
"autoprefixer": "^10.4.20",
"combinate": "^1.1.11",
"postcss": "^8.5.1",
+ "srvx": "^0.8.6",
"tailwindcss": "^3.4.17",
"typescript": "^5.7.2",
"vite-tsconfig-paths": "^5.1.4"
diff --git a/e2e/react-start/server-functions/src/routeTree.gen.ts b/e2e/react-start/server-functions/src/routeTree.gen.ts
index 39bdf99d2d..249607c47d 100644
--- a/e2e/react-start/server-functions/src/routeTree.gen.ts
+++ b/e2e/react-start/server-functions/src/routeTree.gen.ts
@@ -24,6 +24,7 @@ import { Route as AbortSignalRouteImport } from './routes/abort-signal'
import { Route as IndexRouteImport } from './routes/index'
import { Route as MiddlewareIndexRouteImport } from './routes/middleware/index'
import { Route as FormdataRedirectIndexRouteImport } from './routes/formdata-redirect/index'
+import { Route as FactoryIndexRouteImport } from './routes/factory/index'
import { Route as CookiesIndexRouteImport } from './routes/cookies/index'
import { Route as MiddlewareSendServerFnRouteImport } from './routes/middleware/send-serverFn'
import { Route as MiddlewareClientMiddlewareRouterRouteImport } from './routes/middleware/client-middleware-router'
@@ -105,6 +106,11 @@ const FormdataRedirectIndexRoute = FormdataRedirectIndexRouteImport.update({
path: '/formdata-redirect/',
getParentRoute: () => rootRouteImport,
} as any)
+const FactoryIndexRoute = FactoryIndexRouteImport.update({
+ id: '/factory/',
+ path: '/factory/',
+ getParentRoute: () => rootRouteImport,
+} as any)
const CookiesIndexRoute = CookiesIndexRouteImport.update({
id: '/cookies/',
path: '/cookies/',
@@ -151,6 +157,7 @@ export interface FileRoutesByFullPath {
'/middleware/client-middleware-router': typeof MiddlewareClientMiddlewareRouterRoute
'/middleware/send-serverFn': typeof MiddlewareSendServerFnRoute
'/cookies': typeof CookiesIndexRoute
+ '/factory': typeof FactoryIndexRoute
'/formdata-redirect': typeof FormdataRedirectIndexRoute
'/middleware': typeof MiddlewareIndexRoute
'/formdata-redirect/target/$name': typeof FormdataRedirectTargetNameRoute
@@ -173,6 +180,7 @@ export interface FileRoutesByTo {
'/middleware/client-middleware-router': typeof MiddlewareClientMiddlewareRouterRoute
'/middleware/send-serverFn': typeof MiddlewareSendServerFnRoute
'/cookies': typeof CookiesIndexRoute
+ '/factory': typeof FactoryIndexRoute
'/formdata-redirect': typeof FormdataRedirectIndexRoute
'/middleware': typeof MiddlewareIndexRoute
'/formdata-redirect/target/$name': typeof FormdataRedirectTargetNameRoute
@@ -196,6 +204,7 @@ export interface FileRoutesById {
'/middleware/client-middleware-router': typeof MiddlewareClientMiddlewareRouterRoute
'/middleware/send-serverFn': typeof MiddlewareSendServerFnRoute
'/cookies/': typeof CookiesIndexRoute
+ '/factory/': typeof FactoryIndexRoute
'/formdata-redirect/': typeof FormdataRedirectIndexRoute
'/middleware/': typeof MiddlewareIndexRoute
'/formdata-redirect/target/$name': typeof FormdataRedirectTargetNameRoute
@@ -220,6 +229,7 @@ export interface FileRouteTypes {
| '/middleware/client-middleware-router'
| '/middleware/send-serverFn'
| '/cookies'
+ | '/factory'
| '/formdata-redirect'
| '/middleware'
| '/formdata-redirect/target/$name'
@@ -242,6 +252,7 @@ export interface FileRouteTypes {
| '/middleware/client-middleware-router'
| '/middleware/send-serverFn'
| '/cookies'
+ | '/factory'
| '/formdata-redirect'
| '/middleware'
| '/formdata-redirect/target/$name'
@@ -264,6 +275,7 @@ export interface FileRouteTypes {
| '/middleware/client-middleware-router'
| '/middleware/send-serverFn'
| '/cookies/'
+ | '/factory/'
| '/formdata-redirect/'
| '/middleware/'
| '/formdata-redirect/target/$name'
@@ -287,6 +299,7 @@ export interface RootRouteChildren {
MiddlewareClientMiddlewareRouterRoute: typeof MiddlewareClientMiddlewareRouterRoute
MiddlewareSendServerFnRoute: typeof MiddlewareSendServerFnRoute
CookiesIndexRoute: typeof CookiesIndexRoute
+ FactoryIndexRoute: typeof FactoryIndexRoute
FormdataRedirectIndexRoute: typeof FormdataRedirectIndexRoute
MiddlewareIndexRoute: typeof MiddlewareIndexRoute
FormdataRedirectTargetNameRoute: typeof FormdataRedirectTargetNameRoute
@@ -399,6 +412,13 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof FormdataRedirectIndexRouteImport
parentRoute: typeof rootRouteImport
}
+ '/factory/': {
+ id: '/factory/'
+ path: '/factory'
+ fullPath: '/factory'
+ preLoaderRoute: typeof FactoryIndexRouteImport
+ parentRoute: typeof rootRouteImport
+ }
'/cookies/': {
id: '/cookies/'
path: '/cookies'
@@ -455,6 +475,7 @@ const rootRouteChildren: RootRouteChildren = {
MiddlewareClientMiddlewareRouterRoute: MiddlewareClientMiddlewareRouterRoute,
MiddlewareSendServerFnRoute: MiddlewareSendServerFnRoute,
CookiesIndexRoute: CookiesIndexRoute,
+ FactoryIndexRoute: FactoryIndexRoute,
FormdataRedirectIndexRoute: FormdataRedirectIndexRoute,
MiddlewareIndexRoute: MiddlewareIndexRoute,
FormdataRedirectTargetNameRoute: FormdataRedirectTargetNameRoute,
diff --git a/e2e/react-start/server-functions/src/routes/env-only.tsx b/e2e/react-start/server-functions/src/routes/env-only.tsx
index fe5ae8c1e8..2a938d692e 100644
--- a/e2e/react-start/server-functions/src/routes/env-only.tsx
+++ b/e2e/react-start/server-functions/src/routes/env-only.tsx
@@ -1,9 +1,13 @@
import { createFileRoute } from '@tanstack/react-router'
-import { clientOnly, createServerFn, serverOnly } from '@tanstack/react-start'
+import {
+ createClientOnlyFn,
+ createServerFn,
+ createServerOnlyFn,
+} from '@tanstack/react-start'
import { useState } from 'react'
-const serverEcho = serverOnly((input: string) => 'server got: ' + input)
-const clientEcho = clientOnly((input: string) => 'client got: ' + input)
+const serverEcho = createServerOnlyFn((input: string) => 'server got: ' + input)
+const clientEcho = createClientOnlyFn((input: string) => 'client got: ' + input)
const testOnServer = createServerFn().handler(() => {
const serverOnServer = serverEcho('hello')
diff --git a/e2e/react-start/server-functions/src/routes/factory/-functions/createBarServerFn.ts b/e2e/react-start/server-functions/src/routes/factory/-functions/createBarServerFn.ts
new file mode 100644
index 0000000000..4d622fcf9b
--- /dev/null
+++ b/e2e/react-start/server-functions/src/routes/factory/-functions/createBarServerFn.ts
@@ -0,0 +1,22 @@
+import { createMiddleware } from '@tanstack/react-start'
+import { createFooServerFn } from './createFooServerFn'
+
+const barMiddleware = createMiddleware({ type: 'function' }).server(
+ ({ next }) => {
+ console.log('Bar middleware triggered')
+ return next({
+ context: { bar: 'bar' } as const,
+ })
+ },
+)
+
+export const createBarServerFn = createFooServerFn().middleware([barMiddleware])
+
+export const barFnInsideFactoryFile = createBarServerFn().handler(
+ ({ context }) => {
+ return {
+ name: 'barFnInsideFactoryFile',
+ context,
+ }
+ },
+)
diff --git a/e2e/react-start/server-functions/src/routes/factory/-functions/createFakeFn.ts b/e2e/react-start/server-functions/src/routes/factory/-functions/createFakeFn.ts
new file mode 100644
index 0000000000..1c72733885
--- /dev/null
+++ b/e2e/react-start/server-functions/src/routes/factory/-functions/createFakeFn.ts
@@ -0,0 +1,5 @@
+export function createFakeFn() {
+ return {
+ handler: (cb: () => Promise) => cb,
+ }
+}
diff --git a/e2e/react-start/server-functions/src/routes/factory/-functions/createFooServerFn.ts b/e2e/react-start/server-functions/src/routes/factory/-functions/createFooServerFn.ts
new file mode 100644
index 0000000000..af13270b62
--- /dev/null
+++ b/e2e/react-start/server-functions/src/routes/factory/-functions/createFooServerFn.ts
@@ -0,0 +1,22 @@
+import { createMiddleware, createServerFn } from '@tanstack/react-start'
+
+const fooMiddleware = createMiddleware({ type: 'function' }).server(
+ ({ next }) => {
+ console.log('Foo middleware triggered')
+ return next({
+ context: { foo: 'foo' } as const,
+ })
+ },
+)
+
+export const createFooServerFn = createServerFn().middleware([fooMiddleware])
+
+export const fooFnInsideFactoryFile = createFooServerFn().handler(
+ async ({ context, method }) => {
+ console.log('fooFnInsideFactoryFile handler triggered', method)
+ return {
+ name: 'fooFnInsideFactoryFile',
+ context,
+ }
+ },
+)
diff --git a/e2e/react-start/server-functions/src/routes/factory/-functions/functions.ts b/e2e/react-start/server-functions/src/routes/factory/-functions/functions.ts
new file mode 100644
index 0000000000..35be5f91f7
--- /dev/null
+++ b/e2e/react-start/server-functions/src/routes/factory/-functions/functions.ts
@@ -0,0 +1,93 @@
+import { createMiddleware, createServerFn } from '@tanstack/react-start'
+import { createBarServerFn } from './createBarServerFn'
+import { createFooServerFn } from './createFooServerFn'
+import { createFakeFn } from './createFakeFn'
+
+export const fooFn = createFooServerFn().handler(({ context }) => {
+ return {
+ name: 'fooFn',
+ context,
+ }
+})
+
+export const fooFnPOST = createFooServerFn({ method: 'POST' }).handler(
+ ({ context }) => {
+ return {
+ name: 'fooFnPOST',
+ context,
+ }
+ },
+)
+
+export const barFn = createBarServerFn().handler(({ context }) => {
+ return {
+ name: 'barFn',
+ context,
+ }
+})
+
+export const barFnPOST = createBarServerFn({ method: 'POST' }).handler(
+ ({ context }) => {
+ return {
+ name: 'barFnPOST',
+ context,
+ }
+ },
+)
+
+const localMiddleware = createMiddleware({ type: 'function' }).server(
+ ({ next }) => {
+ console.log('local middleware triggered')
+ return next({
+ context: { local: 'local' } as const,
+ })
+ },
+)
+
+const localFnFactory = createBarServerFn.middleware([localMiddleware])
+
+const anotherMiddleware = createMiddleware({ type: 'function' }).server(
+ ({ next }) => {
+ console.log('another middleware triggered')
+ return next({
+ context: { another: 'another' } as const,
+ })
+ },
+)
+
+export const localFn = localFnFactory()
+ .middleware([anotherMiddleware])
+ .handler(({ context }) => {
+ return {
+ name: 'localFn',
+ context,
+ }
+ })
+
+export const localFnPOST = localFnFactory({ method: 'POST' })
+ .middleware([anotherMiddleware])
+ .handler(({ context }) => {
+ return {
+ name: 'localFnPOST',
+ context,
+ }
+ })
+
+export const fakeFn = createFakeFn().handler(async () => {
+ return {
+ name: 'fakeFn',
+ window,
+ }
+})
+
+export const composeFactory = createServerFn({ method: 'GET' }).middleware([
+ createBarServerFn,
+])
+export const composedFn = composeFactory()
+ .middleware([anotherMiddleware, localFnFactory])
+ .handler(({ context }) => {
+ return {
+ name: 'composedFn',
+ context,
+ }
+ })
diff --git a/e2e/react-start/server-functions/src/routes/factory/index.tsx b/e2e/react-start/server-functions/src/routes/factory/index.tsx
new file mode 100644
index 0000000000..cf16c362b1
--- /dev/null
+++ b/e2e/react-start/server-functions/src/routes/factory/index.tsx
@@ -0,0 +1,184 @@
+import { createFileRoute, deepEqual } from '@tanstack/react-router'
+
+import React from 'react'
+import { createServerFn } from '@tanstack/react-start'
+import { fooFnInsideFactoryFile } from './-functions/createFooServerFn'
+import {
+ barFn,
+ barFnPOST,
+ composedFn,
+ fakeFn,
+ fooFn,
+ fooFnPOST,
+ localFn,
+ localFnPOST,
+} from './-functions/functions'
+
+export const Route = createFileRoute('/factory/')({
+ ssr: false,
+ component: RouteComponent,
+})
+
+const fnInsideRoute = createServerFn({ method: 'GET' }).handler(() => {
+ return {
+ name: 'fnInsideRoute',
+ }
+})
+
+const functions = {
+ fnInsideRoute: {
+ fn: fnInsideRoute,
+ type: 'serverFn',
+ expected: {
+ name: 'fnInsideRoute',
+ },
+ },
+ fooFnInsideFactoryFile: {
+ fn: fooFnInsideFactoryFile,
+ type: 'serverFn',
+
+ expected: {
+ name: 'fooFnInsideFactoryFile',
+ context: { foo: 'foo' },
+ },
+ },
+ fooFn: {
+ fn: fooFn,
+ type: 'serverFn',
+
+ expected: {
+ name: 'fooFn',
+ context: { foo: 'foo' },
+ },
+ },
+ fooFnPOST: {
+ fn: fooFnPOST,
+ type: 'serverFn',
+
+ expected: {
+ name: 'fooFnPOST',
+ context: { foo: 'foo' },
+ },
+ },
+ barFn: {
+ fn: barFn,
+ type: 'serverFn',
+
+ expected: {
+ name: 'barFn',
+ context: { foo: 'foo', bar: 'bar' },
+ },
+ },
+ barFnPOST: {
+ fn: barFnPOST,
+ type: 'serverFn',
+
+ expected: {
+ name: 'barFnPOST',
+ context: { foo: 'foo', bar: 'bar' },
+ },
+ },
+ localFn: {
+ fn: localFn,
+ type: 'serverFn',
+
+ expected: {
+ name: 'localFn',
+ context: { foo: 'foo', bar: 'bar', local: 'local', another: 'another' },
+ },
+ },
+ localFnPOST: {
+ fn: localFnPOST,
+ type: 'serverFn',
+
+ expected: {
+ name: 'localFnPOST',
+ context: { foo: 'foo', bar: 'bar', local: 'local', another: 'another' },
+ },
+ },
+ composedFn: {
+ fn: composedFn,
+ type: 'serverFn',
+ expected: {
+ name: 'composedFn',
+ context: { foo: 'foo', bar: 'bar', another: 'another', local: 'local' },
+ },
+ },
+ fakeFn: {
+ fn: fakeFn,
+ type: 'localFn',
+ expected: {
+ name: 'fakeFn',
+ window,
+ },
+ },
+} satisfies Record
+
+interface TestCase {
+ fn: () => Promise
+ expected: any
+ type: 'serverFn' | 'localFn'
+}
+function Test({ fn, type, expected }: TestCase) {
+ const [result, setResult] = React.useState(null)
+ function comparison() {
+ if (result) {
+ const isEqual = deepEqual(result, expected)
+ return isEqual ? 'equal' : 'not equal'
+ }
+ return 'Loading...'
+ }
+
+ return (
+
+
+
+ It should return{' '}
+
+
+ {type === 'serverFn' ? JSON.stringify(expected) : 'localFn'}
+
+
+
+
+ fn returns:
+
+
+ {result
+ ? type === 'serverFn'
+ ? JSON.stringify(result)
+ : 'localFn'
+ : 'Loading...'}
+ {' '}
+
+ {comparison()}
+
+
+
{
+ fn().then(setResult)
+ }}
+ >
+ Invoke Server Function
+
+
+ )
+}
+function RouteComponent() {
+ return (
+
+
+ Server functions middleware E2E tests
+
+ {Object.entries(functions).map(([name, testCase]) => (
+
+ ))}
+
+ )
+}
diff --git a/e2e/react-start/server-functions/src/routes/headers.tsx b/e2e/react-start/server-functions/src/routes/headers.tsx
index 77c576e40b..79b05c0fcb 100644
--- a/e2e/react-start/server-functions/src/routes/headers.tsx
+++ b/e2e/react-start/server-functions/src/routes/headers.tsx
@@ -1,8 +1,11 @@
import { createFileRoute } from '@tanstack/react-router'
import * as React from 'react'
import { createServerFn } from '@tanstack/react-start'
-import { getHeaders, setHeader } from '@tanstack/react-start/server'
-import type { HTTPHeaderName } from '@tanstack/react-start/server'
+import {
+ getRequestHeaders,
+ setResponseHeader,
+} from '@tanstack/react-start/server'
+import type { RequestHeaderName } from '@tanstack/react-start/server'
export const Route = createFileRoute('/headers')({
loader: async () => {
@@ -17,17 +20,18 @@ export const Route = createFileRoute('/headers')({
})
export const getTestHeaders = createServerFn().handler(() => {
- setHeader('x-test-header', 'test-value')
+ setResponseHeader('x-test-header', 'test-value')
+ const reqHeaders = Object.fromEntries(getRequestHeaders().entries())
return {
- serverHeaders: getHeaders(),
- headers: getHeaders(),
+ serverHeaders: reqHeaders,
+ headers: reqHeaders,
}
})
type TestHeadersResult = {
- headers?: Partial>
- serverHeaders?: Partial>
+ headers?: Partial>
+ serverHeaders?: Partial>
}
function ResponseHeaders({
diff --git a/e2e/react-start/server-functions/src/routes/index.tsx b/e2e/react-start/server-functions/src/routes/index.tsx
index 949cc08f58..6251940689 100644
--- a/e2e/react-start/server-functions/src/routes/index.tsx
+++ b/e2e/react-start/server-functions/src/routes/index.tsx
@@ -85,6 +85,9 @@ function Home() {
Server Functions Middlware E2E tests
+
+ Server Functions Factory E2E tests
+
)
diff --git a/e2e/react-start/server-functions/src/routes/raw-response.tsx b/e2e/react-start/server-functions/src/routes/raw-response.tsx
index 8da5f8af7d..f30ff6660e 100644
--- a/e2e/react-start/server-functions/src/routes/raw-response.tsx
+++ b/e2e/react-start/server-functions/src/routes/raw-response.tsx
@@ -8,7 +8,7 @@ export const Route = createFileRoute('/raw-response')({
})
const expectedValue = 'Hello from a server function!'
-export const rawResponseFn = createServerFn({ response: 'raw' }).handler(() => {
+export const rawResponseFn = createServerFn().handler(() => {
return new Response(expectedValue)
})
diff --git a/e2e/react-start/server-functions/src/routes/serialize-form-data.tsx b/e2e/react-start/server-functions/src/routes/serialize-form-data.tsx
index b1b9dc777a..5429df98c8 100644
--- a/e2e/react-start/server-functions/src/routes/serialize-form-data.tsx
+++ b/e2e/react-start/server-functions/src/routes/serialize-form-data.tsx
@@ -15,7 +15,7 @@ const testValues = {
__adder: 1,
}
-export const greetUser = createServerFn()
+export const greetUser = createServerFn({ method: 'POST' })
.validator((data: FormData) => {
if (!(data instanceof FormData)) {
throw new Error('Invalid! FormData is required')
diff --git a/e2e/react-start/server-functions/src/routes/submit-post-formdata.tsx b/e2e/react-start/server-functions/src/routes/submit-post-formdata.tsx
index 05df922817..4369239a05 100644
--- a/e2e/react-start/server-functions/src/routes/submit-post-formdata.tsx
+++ b/e2e/react-start/server-functions/src/routes/submit-post-formdata.tsx
@@ -9,7 +9,7 @@ const testValues = {
name: 'Sean',
}
-export const greetUser = createServerFn({ method: 'POST', response: 'raw' })
+export const greetUser = createServerFn({ method: 'POST' })
.validator((data: FormData) => {
if (!(data instanceof FormData)) {
throw new Error('Invalid! FormData is required')
diff --git a/e2e/react-start/server-functions/tests/fixture.ts b/e2e/react-start/server-functions/tests/fixture.ts
deleted file mode 100644
index abb7b1d564..0000000000
--- a/e2e/react-start/server-functions/tests/fixture.ts
+++ /dev/null
@@ -1,28 +0,0 @@
-import { test as base, expect } from '@playwright/test'
-
-export interface TestFixtureOptions {
- whitelistErrors: Array
-}
-export const test = base.extend({
- whitelistErrors: [[], { option: true }],
- page: async ({ page, whitelistErrors }, use) => {
- const errorMessages: Array = []
- page.on('console', (m) => {
- if (m.type() === 'error') {
- const text = m.text()
- for (const whitelistError of whitelistErrors) {
- if (
- (typeof whitelistError === 'string' &&
- text.includes(whitelistError)) ||
- (whitelistError instanceof RegExp && whitelistError.test(text))
- ) {
- return
- }
- }
- errorMessages.push(text)
- }
- })
- await use(page)
- expect(errorMessages).toEqual([])
- },
-})
diff --git a/e2e/react-start/server-functions/tests/server-functions.spec.ts b/e2e/react-start/server-functions/tests/server-functions.spec.ts
index 86332e7491..990487289f 100644
--- a/e2e/react-start/server-functions/tests/server-functions.spec.ts
+++ b/e2e/react-start/server-functions/tests/server-functions.spec.ts
@@ -1,8 +1,11 @@
import * as fs from 'node:fs'
-import { expect, test } from '@playwright/test'
-import { PORT } from '../playwright.config'
+import { expect } from '@playwright/test'
+import { getTestServerPort, test } from '@tanstack/router-e2e-utils'
+import packageJson from '../package.json' with { type: 'json' }
import type { Page } from '@playwright/test'
+const PORT = await getTestServerPort(packageJson.name)
+
test('invoking a server function with custom response status code', async ({
page,
}) => {
@@ -11,16 +14,10 @@ test('invoking a server function with custom response status code', async ({
await page.waitForLoadState('networkidle')
const requestPromise = new Promise((resolve) => {
- page.on('response', async (response) => {
+ page.on('response', (response) => {
expect(response.status()).toBe(225)
expect(response.statusText()).toBe('hello')
- expect(response.headers()['content-type']).toBe('application/json')
- expect(await response.json()).toEqual(
- expect.objectContaining({
- result: { hello: 'world' },
- context: {},
- }),
- )
+ expect(response.headers()['content-type']).toContain('application/json')
resolve()
})
})
@@ -122,11 +119,11 @@ test('env-only functions can only be called on the server or client respectively
'server got: hello',
)
await expect(page.getByTestId('server-on-client')).toContainText(
- 'serverEcho threw an error: serverOnly() functions can only be called on the server!',
+ 'serverEcho threw an error: createServerOnlyFn() functions can only be called on the server!',
)
await expect(page.getByTestId('client-on-server')).toContainText(
- 'clientEcho threw an error: clientOnly() functions can only be called on the client!',
+ 'clientEcho threw an error: createClientOnlyFn() functions can only be called on the client!',
)
await expect(page.getByTestId('client-on-client')).toContainText(
'client got: hello',
@@ -372,3 +369,37 @@ test.describe('middleware', () => {
})
})
})
+
+test('factory', async ({ page }) => {
+ await page.goto('/factory')
+
+ await expect(page.getByTestId('factory-route-component')).toBeInViewport()
+
+ const buttons = await page
+ .locator('[data-testid^="btn-fn-"]')
+ .elementHandles()
+ for (const button of buttons) {
+ const testId = await button.getAttribute('data-testid')
+
+ if (!testId) {
+ throw new Error('Button is missing data-testid')
+ }
+
+ const suffix = testId.replace('btn-fn-', '')
+
+ const expected =
+ (await page.getByTestId(`expected-fn-result-${suffix}`).textContent()) ||
+ ''
+ expect(expected).not.toBe('')
+
+ await button.click()
+
+ await expect(page.getByTestId(`fn-result-${suffix}`)).toContainText(
+ expected,
+ )
+
+ await expect(page.getByTestId(`fn-comparison-${suffix}`)).toContainText(
+ 'equal',
+ )
+ }
+})
diff --git a/e2e/react-start/server-functions/vite.config.ts b/e2e/react-start/server-functions/vite.config.ts
index 1df337cd40..dc57f144e4 100644
--- a/e2e/react-start/server-functions/vite.config.ts
+++ b/e2e/react-start/server-functions/vite.config.ts
@@ -1,6 +1,7 @@
import { defineConfig } from 'vite'
import tsConfigPaths from 'vite-tsconfig-paths'
import { tanstackStart } from '@tanstack/react-start/plugin/vite'
+import viteReact from '@vitejs/plugin-react'
export default defineConfig({
plugins: [
@@ -8,5 +9,6 @@ export default defineConfig({
projects: ['./tsconfig.json'],
}),
tanstackStart(),
+ viteReact(),
],
})
diff --git a/e2e/react-start/server-routes/package.json b/e2e/react-start/server-routes/package.json
index e7352c35ce..614c5d1552 100644
--- a/e2e/react-start/server-routes/package.json
+++ b/e2e/react-start/server-routes/package.json
@@ -7,7 +7,7 @@
"dev": "vite dev --port 3000",
"dev:e2e": "vite dev",
"build": "vite build && tsc --noEmit",
- "start": "node .output/server/index.mjs",
+ "start": "pnpx srvx --prod -s ../client dist/server/server.js",
"test:e2e": "playwright test --project=chromium"
},
"dependencies": {
@@ -19,7 +19,7 @@
"react-dom": "^19.0.0",
"redaxios": "^0.5.1",
"tailwind-merge": "^2.6.0",
- "vite": "^6.3.5",
+ "vite": "^7.1.1",
"zod": "^3.24.2"
},
"devDependencies": {
@@ -33,6 +33,7 @@
"autoprefixer": "^10.4.20",
"combinate": "^1.1.11",
"postcss": "^8.5.1",
+ "srvx": "^0.8.6",
"tailwindcss": "^3.4.17",
"typescript": "^5.7.2",
"vite-tsconfig-paths": "^5.1.4"
diff --git a/e2e/react-start/server-routes/tests/fixture.ts b/e2e/react-start/server-routes/tests/fixture.ts
deleted file mode 100644
index abb7b1d564..0000000000
--- a/e2e/react-start/server-routes/tests/fixture.ts
+++ /dev/null
@@ -1,28 +0,0 @@
-import { test as base, expect } from '@playwright/test'
-
-export interface TestFixtureOptions {
- whitelistErrors: Array
-}
-export const test = base.extend({
- whitelistErrors: [[], { option: true }],
- page: async ({ page, whitelistErrors }, use) => {
- const errorMessages: Array = []
- page.on('console', (m) => {
- if (m.type() === 'error') {
- const text = m.text()
- for (const whitelistError of whitelistErrors) {
- if (
- (typeof whitelistError === 'string' &&
- text.includes(whitelistError)) ||
- (whitelistError instanceof RegExp && whitelistError.test(text))
- ) {
- return
- }
- }
- errorMessages.push(text)
- }
- })
- await use(page)
- expect(errorMessages).toEqual([])
- },
-})
diff --git a/e2e/react-start/server-routes/tests/server-routes.spec.ts b/e2e/react-start/server-routes/tests/server-routes.spec.ts
index 098a40b2ef..33176a23fd 100644
--- a/e2e/react-start/server-routes/tests/server-routes.spec.ts
+++ b/e2e/react-start/server-routes/tests/server-routes.spec.ts
@@ -1,4 +1,5 @@
-import { expect, test } from '@playwright/test'
+import { expect } from '@playwright/test'
+import { test } from '@tanstack/router-e2e-utils'
test('merge-server-fn-middleware-context', async ({ page }) => {
await page.goto('/merge-server-fn-middleware-context')
diff --git a/e2e/react-start/server-routes/vite.config.ts b/e2e/react-start/server-routes/vite.config.ts
index 1df337cd40..dc57f144e4 100644
--- a/e2e/react-start/server-routes/vite.config.ts
+++ b/e2e/react-start/server-routes/vite.config.ts
@@ -1,6 +1,7 @@
import { defineConfig } from 'vite'
import tsConfigPaths from 'vite-tsconfig-paths'
import { tanstackStart } from '@tanstack/react-start/plugin/vite'
+import viteReact from '@vitejs/plugin-react'
export default defineConfig({
plugins: [
@@ -8,5 +9,6 @@ export default defineConfig({
projects: ['./tsconfig.json'],
}),
tanstackStart(),
+ viteReact(),
],
})
diff --git a/e2e/react-start/spa-mode/package.json b/e2e/react-start/spa-mode/package.json
index ec5aaa4d5d..ae48f46c88 100644
--- a/e2e/react-start/spa-mode/package.json
+++ b/e2e/react-start/spa-mode/package.json
@@ -7,7 +7,7 @@
"dev": "vite dev --port 3000",
"dev:e2e": "vite dev",
"build": "vite build && tsc --noEmit",
- "start": "npx serve .output/public",
+ "start": "npx serve dist/client",
"test:e2e": "rm -rf port*.txt; playwright test --project=chromium"
},
"dependencies": {
@@ -25,7 +25,7 @@
"postcss": "^8.5.1",
"tailwindcss": "^3.4.17",
"typescript": "^5.7.2",
- "vite": "^6.3.5",
+ "vite": "^7.1.1",
"vite-tsconfig-paths": "^5.1.4"
}
}
diff --git a/e2e/react-start/spa-mode/tests/app.spec.ts b/e2e/react-start/spa-mode/tests/app.spec.ts
index 8970ec333c..c18a0ff65d 100644
--- a/e2e/react-start/spa-mode/tests/app.spec.ts
+++ b/e2e/react-start/spa-mode/tests/app.spec.ts
@@ -1,5 +1,5 @@
import { expect } from '@playwright/test'
-import { test } from './fixture'
+import { test } from '@tanstack/router-e2e-utils'
import type { Page } from '@playwright/test'
async function runTest(
diff --git a/e2e/react-start/spa-mode/tests/fixture.ts b/e2e/react-start/spa-mode/tests/fixture.ts
deleted file mode 100644
index abb7b1d564..0000000000
--- a/e2e/react-start/spa-mode/tests/fixture.ts
+++ /dev/null
@@ -1,28 +0,0 @@
-import { test as base, expect } from '@playwright/test'
-
-export interface TestFixtureOptions {
- whitelistErrors: Array
-}
-export const test = base.extend({
- whitelistErrors: [[], { option: true }],
- page: async ({ page, whitelistErrors }, use) => {
- const errorMessages: Array = []
- page.on('console', (m) => {
- if (m.type() === 'error') {
- const text = m.text()
- for (const whitelistError of whitelistErrors) {
- if (
- (typeof whitelistError === 'string' &&
- text.includes(whitelistError)) ||
- (whitelistError instanceof RegExp && whitelistError.test(text))
- ) {
- return
- }
- }
- errorMessages.push(text)
- }
- })
- await use(page)
- expect(errorMessages).toEqual([])
- },
-})
diff --git a/e2e/react-start/virtual-routes/package.json b/e2e/react-start/virtual-routes/package.json
index 3347f1e995..b4f3b6b6ed 100644
--- a/e2e/react-start/virtual-routes/package.json
+++ b/e2e/react-start/virtual-routes/package.json
@@ -7,7 +7,7 @@
"dev": "vite dev --port 3000",
"dev:e2e": "vite dev",
"build": "vite build && tsc --noEmit",
- "start": "node .output/server/index.mjs",
+ "start": "pnpx srvx --prod -s ../client dist/server/server.js",
"test:e2e": "rm -rf port*.txt; playwright test --project=chromium"
},
"dependencies": {
@@ -19,7 +19,7 @@
"react-dom": "^19.0.0",
"redaxios": "^0.5.1",
"tailwind-merge": "^2.6.0",
- "vite": "^6.3.5",
+ "vite": "^7.1.1",
"zod": "^3.24.2"
},
"devDependencies": {
@@ -32,6 +32,7 @@
"autoprefixer": "^10.4.20",
"combinate": "^1.1.11",
"postcss": "^8.5.1",
+ "srvx": "^0.8.6",
"tailwindcss": "^3.4.17",
"typescript": "^5.7.2",
"vite-tsconfig-paths": "^5.1.4"
diff --git a/e2e/react-start/virtual-routes/vite.config.ts b/e2e/react-start/virtual-routes/vite.config.ts
index 21ff4c2940..110811e198 100644
--- a/e2e/react-start/virtual-routes/vite.config.ts
+++ b/e2e/react-start/virtual-routes/vite.config.ts
@@ -11,7 +11,7 @@ export default defineConfig({
projects: ['./tsconfig.json'],
}),
tanstackStart({
- tsr: {
+ router: {
virtualRouteConfig: './routes.ts',
},
}),
diff --git a/e2e/react-start/website/package.json b/e2e/react-start/website/package.json
index 2990a23c08..5d54afc056 100644
--- a/e2e/react-start/website/package.json
+++ b/e2e/react-start/website/package.json
@@ -7,7 +7,7 @@
"dev": "vite dev --port 3000",
"dev:e2e": "vite dev",
"build": "vite build && tsc --noEmit",
- "start": "node .output/server/index.mjs",
+ "start": "pnpx srvx --prod -s ../client dist/server/server.js",
"test:e2e": "rm -rf port*.txt; playwright test --project=chromium"
},
"dependencies": {
@@ -29,9 +29,10 @@
"@vitejs/plugin-react": "^4.3.4",
"autoprefixer": "^10.4.20",
"postcss": "^8.5.1",
+ "srvx": "^0.8.6",
"tailwindcss": "^3.4.17",
"typescript": "^5.7.2",
- "vite": "^6.3.5",
+ "vite": "^7.1.1",
"vite-tsconfig-paths": "^5.1.4"
}
}
diff --git a/e2e/react-start/website/vite.config.ts b/e2e/react-start/website/vite.config.ts
index a1b3d840f5..c2c28ae93b 100644
--- a/e2e/react-start/website/vite.config.ts
+++ b/e2e/react-start/website/vite.config.ts
@@ -1,6 +1,7 @@
import { defineConfig } from 'vite'
import tsConfigPaths from 'vite-tsconfig-paths'
import { tanstackStart } from '@tanstack/react-start/plugin/vite'
+import viteReact from '@vitejs/plugin-react'
export default defineConfig({
server: {
@@ -11,5 +12,6 @@ export default defineConfig({
projects: ['./tsconfig.json'],
}),
tanstackStart(),
+ viteReact(),
],
})
diff --git a/e2e/solid-router/basic-file-based-code-splitting/package.json b/e2e/solid-router/basic-file-based-code-splitting/package.json
index 6a929a45bc..05739aa9c5 100644
--- a/e2e/solid-router/basic-file-based-code-splitting/package.json
+++ b/e2e/solid-router/basic-file-based-code-splitting/package.json
@@ -25,7 +25,7 @@
"devDependencies": {
"@playwright/test": "^1.50.1",
"@tanstack/router-e2e-utils": "workspace:^",
- "vite": "^6.3.5",
- "vite-plugin-solid": "^2.11.2"
+ "vite": "^7.1.1",
+ "vite-plugin-solid": "^2.11.8"
}
}
diff --git a/e2e/solid-router/basic-file-based/package.json b/e2e/solid-router/basic-file-based/package.json
index 50b911f89a..f3a3019b46 100644
--- a/e2e/solid-router/basic-file-based/package.json
+++ b/e2e/solid-router/basic-file-based/package.json
@@ -25,8 +25,8 @@
"devDependencies": {
"@playwright/test": "^1.50.1",
"@tanstack/router-e2e-utils": "workspace:^",
- "vite-plugin-solid": "^2.11.2",
+ "vite-plugin-solid": "^2.11.8",
"combinate": "^1.1.11",
- "vite": "^6.3.5"
+ "vite": "^7.1.1"
}
}
diff --git a/e2e/solid-router/basic-scroll-restoration/package.json b/e2e/solid-router/basic-scroll-restoration/package.json
index 99eadce4ed..b1eef16702 100644
--- a/e2e/solid-router/basic-scroll-restoration/package.json
+++ b/e2e/solid-router/basic-scroll-restoration/package.json
@@ -23,7 +23,7 @@
"devDependencies": {
"@playwright/test": "^1.50.1",
"@tanstack/router-e2e-utils": "workspace:^",
- "vite-plugin-solid": "^2.11.2",
- "vite": "^6.3.5"
+ "vite-plugin-solid": "^2.11.8",
+ "vite": "^7.1.1"
}
}
diff --git a/e2e/solid-router/basic-solid-query-file-based/package.json b/e2e/solid-router/basic-solid-query-file-based/package.json
index cff6d8c71c..2d9ccafe20 100644
--- a/e2e/solid-router/basic-solid-query-file-based/package.json
+++ b/e2e/solid-router/basic-solid-query-file-based/package.json
@@ -26,7 +26,7 @@
"devDependencies": {
"@playwright/test": "^1.50.1",
"@tanstack/router-e2e-utils": "workspace:^",
- "vite-plugin-solid": "^2.11.2",
- "vite": "^6.3.5"
+ "vite-plugin-solid": "^2.11.8",
+ "vite": "^7.1.1"
}
}
diff --git a/e2e/solid-router/basic-solid-query/package.json b/e2e/solid-router/basic-solid-query/package.json
index 61c7fa9fd3..4a1346f52e 100644
--- a/e2e/solid-router/basic-solid-query/package.json
+++ b/e2e/solid-router/basic-solid-query/package.json
@@ -24,7 +24,7 @@
"devDependencies": {
"@playwright/test": "^1.50.1",
"@tanstack/router-e2e-utils": "workspace:^",
- "vite-plugin-solid": "^2.11.2",
- "vite": "^6.3.5"
+ "vite-plugin-solid": "^2.11.8",
+ "vite": "^7.1.1"
}
}
diff --git a/e2e/solid-router/basic-virtual-file-based/package.json b/e2e/solid-router/basic-virtual-file-based/package.json
index 7e6f8ec3cd..3a19c7f602 100644
--- a/e2e/solid-router/basic-virtual-file-based/package.json
+++ b/e2e/solid-router/basic-virtual-file-based/package.json
@@ -25,7 +25,7 @@
"devDependencies": {
"@playwright/test": "^1.50.1",
"@tanstack/router-e2e-utils": "workspace:^",
- "vite-plugin-solid": "^2.11.2",
- "vite": "^6.3.5"
+ "vite-plugin-solid": "^2.11.8",
+ "vite": "^7.1.1"
}
}
diff --git a/e2e/solid-router/basic-virtual-named-export-config-file-based/package.json b/e2e/solid-router/basic-virtual-named-export-config-file-based/package.json
index 212cb73be7..6f57ade84c 100644
--- a/e2e/solid-router/basic-virtual-named-export-config-file-based/package.json
+++ b/e2e/solid-router/basic-virtual-named-export-config-file-based/package.json
@@ -25,7 +25,7 @@
"devDependencies": {
"@playwright/test": "^1.50.1",
"@tanstack/router-e2e-utils": "workspace:^",
- "vite-plugin-solid": "^2.11.2",
- "vite": "^6.3.5"
+ "vite-plugin-solid": "^2.11.8",
+ "vite": "^7.1.1"
}
}
diff --git a/e2e/solid-router/basic/package.json b/e2e/solid-router/basic/package.json
index 9634148185..930f065ce8 100644
--- a/e2e/solid-router/basic/package.json
+++ b/e2e/solid-router/basic/package.json
@@ -22,7 +22,7 @@
"devDependencies": {
"@playwright/test": "^1.50.1",
"@tanstack/router-e2e-utils": "workspace:^",
- "vite-plugin-solid": "^2.11.2",
- "vite": "^6.3.5"
+ "vite-plugin-solid": "^2.11.8",
+ "vite": "^7.1.1"
}
}
diff --git a/e2e/solid-router/scroll-restoration-sandbox-vite/package.json b/e2e/solid-router/scroll-restoration-sandbox-vite/package.json
index 8d41ebe795..c39283cc58 100644
--- a/e2e/solid-router/scroll-restoration-sandbox-vite/package.json
+++ b/e2e/solid-router/scroll-restoration-sandbox-vite/package.json
@@ -28,7 +28,7 @@
"devDependencies": {
"@playwright/test": "^1.50.1",
"@tanstack/router-e2e-utils": "workspace:^",
- "vite-plugin-solid": "^2.11.2",
- "vite": "^6.3.5"
+ "vite-plugin-solid": "^2.11.8",
+ "vite": "^7.1.1"
}
}
diff --git a/e2e/solid-start/basic-tsr-config/package.json b/e2e/solid-start/basic-tsr-config/package.json
index 97d12fa5ba..e94beef5ee 100644
--- a/e2e/solid-start/basic-tsr-config/package.json
+++ b/e2e/solid-start/basic-tsr-config/package.json
@@ -7,7 +7,7 @@
"dev": "vite dev --port 3000",
"dev:e2e": "vite dev",
"build": "rimraf ./count.txt && vite build && tsc --noEmit",
- "start": "node .output/server/index.mjs",
+ "start": "pnpx srvx --prod -s ../client dist/server/server.js",
"test:e2e": "rm -rf port*.txt; playwright test --project=chromium"
},
"dependencies": {
@@ -15,12 +15,14 @@
"@tanstack/solid-router-devtools": "workspace:^",
"@tanstack/solid-start": "workspace:^",
"solid-js": "^1.9.5",
- "vite": "6.3.5"
+ "vite": "^7.1.1"
},
"devDependencies": {
"@tanstack/router-e2e-utils": "workspace:^",
"@types/node": "^22.10.2",
+ "srvx": "^0.8.6",
"typescript": "^5.7.2",
+ "vite-plugin-solid": "^2.11.8",
"vite-tsconfig-paths": "^5.1.4"
}
}
diff --git a/e2e/solid-start/basic-tsr-config/tests/app.spec.ts b/e2e/solid-start/basic-tsr-config/tests/app.spec.ts
index e3488df952..782007684a 100644
--- a/e2e/solid-start/basic-tsr-config/tests/app.spec.ts
+++ b/e2e/solid-start/basic-tsr-config/tests/app.spec.ts
@@ -3,6 +3,7 @@ import { expect, test } from '@playwright/test'
test('opening the app', async ({ page }) => {
await page.goto('/')
+ await page.waitForLoadState('networkidle')
await expect(page.getByTestId('add-button')).toContainText('Add 1 to 0?')
await page.getByTestId('add-button').click()
await page.waitForLoadState('networkidle')
diff --git a/e2e/solid-start/basic-tsr-config/vite.config.ts b/e2e/solid-start/basic-tsr-config/vite.config.ts
index 347962b83d..fa5673a503 100644
--- a/e2e/solid-start/basic-tsr-config/vite.config.ts
+++ b/e2e/solid-start/basic-tsr-config/vite.config.ts
@@ -1,6 +1,7 @@
import { defineConfig } from 'vite'
import tsConfigPaths from 'vite-tsconfig-paths'
import { tanstackStart } from '@tanstack/solid-start/plugin/vite'
+import viteSolid from 'vite-plugin-solid'
export default defineConfig({
server: {
@@ -11,9 +12,8 @@ export default defineConfig({
projects: ['./tsconfig.json'],
}),
tanstackStart({
- tsr: {
- srcDirectory: './src/app',
- },
+ srcDirectory: './src/app',
}),
+ viteSolid({ ssr: true }),
],
})
diff --git a/e2e/solid-start/basic/package.json b/e2e/solid-start/basic/package.json
index c7b631c1d6..d3515f9eaf 100644
--- a/e2e/solid-start/basic/package.json
+++ b/e2e/solid-start/basic/package.json
@@ -7,7 +7,7 @@
"dev": "vite dev --port 3000",
"dev:e2e": "vite dev",
"build": "vite build && tsc --noEmit",
- "start": "node .output/server/index.mjs",
+ "start": "pnpx srvx --prod -s ../client dist/server/server.js",
"test:e2e": "rm -rf port*.txt; playwright test --project=chromium"
},
"dependencies": {
@@ -17,7 +17,7 @@
"redaxios": "^0.5.1",
"solid-js": "^1.9.5",
"tailwind-merge": "^2.6.0",
- "vite": "6.3.5",
+ "vite": "^7.1.1",
"zod": "^3.24.2"
},
"devDependencies": {
@@ -27,9 +27,10 @@
"autoprefixer": "^10.4.20",
"combinate": "^1.1.11",
"postcss": "^8.5.1",
+ "srvx": "^0.8.6",
"tailwindcss": "^3.4.17",
"typescript": "^5.7.2",
- "vite-plugin-solid": "^2.11.2",
+ "vite-plugin-solid": "^2.11.8",
"vite-tsconfig-paths": "^5.1.4"
}
}
diff --git a/e2e/solid-start/basic/src/server.ts b/e2e/solid-start/basic/src/server.ts
index f9fbb3a2d5..dc9f547478 100644
--- a/e2e/solid-start/basic/src/server.ts
+++ b/e2e/solid-start/basic/src/server.ts
@@ -8,6 +8,10 @@ import { createRouter } from './router'
console.log("[server-entry]: using custom server entry in 'src/server.ts'")
-export default createStartHandler({
+const fetch = createStartHandler({
createRouter,
})(defaultStreamHandler)
+
+export default {
+ fetch,
+}
diff --git a/e2e/solid-start/basic/tests/fixture.ts b/e2e/solid-start/basic/tests/fixture.ts
deleted file mode 100644
index abb7b1d564..0000000000
--- a/e2e/solid-start/basic/tests/fixture.ts
+++ /dev/null
@@ -1,28 +0,0 @@
-import { test as base, expect } from '@playwright/test'
-
-export interface TestFixtureOptions {
- whitelistErrors: Array
-}
-export const test = base.extend({
- whitelistErrors: [[], { option: true }],
- page: async ({ page, whitelistErrors }, use) => {
- const errorMessages: Array = []
- page.on('console', (m) => {
- if (m.type() === 'error') {
- const text = m.text()
- for (const whitelistError of whitelistErrors) {
- if (
- (typeof whitelistError === 'string' &&
- text.includes(whitelistError)) ||
- (whitelistError instanceof RegExp && whitelistError.test(text))
- ) {
- return
- }
- }
- errorMessages.push(text)
- }
- })
- await use(page)
- expect(errorMessages).toEqual([])
- },
-})
diff --git a/e2e/solid-start/basic/tests/navigation.spec.ts b/e2e/solid-start/basic/tests/navigation.spec.ts
index 5d21f2adbe..b73d4ddf09 100644
--- a/e2e/solid-start/basic/tests/navigation.spec.ts
+++ b/e2e/solid-start/basic/tests/navigation.spec.ts
@@ -1,5 +1,11 @@
-import { expect, test } from '@playwright/test'
+import { expect } from '@playwright/test'
+import { test } from '@tanstack/router-e2e-utils'
+test.use({
+ whitelistErrors: [
+ /Failed to load resource: the server responded with a status of 404/,
+ ],
+})
test('Navigating to post', async ({ page }) => {
await page.goto('/')
diff --git a/e2e/solid-start/basic/tests/not-found.spec.ts b/e2e/solid-start/basic/tests/not-found.spec.ts
index 0d83ab5280..ab1c94eee9 100644
--- a/e2e/solid-start/basic/tests/not-found.spec.ts
+++ b/e2e/solid-start/basic/tests/not-found.spec.ts
@@ -1,6 +1,6 @@
import { expect } from '@playwright/test'
import combinateImport from 'combinate'
-import { test } from './fixture'
+import { test } from '@tanstack/router-e2e-utils'
// somehow playwright does not correctly import default exports
const combinate = (combinateImport as any).default as typeof combinateImport
diff --git a/e2e/solid-start/basic/tests/redirect.spec.ts b/e2e/solid-start/basic/tests/redirect.spec.ts
index 87e93a42e6..78c57d6a00 100644
--- a/e2e/solid-start/basic/tests/redirect.spec.ts
+++ b/e2e/solid-start/basic/tests/redirect.spec.ts
@@ -4,9 +4,9 @@ import combinateImport from 'combinate'
import {
getDummyServerPort,
getTestServerPort,
+ test,
} from '@tanstack/router-e2e-utils'
import packageJson from '../package.json' with { type: 'json' }
-import { test } from './fixture'
// somehow playwright does not correctly import default exports
const combinate = (combinateImport as any).default as typeof combinateImport
@@ -184,6 +184,8 @@ test.describe('redirects', () => {
await page.goto(`/redirect/${target}/serverFn/via-useServerFn?${q}`)
+ await page.waitForLoadState('networkidle')
+
const button = page.getByTestId('redirect-on-click')
let fullPageLoad = false
diff --git a/e2e/solid-start/basic/tests/search-params.spec.ts b/e2e/solid-start/basic/tests/search-params.spec.ts
index 23cd97517d..d7ce617890 100644
--- a/e2e/solid-start/basic/tests/search-params.spec.ts
+++ b/e2e/solid-start/basic/tests/search-params.spec.ts
@@ -1,5 +1,5 @@
import { expect } from '@playwright/test'
-import { test } from './fixture'
+import { test } from '@tanstack/router-e2e-utils'
import type { Response } from '@playwright/test'
function expectRedirect(response: Response | null, endsWith: string) {
diff --git a/e2e/solid-start/basic/tests/streaming.spec.ts b/e2e/solid-start/basic/tests/streaming.spec.ts
index 252bb192aa..15f60b7deb 100644
--- a/e2e/solid-start/basic/tests/streaming.spec.ts
+++ b/e2e/solid-start/basic/tests/streaming.spec.ts
@@ -1,4 +1,5 @@
-import { expect, test } from '@playwright/test'
+import { expect } from '@playwright/test'
+import { test } from '@tanstack/router-e2e-utils'
test('Navigating to deferred route', async ({ page }) => {
await page.goto('/')
diff --git a/e2e/solid-start/basic/vite.config.ts b/e2e/solid-start/basic/vite.config.ts
index 3af67d62ad..1a2219f443 100644
--- a/e2e/solid-start/basic/vite.config.ts
+++ b/e2e/solid-start/basic/vite.config.ts
@@ -1,6 +1,7 @@
import { defineConfig } from 'vite'
import tsConfigPaths from 'vite-tsconfig-paths'
import { tanstackStart } from '@tanstack/solid-start/plugin/vite'
+import viteSolid from 'vite-plugin-solid'
export default defineConfig({
server: {
@@ -10,6 +11,7 @@ export default defineConfig({
tsConfigPaths({
projects: ['./tsconfig.json'],
}),
- tanstackStart({}),
+ tanstackStart(),
+ viteSolid({ ssr: true }),
],
})
diff --git a/e2e/solid-start/custom-basepath/express-server.ts b/e2e/solid-start/custom-basepath/express-server.ts
new file mode 100644
index 0000000000..6fa802e447
--- /dev/null
+++ b/e2e/solid-start/custom-basepath/express-server.ts
@@ -0,0 +1,44 @@
+import express from 'express'
+import { toNodeHandler } from 'srvx/node'
+
+const DEVELOPMENT = process.env.NODE_ENV === 'development'
+const PORT = Number.parseInt(process.env.PORT || '3000')
+
+const app = express()
+
+if (DEVELOPMENT) {
+ const viteDevServer = await import('vite').then((vite) =>
+ vite.createServer({
+ server: { middlewareMode: true },
+ }),
+ )
+ app.use(viteDevServer.middlewares)
+ app.use(async (req, res, next) => {
+ try {
+ const { default: serverEntry } =
+ await viteDevServer.ssrLoadModule('./src/server.ts')
+ const handler = toNodeHandler(serverEntry.fetch)
+ await handler(req, res)
+ } catch (error) {
+ if (typeof error === 'object' && error instanceof Error) {
+ viteDevServer.ssrFixStacktrace(error)
+ }
+ next(error)
+ }
+ })
+} else {
+ const { default: handler } = await import('./dist/server/server.js')
+ const nodeHandler = toNodeHandler(handler.fetch)
+ app.use('/custom/basepath', express.static('dist/client'))
+ app.use(async (req, res, next) => {
+ try {
+ await nodeHandler(req, res)
+ } catch (error) {
+ next(error)
+ }
+ })
+}
+
+app.listen(PORT, () => {
+ console.log(`Server is running on http://localhost:${PORT}`)
+})
diff --git a/e2e/solid-start/custom-basepath/package.json b/e2e/solid-start/custom-basepath/package.json
index 1f668703a3..1b0755af31 100644
--- a/e2e/solid-start/custom-basepath/package.json
+++ b/e2e/solid-start/custom-basepath/package.json
@@ -4,32 +4,33 @@
"sideEffects": false,
"type": "module",
"scripts": {
- "dev": "vite dev --port 3000",
- "dev:e2e": "vite dev",
+ "dev": "cross-env NODE_ENV=development tsx express-server.ts",
"build": "vite build && tsc --noEmit",
- "start": "node .output/server/index.mjs",
+ "start": "tsx express-server.ts",
"test:e2e": "rm -rf port*.txt; playwright test --project=chromium"
},
"dependencies": {
"@tanstack/solid-router": "workspace:^",
"@tanstack/solid-router-devtools": "workspace:^",
"@tanstack/solid-start": "workspace:^",
+ "express": "^4.21.2",
"redaxios": "^0.5.1",
- "solid-js": "^1.9.5",
- "tailwind-merge": "^2.6.0",
- "vite": "6.3.5",
- "zod": "^3.24.2"
+ "solid-js": "^1.9.5"
},
"devDependencies": {
"@playwright/test": "^1.50.1",
"@tanstack/router-e2e-utils": "workspace:^",
+ "@types/express": "^5.0.3",
"@types/node": "^22.10.2",
"autoprefixer": "^10.4.20",
- "combinate": "^1.1.11",
+ "cross-env": "^10.0.0",
"postcss": "^8.5.1",
+ "srvx": "^0.8.6",
"tailwindcss": "^3.4.17",
+ "tsx": "^4.20.3",
"typescript": "^5.7.2",
- "vite-plugin-solid": "^2.11.2",
+ "vite": "^7.1.1",
+ "vite-plugin-solid": "^2.11.8",
"vite-tsconfig-paths": "^5.1.4"
}
}
diff --git a/e2e/solid-start/custom-basepath/src/server.ts b/e2e/solid-start/custom-basepath/src/server.ts
new file mode 100644
index 0000000000..d54db7edf0
--- /dev/null
+++ b/e2e/solid-start/custom-basepath/src/server.ts
@@ -0,0 +1,14 @@
+import {
+ createStartHandler,
+ defaultStreamHandler,
+} from '@tanstack/solid-start/server'
+
+import { createRouter } from './router'
+
+const fetch = createStartHandler({
+ createRouter,
+})(defaultStreamHandler)
+
+export default {
+ fetch,
+}
diff --git a/e2e/solid-start/custom-basepath/vite.config.ts b/e2e/solid-start/custom-basepath/vite.config.ts
index d6784f657c..4f0310eddf 100644
--- a/e2e/solid-start/custom-basepath/vite.config.ts
+++ b/e2e/solid-start/custom-basepath/vite.config.ts
@@ -1,6 +1,7 @@
import { defineConfig } from 'vite'
import tsConfigPaths from 'vite-tsconfig-paths'
import { tanstackStart } from '@tanstack/solid-start/plugin/vite'
+import viteSolid from 'vite-plugin-solid'
export default defineConfig({
base: '/custom/basepath',
@@ -11,6 +12,7 @@ export default defineConfig({
tsConfigPaths({
projects: ['./tsconfig.json'],
}),
- tanstackStart({}),
+ tanstackStart(),
+ viteSolid({ ssr: true }),
],
})
diff --git a/e2e/solid-start/scroll-restoration/package.json b/e2e/solid-start/scroll-restoration/package.json
index 60f64e7d04..8527fa97e4 100644
--- a/e2e/solid-start/scroll-restoration/package.json
+++ b/e2e/solid-start/scroll-restoration/package.json
@@ -7,7 +7,7 @@
"dev": "vite dev --port 3000",
"dev:e2e": "vite dev",
"build": "vite build && tsc --noEmit",
- "start": "node .output/server/index.mjs",
+ "start": "pnpx srvx --prod -s ../client dist/server/server.js",
"test:e2e": "rm -rf port*.txt; playwright test --project=chromium"
},
"dependencies": {
@@ -18,7 +18,7 @@
"redaxios": "^0.5.1",
"solid-js": "^1.9.5",
"tailwind-merge": "^2.6.0",
- "vite": "6.3.5",
+ "vite": "^7.1.1",
"zod": "^3.24.2"
},
"devDependencies": {
@@ -28,9 +28,10 @@
"autoprefixer": "^10.4.20",
"combinate": "^1.1.11",
"postcss": "^8.5.1",
+ "srvx": "^0.8.6",
"tailwindcss": "^3.4.17",
"typescript": "^5.7.2",
- "vite-plugin-solid": "^2.11.6",
+ "vite-plugin-solid": "^2.11.8",
"vite-tsconfig-paths": "^5.1.4"
}
}
diff --git a/e2e/solid-start/scroll-restoration/vite.config.ts b/e2e/solid-start/scroll-restoration/vite.config.ts
index 3af67d62ad..1a2219f443 100644
--- a/e2e/solid-start/scroll-restoration/vite.config.ts
+++ b/e2e/solid-start/scroll-restoration/vite.config.ts
@@ -1,6 +1,7 @@
import { defineConfig } from 'vite'
import tsConfigPaths from 'vite-tsconfig-paths'
import { tanstackStart } from '@tanstack/solid-start/plugin/vite'
+import viteSolid from 'vite-plugin-solid'
export default defineConfig({
server: {
@@ -10,6 +11,7 @@ export default defineConfig({
tsConfigPaths({
projects: ['./tsconfig.json'],
}),
- tanstackStart({}),
+ tanstackStart(),
+ viteSolid({ ssr: true }),
],
})
diff --git a/e2e/solid-start/selective-ssr/package.json b/e2e/solid-start/selective-ssr/package.json
index 3be0fee142..67a902cfe2 100644
--- a/e2e/solid-start/selective-ssr/package.json
+++ b/e2e/solid-start/selective-ssr/package.json
@@ -7,7 +7,7 @@
"dev": "vite dev --port 3000",
"dev:e2e": "vite dev",
"build": "vite build && tsc --noEmit",
- "start": "node .output/server/index.mjs",
+ "start": "pnpx srvx --prod -s ../client dist/server/server.js",
"test:e2e": "rm -rf port*.txt; playwright test --project=chromium"
},
"dependencies": {
@@ -19,9 +19,11 @@
"devDependencies": {
"@tanstack/router-e2e-utils": "workspace:^",
"postcss": "^8.5.1",
+ "srvx": "^0.8.6",
"tailwindcss": "^3.4.17",
"typescript": "^5.7.2",
- "vite": "^6.3.5",
+ "vite": "^7.1.1",
+ "vite-plugin-solid": "^2.11.8",
"vite-tsconfig-paths": "^5.1.4"
}
}
diff --git a/e2e/solid-start/selective-ssr/tests/app.spec.ts b/e2e/solid-start/selective-ssr/tests/app.spec.ts
index b013dfb169..aea216d506 100644
--- a/e2e/solid-start/selective-ssr/tests/app.spec.ts
+++ b/e2e/solid-start/selective-ssr/tests/app.spec.ts
@@ -1,5 +1,5 @@
import { expect } from '@playwright/test'
-import { test } from './fixture'
+import { test } from '@tanstack/router-e2e-utils'
const testCount = 7
diff --git a/e2e/solid-start/selective-ssr/tests/fixture.ts b/e2e/solid-start/selective-ssr/tests/fixture.ts
deleted file mode 100644
index abb7b1d564..0000000000
--- a/e2e/solid-start/selective-ssr/tests/fixture.ts
+++ /dev/null
@@ -1,28 +0,0 @@
-import { test as base, expect } from '@playwright/test'
-
-export interface TestFixtureOptions {
- whitelistErrors: Array
-}
-export const test = base.extend({
- whitelistErrors: [[], { option: true }],
- page: async ({ page, whitelistErrors }, use) => {
- const errorMessages: Array = []
- page.on('console', (m) => {
- if (m.type() === 'error') {
- const text = m.text()
- for (const whitelistError of whitelistErrors) {
- if (
- (typeof whitelistError === 'string' &&
- text.includes(whitelistError)) ||
- (whitelistError instanceof RegExp && whitelistError.test(text))
- ) {
- return
- }
- }
- errorMessages.push(text)
- }
- })
- await use(page)
- expect(errorMessages).toEqual([])
- },
-})
diff --git a/e2e/solid-start/selective-ssr/vite.config.ts b/e2e/solid-start/selective-ssr/vite.config.ts
index 151f2248f8..20ffdb3d6e 100644
--- a/e2e/solid-start/selective-ssr/vite.config.ts
+++ b/e2e/solid-start/selective-ssr/vite.config.ts
@@ -1,6 +1,7 @@
import { defineConfig } from 'vite'
import { tanstackStart } from '@tanstack/solid-start/plugin/vite'
import tsConfigPaths from 'vite-tsconfig-paths'
+import viteSolid from 'vite-plugin-solid'
export default defineConfig({
server: {
@@ -11,5 +12,6 @@ export default defineConfig({
projects: ['./tsconfig.json'],
}),
tanstackStart(),
+ viteSolid({ ssr: true }),
],
})
diff --git a/e2e/solid-start/server-functions/package.json b/e2e/solid-start/server-functions/package.json
index 7a02e8266e..fb3d649934 100644
--- a/e2e/solid-start/server-functions/package.json
+++ b/e2e/solid-start/server-functions/package.json
@@ -7,7 +7,7 @@
"dev": "vite dev --port 3000",
"dev:e2e": "vite dev",
"build": "vite build && tsc --noEmit",
- "start": "node .output/server/index.mjs",
+ "start": "pnpx srvx --prod -s ../client dist/server/server.js",
"test:e2e": "rm -rf port*.txt; playwright test --project=chromium"
},
"dependencies": {
@@ -18,7 +18,7 @@
"redaxios": "^0.5.1",
"solid-js": "^1.9.5",
"tailwind-merge": "^2.6.0",
- "vite": "6.3.5",
+ "vite": "^7.1.1",
"zod": "^3.24.2"
},
"devDependencies": {
@@ -29,9 +29,10 @@
"autoprefixer": "^10.4.20",
"combinate": "^1.1.11",
"postcss": "^8.5.1",
+ "srvx": "^0.8.6",
"tailwindcss": "^3.4.17",
"typescript": "^5.7.2",
- "vite-plugin-solid": "^2.11.6",
+ "vite-plugin-solid": "^2.11.8",
"vite-tsconfig-paths": "^5.1.4"
}
}
diff --git a/e2e/solid-start/server-functions/src/routes/env-only.tsx b/e2e/solid-start/server-functions/src/routes/env-only.tsx
index df8f08eed2..85bcae0f60 100644
--- a/e2e/solid-start/server-functions/src/routes/env-only.tsx
+++ b/e2e/solid-start/server-functions/src/routes/env-only.tsx
@@ -1,9 +1,13 @@
import { createFileRoute } from '@tanstack/solid-router'
-import { clientOnly, createServerFn, serverOnly } from '@tanstack/solid-start'
+import {
+ createClientOnlyFn,
+ createServerFn,
+ createServerOnlyFn,
+} from '@tanstack/solid-start'
import { createSignal } from 'solid-js'
-const serverEcho = serverOnly((input: string) => 'server got: ' + input)
-const clientEcho = clientOnly((input: string) => 'client got: ' + input)
+const serverEcho = createServerOnlyFn((input: string) => 'server got: ' + input)
+const clientEcho = createClientOnlyFn((input: string) => 'client got: ' + input)
const testOnServer = createServerFn().handler(() => {
const serverOnServer = serverEcho('hello')
diff --git a/e2e/solid-start/server-functions/src/routes/headers.tsx b/e2e/solid-start/server-functions/src/routes/headers.tsx
index 3b1ce8d499..132f304fbe 100644
--- a/e2e/solid-start/server-functions/src/routes/headers.tsx
+++ b/e2e/solid-start/server-functions/src/routes/headers.tsx
@@ -1,8 +1,11 @@
import { createFileRoute } from '@tanstack/solid-router'
import * as Solid from 'solid-js'
import { createServerFn } from '@tanstack/solid-start'
-import { getHeaders, setHeader } from '@tanstack/solid-start/server'
-import type { HTTPHeaderName } from '@tanstack/solid-start/server'
+import {
+ getRequestHeaders,
+ setResponseHeader,
+} from '@tanstack/solid-start/server'
+import type { RequestHeaderName } from '@tanstack/solid-start/server'
export const Route = createFileRoute('/headers')({
loader: async () => {
@@ -17,17 +20,18 @@ export const Route = createFileRoute('/headers')({
})
export const getTestHeaders = createServerFn().handler(() => {
- setHeader('x-test-header', 'test-value')
+ setResponseHeader('x-test-header', 'test-value')
+ const reqHeaders = Object.fromEntries(getRequestHeaders().entries())
return {
- serverHeaders: getHeaders(),
- headers: getHeaders(),
+ serverHeaders: reqHeaders,
+ headers: reqHeaders,
}
})
type TestHeadersResult = {
- headers?: Partial>
- serverHeaders?: Partial>
+ headers?: Partial>
+ serverHeaders?: Partial>
}
function ResponseHeaders({
diff --git a/e2e/solid-start/server-functions/src/routes/raw-response.tsx b/e2e/solid-start/server-functions/src/routes/raw-response.tsx
index 24f95e2cd1..ad3cfdc419 100644
--- a/e2e/solid-start/server-functions/src/routes/raw-response.tsx
+++ b/e2e/solid-start/server-functions/src/routes/raw-response.tsx
@@ -8,7 +8,7 @@ export const Route = createFileRoute('/raw-response')({
})
const expectedValue = 'Hello from a server function!'
-export const rawResponseFn = createServerFn({ response: 'raw' }).handler(() => {
+export const rawResponseFn = createServerFn().handler(() => {
return new Response(expectedValue)
})
diff --git a/e2e/solid-start/server-functions/src/routes/serialize-form-data.tsx b/e2e/solid-start/server-functions/src/routes/serialize-form-data.tsx
index 1973e9f7b9..aeaf80576c 100644
--- a/e2e/solid-start/server-functions/src/routes/serialize-form-data.tsx
+++ b/e2e/solid-start/server-functions/src/routes/serialize-form-data.tsx
@@ -11,7 +11,7 @@ const testValues = {
__adder: 1,
}
-export const greetUser = createServerFn()
+export const greetUser = createServerFn({ method: 'POST' })
.validator((data: FormData) => {
if (!(data instanceof FormData)) {
throw new Error('Invalid! FormData is required')
diff --git a/e2e/solid-start/server-functions/src/routes/submit-post-formdata.tsx b/e2e/solid-start/server-functions/src/routes/submit-post-formdata.tsx
index 3fb6ea356f..d9b8ed5588 100644
--- a/e2e/solid-start/server-functions/src/routes/submit-post-formdata.tsx
+++ b/e2e/solid-start/server-functions/src/routes/submit-post-formdata.tsx
@@ -9,7 +9,7 @@ const testValues = {
name: 'Sean',
}
-export const greetUser = createServerFn({ method: 'POST', response: 'raw' })
+export const greetUser = createServerFn({ method: 'POST' })
.validator((data: FormData) => {
if (!(data instanceof FormData)) {
throw new Error('Invalid! FormData is required')
diff --git a/e2e/solid-start/server-functions/tests/fixture.ts b/e2e/solid-start/server-functions/tests/fixture.ts
deleted file mode 100644
index abb7b1d564..0000000000
--- a/e2e/solid-start/server-functions/tests/fixture.ts
+++ /dev/null
@@ -1,28 +0,0 @@
-import { test as base, expect } from '@playwright/test'
-
-export interface TestFixtureOptions {
- whitelistErrors: Array
-}
-export const test = base.extend({
- whitelistErrors: [[], { option: true }],
- page: async ({ page, whitelistErrors }, use) => {
- const errorMessages: Array = []
- page.on('console', (m) => {
- if (m.type() === 'error') {
- const text = m.text()
- for (const whitelistError of whitelistErrors) {
- if (
- (typeof whitelistError === 'string' &&
- text.includes(whitelistError)) ||
- (whitelistError instanceof RegExp && whitelistError.test(text))
- ) {
- return
- }
- }
- errorMessages.push(text)
- }
- })
- await use(page)
- expect(errorMessages).toEqual([])
- },
-})
diff --git a/e2e/solid-start/server-functions/tests/server-functions.spec.ts b/e2e/solid-start/server-functions/tests/server-functions.spec.ts
index 80c89004c5..2af3201cf4 100644
--- a/e2e/solid-start/server-functions/tests/server-functions.spec.ts
+++ b/e2e/solid-start/server-functions/tests/server-functions.spec.ts
@@ -1,5 +1,6 @@
import * as fs from 'node:fs'
-import { expect, test } from '@playwright/test'
+import { expect } from '@playwright/test'
+import { test } from '@tanstack/router-e2e-utils'
import { PORT } from '../playwright.config'
import type { Page } from '@playwright/test'
@@ -11,16 +12,10 @@ test('invoking a server function with custom response status code', async ({
await page.waitForLoadState('networkidle')
const requestPromise = new Promise((resolve) => {
- page.on('response', async (response) => {
+ page.on('response', (response) => {
expect(response.status()).toBe(225)
expect(response.statusText()).toBe('hello')
- expect(response.headers()['content-type']).toBe('application/json')
- expect(await response.json()).toEqual(
- expect.objectContaining({
- result: { hello: 'world' },
- context: {},
- }),
- )
+ expect(response.headers()['content-type']).toContain('application/json')
resolve()
})
})
@@ -122,11 +117,11 @@ test('env-only functions can only be called on the server or client respectively
'server got: hello',
)
await expect(page.getByTestId('server-on-client')).toContainText(
- 'serverEcho threw an error: serverOnly() functions can only be called on the server!',
+ 'serverEcho threw an error: createServerOnlyFn() functions can only be called on the server!',
)
await expect(page.getByTestId('client-on-server')).toContainText(
- 'clientEcho threw an error: clientOnly() functions can only be called on the client!',
+ 'clientEcho threw an error: createClientOnlyFn() functions can only be called on the client!',
)
await expect(page.getByTestId('client-on-client')).toContainText(
'client got: hello',
diff --git a/e2e/solid-start/server-functions/vite.config.ts b/e2e/solid-start/server-functions/vite.config.ts
index bae1bfaad6..1a2219f443 100644
--- a/e2e/solid-start/server-functions/vite.config.ts
+++ b/e2e/solid-start/server-functions/vite.config.ts
@@ -1,6 +1,7 @@
import { defineConfig } from 'vite'
import tsConfigPaths from 'vite-tsconfig-paths'
import { tanstackStart } from '@tanstack/solid-start/plugin/vite'
+import viteSolid from 'vite-plugin-solid'
export default defineConfig({
server: {
@@ -11,5 +12,6 @@ export default defineConfig({
projects: ['./tsconfig.json'],
}),
tanstackStart(),
+ viteSolid({ ssr: true }),
],
})
diff --git a/e2e/solid-start/server-routes/package.json b/e2e/solid-start/server-routes/package.json
index c2bec1aa27..96a395f286 100644
--- a/e2e/solid-start/server-routes/package.json
+++ b/e2e/solid-start/server-routes/package.json
@@ -7,7 +7,7 @@
"dev": "vite dev --port 3000",
"dev:e2e": "vite dev",
"build": "vite build && tsc --noEmit",
- "start": "node .output/server/index.mjs",
+ "start": "pnpx srvx --prod -s ../client dist/server/server.js",
"test:e2e": "playwright test --project=chromium"
},
"dependencies": {
@@ -18,7 +18,7 @@
"redaxios": "^0.5.1",
"solid-js": "^1.9.5",
"tailwind-merge": "^2.6.0",
- "vite": "6.3.5",
+ "vite": "^7.1.1",
"zod": "^3.24.2"
},
"devDependencies": {
@@ -29,9 +29,10 @@
"autoprefixer": "^10.4.20",
"combinate": "^1.1.11",
"postcss": "^8.5.1",
+ "srvx": "^0.8.6",
"tailwindcss": "^3.4.17",
"typescript": "^5.7.2",
- "vite-plugin-solid": "^2.11.6",
+ "vite-plugin-solid": "^2.11.8",
"vite-tsconfig-paths": "^5.1.4"
}
}
diff --git a/e2e/solid-start/server-routes/tests/fixture.ts b/e2e/solid-start/server-routes/tests/fixture.ts
deleted file mode 100644
index abb7b1d564..0000000000
--- a/e2e/solid-start/server-routes/tests/fixture.ts
+++ /dev/null
@@ -1,28 +0,0 @@
-import { test as base, expect } from '@playwright/test'
-
-export interface TestFixtureOptions {
- whitelistErrors: Array
-}
-export const test = base.extend({
- whitelistErrors: [[], { option: true }],
- page: async ({ page, whitelistErrors }, use) => {
- const errorMessages: Array = []
- page.on('console', (m) => {
- if (m.type() === 'error') {
- const text = m.text()
- for (const whitelistError of whitelistErrors) {
- if (
- (typeof whitelistError === 'string' &&
- text.includes(whitelistError)) ||
- (whitelistError instanceof RegExp && whitelistError.test(text))
- ) {
- return
- }
- }
- errorMessages.push(text)
- }
- })
- await use(page)
- expect(errorMessages).toEqual([])
- },
-})
diff --git a/e2e/solid-start/server-routes/tests/server-routes.spec.ts b/e2e/solid-start/server-routes/tests/server-routes.spec.ts
index 098a40b2ef..33176a23fd 100644
--- a/e2e/solid-start/server-routes/tests/server-routes.spec.ts
+++ b/e2e/solid-start/server-routes/tests/server-routes.spec.ts
@@ -1,4 +1,5 @@
-import { expect, test } from '@playwright/test'
+import { expect } from '@playwright/test'
+import { test } from '@tanstack/router-e2e-utils'
test('merge-server-fn-middleware-context', async ({ page }) => {
await page.goto('/merge-server-fn-middleware-context')
diff --git a/e2e/solid-start/server-routes/vite.config.ts b/e2e/solid-start/server-routes/vite.config.ts
index bae1bfaad6..1a2219f443 100644
--- a/e2e/solid-start/server-routes/vite.config.ts
+++ b/e2e/solid-start/server-routes/vite.config.ts
@@ -1,6 +1,7 @@
import { defineConfig } from 'vite'
import tsConfigPaths from 'vite-tsconfig-paths'
import { tanstackStart } from '@tanstack/solid-start/plugin/vite'
+import viteSolid from 'vite-plugin-solid'
export default defineConfig({
server: {
@@ -11,5 +12,6 @@ export default defineConfig({
projects: ['./tsconfig.json'],
}),
tanstackStart(),
+ viteSolid({ ssr: true }),
],
})
diff --git a/e2e/solid-start/spa-mode/package.json b/e2e/solid-start/spa-mode/package.json
index 74f862abcb..a0ffac57a5 100644
--- a/e2e/solid-start/spa-mode/package.json
+++ b/e2e/solid-start/spa-mode/package.json
@@ -7,7 +7,7 @@
"dev": "vite dev --port 3000",
"dev:e2e": "vite dev",
"build": "vite build && tsc --noEmit",
- "start": "npx serve .output/public",
+ "start": "npx serve dist/client",
"test:e2e": "rm -rf port*.txt; playwright test --project=chromium"
},
"dependencies": {
@@ -22,7 +22,8 @@
"postcss": "^8.5.1",
"tailwindcss": "^3.4.17",
"typescript": "^5.7.2",
- "vite": "^6.3.5",
- "vite-tsconfig-paths": "^5.1.4"
+ "vite": "^7.1.1",
+ "vite-tsconfig-paths": "^5.1.4",
+ "vite-plugin-solid": "^2.11.8"
}
}
diff --git a/e2e/solid-start/spa-mode/tests/app.spec.ts b/e2e/solid-start/spa-mode/tests/app.spec.ts
index 8970ec333c..c18a0ff65d 100644
--- a/e2e/solid-start/spa-mode/tests/app.spec.ts
+++ b/e2e/solid-start/spa-mode/tests/app.spec.ts
@@ -1,5 +1,5 @@
import { expect } from '@playwright/test'
-import { test } from './fixture'
+import { test } from '@tanstack/router-e2e-utils'
import type { Page } from '@playwright/test'
async function runTest(
diff --git a/e2e/solid-start/spa-mode/tests/fixture.ts b/e2e/solid-start/spa-mode/tests/fixture.ts
deleted file mode 100644
index abb7b1d564..0000000000
--- a/e2e/solid-start/spa-mode/tests/fixture.ts
+++ /dev/null
@@ -1,28 +0,0 @@
-import { test as base, expect } from '@playwright/test'
-
-export interface TestFixtureOptions {
- whitelistErrors: Array
-}
-export const test = base.extend({
- whitelistErrors: [[], { option: true }],
- page: async ({ page, whitelistErrors }, use) => {
- const errorMessages: Array = []
- page.on('console', (m) => {
- if (m.type() === 'error') {
- const text = m.text()
- for (const whitelistError of whitelistErrors) {
- if (
- (typeof whitelistError === 'string' &&
- text.includes(whitelistError)) ||
- (whitelistError instanceof RegExp && whitelistError.test(text))
- ) {
- return
- }
- }
- errorMessages.push(text)
- }
- })
- await use(page)
- expect(errorMessages).toEqual([])
- },
-})
diff --git a/e2e/solid-start/spa-mode/vite.config.ts b/e2e/solid-start/spa-mode/vite.config.ts
index f14e499525..3bad2df77e 100644
--- a/e2e/solid-start/spa-mode/vite.config.ts
+++ b/e2e/solid-start/spa-mode/vite.config.ts
@@ -1,6 +1,7 @@
import { defineConfig } from 'vite'
import { tanstackStart } from '@tanstack/solid-start/plugin/vite'
import tsConfigPaths from 'vite-tsconfig-paths'
+import viteSolid from 'vite-plugin-solid'
export default defineConfig({
server: {
@@ -25,5 +26,6 @@ export default defineConfig({
},
],
}),
+ viteSolid({ ssr: true }),
],
})
diff --git a/e2e/solid-start/website/package.json b/e2e/solid-start/website/package.json
index 383f3305db..0a60d4e5f6 100644
--- a/e2e/solid-start/website/package.json
+++ b/e2e/solid-start/website/package.json
@@ -7,7 +7,7 @@
"dev": "vite dev --port 3000",
"dev:e2e": "vite dev",
"build": "vite build && tsc --noEmit",
- "start": "node .output/server/index.mjs",
+ "start": "pnpx srvx --prod -s ../client dist/server/server.js",
"test:e2e": "rm -rf port*.txt; playwright test --project=chromium"
},
"dependencies": {
@@ -17,7 +17,7 @@
"redaxios": "^0.5.1",
"solid-js": "^1.9.5",
"tailwind-merge": "^2.6.0",
- "vite": "6.3.5",
+ "vite": "^7.1.1",
"zod": "^3.24.2"
},
"devDependencies": {
@@ -26,9 +26,10 @@
"@types/node": "^22.10.2",
"autoprefixer": "^10.4.20",
"postcss": "^8.5.1",
+ "srvx": "^0.8.6",
"tailwindcss": "^3.4.17",
"typescript": "^5.7.2",
- "vite-plugin-solid": "^2.11.6",
+ "vite-plugin-solid": "^2.11.8",
"vite-tsconfig-paths": "^5.1.4"
}
}
diff --git a/e2e/solid-start/website/vite.config.ts b/e2e/solid-start/website/vite.config.ts
index 3af67d62ad..1a2219f443 100644
--- a/e2e/solid-start/website/vite.config.ts
+++ b/e2e/solid-start/website/vite.config.ts
@@ -1,6 +1,7 @@
import { defineConfig } from 'vite'
import tsConfigPaths from 'vite-tsconfig-paths'
import { tanstackStart } from '@tanstack/solid-start/plugin/vite'
+import viteSolid from 'vite-plugin-solid'
export default defineConfig({
server: {
@@ -10,6 +11,7 @@ export default defineConfig({
tsConfigPaths({
projects: ['./tsconfig.json'],
}),
- tanstackStart({}),
+ tanstackStart(),
+ viteSolid({ ssr: true }),
],
})
diff --git a/examples/react/authenticated-routes-firebase/package.json b/examples/react/authenticated-routes-firebase/package.json
index c188e691b0..a988f9d149 100644
--- a/examples/react/authenticated-routes-firebase/package.json
+++ b/examples/react/authenticated-routes-firebase/package.json
@@ -9,9 +9,9 @@
"start": "vite"
},
"dependencies": {
- "@tanstack/react-router": "^1.131.27",
- "@tanstack/react-router-devtools": "^1.131.27",
- "@tanstack/router-plugin": "^1.131.27",
+ "@tanstack/react-router": "^1.132.0-alpha.8",
+ "@tanstack/react-router-devtools": "^1.132.0-alpha.8",
+ "@tanstack/router-plugin": "^1.132.0-alpha.9",
"autoprefixer": "^10.4.20",
"firebase": "^11.4.0",
"postcss": "^8.5.1",
@@ -27,6 +27,6 @@
"@types/react-dom": "^19.0.3",
"@vitejs/plugin-react": "^4.3.4",
"typescript": "^5.7.2",
- "vite": "^6.3.5"
+ "vite": "^7.1.1"
}
}
diff --git a/examples/react/authenticated-routes/package.json b/examples/react/authenticated-routes/package.json
index df45f36d77..cf0d7eec25 100644
--- a/examples/react/authenticated-routes/package.json
+++ b/examples/react/authenticated-routes/package.json
@@ -9,9 +9,9 @@
"start": "vite"
},
"dependencies": {
- "@tanstack/react-router": "^1.131.27",
- "@tanstack/react-router-devtools": "^1.131.27",
- "@tanstack/router-plugin": "^1.131.27",
+ "@tanstack/react-router": "^1.132.0-alpha.8",
+ "@tanstack/react-router-devtools": "^1.132.0-alpha.8",
+ "@tanstack/router-plugin": "^1.132.0-alpha.9",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"redaxios": "^0.5.1",
@@ -25,6 +25,6 @@
"@types/react-dom": "^19.0.3",
"@vitejs/plugin-react": "^4.3.4",
"typescript": "^5.7.2",
- "vite": "^6.3.5"
+ "vite": "^7.1.1"
}
}
diff --git a/examples/react/basic-default-search-params/package.json b/examples/react/basic-default-search-params/package.json
index 9995fbcfc8..8c7a386ae5 100644
--- a/examples/react/basic-default-search-params/package.json
+++ b/examples/react/basic-default-search-params/package.json
@@ -10,8 +10,8 @@
},
"dependencies": {
"@tanstack/react-query": "^5.66.0",
- "@tanstack/react-router": "^1.131.27",
- "@tanstack/react-router-devtools": "^1.131.27",
+ "@tanstack/react-router": "^1.132.0-alpha.8",
+ "@tanstack/react-router-devtools": "^1.132.0-alpha.8",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"redaxios": "^0.5.1",
@@ -25,6 +25,6 @@
"@types/react-dom": "^19.0.3",
"@vitejs/plugin-react": "^4.3.4",
"typescript": "^5.7.2",
- "vite": "^6.3.5"
+ "vite": "^7.1.1"
}
}
diff --git a/examples/react/basic-devtools-panel/package.json b/examples/react/basic-devtools-panel/package.json
index 0c7c7fafa6..b65463e96e 100644
--- a/examples/react/basic-devtools-panel/package.json
+++ b/examples/react/basic-devtools-panel/package.json
@@ -9,8 +9,8 @@
"start": "vite"
},
"dependencies": {
- "@tanstack/react-router": "^1.131.27",
- "@tanstack/react-router-devtools": "^1.131.27",
+ "@tanstack/react-router": "^1.132.0-alpha.8",
+ "@tanstack/react-router-devtools": "^1.132.0-alpha.8",
"@tanstack/react-query-devtools": "^5.67.2",
"react": "^19.0.0",
"react-dom": "^19.0.0",
@@ -24,6 +24,6 @@
"@types/react-dom": "^19.0.3",
"@vitejs/plugin-react": "^4.3.4",
"typescript": "^5.7.2",
- "vite": "^6.3.5"
+ "vite": "^7.1.1"
}
}
diff --git a/examples/react/basic-file-based/package.json b/examples/react/basic-file-based/package.json
index fd25b3760d..b850ae9bd2 100644
--- a/examples/react/basic-file-based/package.json
+++ b/examples/react/basic-file-based/package.json
@@ -9,9 +9,9 @@
"start": "vite"
},
"dependencies": {
- "@tanstack/react-router": "^1.131.27",
- "@tanstack/react-router-devtools": "^1.131.27",
- "@tanstack/router-plugin": "^1.131.27",
+ "@tanstack/react-router": "^1.132.0-alpha.8",
+ "@tanstack/react-router-devtools": "^1.132.0-alpha.8",
+ "@tanstack/router-plugin": "^1.132.0-alpha.9",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"redaxios": "^0.5.1",
@@ -25,6 +25,6 @@
"@types/react-dom": "^19.0.3",
"@vitejs/plugin-react": "^4.3.4",
"typescript": "^5.7.2",
- "vite": "^6.3.5"
+ "vite": "^7.1.1"
}
}
diff --git a/examples/react/basic-non-nested-devtools/package.json b/examples/react/basic-non-nested-devtools/package.json
index db1696e610..6107ac67a2 100644
--- a/examples/react/basic-non-nested-devtools/package.json
+++ b/examples/react/basic-non-nested-devtools/package.json
@@ -9,8 +9,8 @@
"start": "vite"
},
"dependencies": {
- "@tanstack/react-router": "^1.131.27",
- "@tanstack/react-router-devtools": "^1.131.27",
+ "@tanstack/react-router": "^1.132.0-alpha.8",
+ "@tanstack/react-router-devtools": "^1.132.0-alpha.8",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"redaxios": "^0.5.1",
@@ -23,6 +23,6 @@
"@types/react-dom": "^19.0.3",
"@vitejs/plugin-react": "^4.3.4",
"typescript": "^5.7.2",
- "vite": "^6.3.5"
+ "vite": "^7.1.1"
}
}
diff --git a/examples/react/basic-react-query-file-based/package.json b/examples/react/basic-react-query-file-based/package.json
index 09048ede0e..fab6b52e86 100644
--- a/examples/react/basic-react-query-file-based/package.json
+++ b/examples/react/basic-react-query-file-based/package.json
@@ -11,9 +11,9 @@
"dependencies": {
"@tanstack/react-query": "^5.66.0",
"@tanstack/react-query-devtools": "^5.66.0",
- "@tanstack/react-router": "^1.131.27",
- "@tanstack/react-router-devtools": "^1.131.27",
- "@tanstack/router-plugin": "^1.131.27",
+ "@tanstack/react-router": "^1.132.0-alpha.8",
+ "@tanstack/react-router-devtools": "^1.132.0-alpha.8",
+ "@tanstack/router-plugin": "^1.132.0-alpha.9",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"redaxios": "^0.5.1",
@@ -27,6 +27,6 @@
"@types/react-dom": "^19.0.3",
"@vitejs/plugin-react": "^4.3.4",
"typescript": "^5.7.2",
- "vite": "^6.3.5"
+ "vite": "^7.1.1"
}
}
diff --git a/examples/react/basic-react-query/package.json b/examples/react/basic-react-query/package.json
index 013a903228..1ca280d421 100644
--- a/examples/react/basic-react-query/package.json
+++ b/examples/react/basic-react-query/package.json
@@ -11,8 +11,8 @@
"dependencies": {
"@tanstack/react-query": "^5.66.0",
"@tanstack/react-query-devtools": "^5.66.0",
- "@tanstack/react-router": "^1.131.27",
- "@tanstack/react-router-devtools": "^1.131.27",
+ "@tanstack/react-router": "^1.132.0-alpha.8",
+ "@tanstack/react-router-devtools": "^1.132.0-alpha.8",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"redaxios": "^0.5.1",
@@ -25,6 +25,6 @@
"@types/react-dom": "^19.0.3",
"@vitejs/plugin-react": "^4.3.4",
"typescript": "^5.7.2",
- "vite": "^6.3.5"
+ "vite": "^7.1.1"
}
}
diff --git a/examples/react/basic-ssr-file-based/package.json b/examples/react/basic-ssr-file-based/package.json
index f3e413566b..c0feba2e80 100644
--- a/examples/react/basic-ssr-file-based/package.json
+++ b/examples/react/basic-ssr-file-based/package.json
@@ -11,23 +11,22 @@
"debug": "node --inspect-brk server"
},
"dependencies": {
- "@tanstack/react-router": "^1.131.27",
- "@tanstack/router-plugin": "^1.131.27",
+ "@tanstack/react-router": "^1.132.0-alpha.8",
+ "@tanstack/router-plugin": "^1.132.0-alpha.9",
"compression": "^1.8.0",
"express": "^4.21.2",
"get-port": "^7.1.0",
- "isbot": "^5.1.28",
"node-fetch": "^3.3.2",
"react": "^19.0.0",
"react-dom": "^19.0.0"
},
"devDependencies": {
- "@tanstack/react-router-devtools": "^1.131.27",
+ "@tanstack/react-router-devtools": "^1.132.0-alpha.8",
"@types/express": "^4.17.23",
"@types/react": "^19.0.8",
"@types/react-dom": "^19.0.1",
"@vitejs/plugin-react": "^4.5.2",
"typescript": "^5.8.3",
- "vite": "^6.3.5"
+ "vite": "^7.1.1"
}
}
diff --git a/examples/react/basic-ssr-streaming-file-based/package.json b/examples/react/basic-ssr-streaming-file-based/package.json
index fc2d5dd213..e8a21bef8b 100644
--- a/examples/react/basic-ssr-streaming-file-based/package.json
+++ b/examples/react/basic-ssr-streaming-file-based/package.json
@@ -11,23 +11,22 @@
"debug": "node --inspect-brk server"
},
"dependencies": {
- "@tanstack/react-router": "^1.131.27",
- "@tanstack/router-plugin": "^1.131.27",
+ "@tanstack/react-router": "^1.132.0-alpha.8",
+ "@tanstack/router-plugin": "^1.132.0-alpha.9",
"compression": "^1.7.5",
"express": "^4.21.2",
"get-port": "^7.1.0",
- "isbot": "^5.1.22",
"node-fetch": "^3.3.2",
"react": "^19.0.0",
"react-dom": "^19.0.0"
},
"devDependencies": {
- "@tanstack/react-router-devtools": "^1.131.27",
+ "@tanstack/react-router-devtools": "^1.132.0-alpha.8",
"@types/express": "^4.17.21",
"@types/react": "^19.0.8",
"@types/react-dom": "^19.0.1",
"@vitejs/plugin-react": "^4.3.4",
"typescript": "^5.7.2",
- "vite": "^6.3.5"
+ "vite": "^7.1.1"
}
}
diff --git a/examples/react/basic-virtual-file-based/package.json b/examples/react/basic-virtual-file-based/package.json
index ca3aa4d328..3810a5006c 100644
--- a/examples/react/basic-virtual-file-based/package.json
+++ b/examples/react/basic-virtual-file-based/package.json
@@ -9,10 +9,10 @@
"start": "vite"
},
"dependencies": {
- "@tanstack/react-router": "^1.131.27",
- "@tanstack/react-router-devtools": "^1.131.27",
- "@tanstack/router-plugin": "^1.131.27",
- "@tanstack/virtual-file-routes": "^1.131.2",
+ "@tanstack/react-router": "^1.132.0-alpha.8",
+ "@tanstack/react-router-devtools": "^1.132.0-alpha.8",
+ "@tanstack/router-plugin": "^1.132.0-alpha.9",
+ "@tanstack/virtual-file-routes": "^1.132.0-alpha.1",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"redaxios": "^0.5.1",
@@ -26,6 +26,6 @@
"@types/react-dom": "^19.0.3",
"@vitejs/plugin-react": "^4.3.4",
"typescript": "^5.7.2",
- "vite": "^6.3.5"
+ "vite": "^7.1.1"
}
}
diff --git a/examples/react/basic-virtual-inside-file-based/package.json b/examples/react/basic-virtual-inside-file-based/package.json
index 2bea5afad5..37ef85c641 100644
--- a/examples/react/basic-virtual-inside-file-based/package.json
+++ b/examples/react/basic-virtual-inside-file-based/package.json
@@ -9,10 +9,10 @@
"start": "vite"
},
"dependencies": {
- "@tanstack/react-router": "^1.131.27",
- "@tanstack/react-router-devtools": "^1.131.27",
- "@tanstack/router-plugin": "^1.131.27",
- "@tanstack/virtual-file-routes": "^1.131.2",
+ "@tanstack/react-router": "^1.132.0-alpha.8",
+ "@tanstack/react-router-devtools": "^1.132.0-alpha.8",
+ "@tanstack/router-plugin": "^1.132.0-alpha.9",
+ "@tanstack/virtual-file-routes": "^1.132.0-alpha.1",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"redaxios": "^0.5.1",
@@ -26,6 +26,6 @@
"@types/react-dom": "^19.0.3",
"@vitejs/plugin-react": "^4.3.4",
"typescript": "^5.7.2",
- "vite": "^6.3.5"
+ "vite": "^7.1.1"
}
}
diff --git a/examples/react/basic/package.json b/examples/react/basic/package.json
index 17e33d6a3b..eec80e69db 100644
--- a/examples/react/basic/package.json
+++ b/examples/react/basic/package.json
@@ -9,8 +9,8 @@
"start": "vite"
},
"dependencies": {
- "@tanstack/react-router": "^1.131.27",
- "@tanstack/react-router-devtools": "^1.131.27",
+ "@tanstack/react-router": "^1.132.0-alpha.8",
+ "@tanstack/react-router-devtools": "^1.132.0-alpha.8",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"redaxios": "^0.5.1",
@@ -23,6 +23,6 @@
"@types/react-dom": "^19.0.3",
"@vitejs/plugin-react": "^4.3.4",
"typescript": "^5.7.2",
- "vite": "^6.3.5"
+ "vite": "^7.1.1"
}
}
diff --git a/examples/react/deferred-data/package.json b/examples/react/deferred-data/package.json
index d82b45ebcc..c71dd5e9f3 100644
--- a/examples/react/deferred-data/package.json
+++ b/examples/react/deferred-data/package.json
@@ -9,8 +9,8 @@
"start": "vite"
},
"dependencies": {
- "@tanstack/react-router": "^1.131.27",
- "@tanstack/react-router-devtools": "^1.131.27",
+ "@tanstack/react-router": "^1.132.0-alpha.8",
+ "@tanstack/react-router-devtools": "^1.132.0-alpha.8",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"redaxios": "^0.5.1",
@@ -24,6 +24,6 @@
"@types/react-dom": "^19.0.3",
"@vitejs/plugin-react": "^4.3.4",
"typescript": "^5.7.2",
- "vite": "^6.3.5"
+ "vite": "^7.1.1"
}
}
diff --git a/examples/react/kitchen-sink-file-based/package.json b/examples/react/kitchen-sink-file-based/package.json
index 115a136d0d..82b1a7ed43 100644
--- a/examples/react/kitchen-sink-file-based/package.json
+++ b/examples/react/kitchen-sink-file-based/package.json
@@ -9,9 +9,9 @@
"start": "vite"
},
"dependencies": {
- "@tanstack/react-router": "^1.131.27",
- "@tanstack/react-router-devtools": "^1.131.27",
- "@tanstack/router-plugin": "^1.131.27",
+ "@tanstack/react-router": "^1.132.0-alpha.8",
+ "@tanstack/react-router-devtools": "^1.132.0-alpha.8",
+ "@tanstack/router-plugin": "^1.132.0-alpha.9",
"immer": "^10.1.1",
"react": "^19.0.0",
"react-dom": "^19.0.0",
@@ -26,6 +26,6 @@
"@types/react-dom": "^19.0.3",
"@vitejs/plugin-react": "^4.3.4",
"typescript": "^5.7.2",
- "vite": "^6.3.5"
+ "vite": "^7.1.1"
}
}
diff --git a/examples/react/kitchen-sink-react-query-file-based/package.json b/examples/react/kitchen-sink-react-query-file-based/package.json
index 0ace315b74..7e92366868 100644
--- a/examples/react/kitchen-sink-react-query-file-based/package.json
+++ b/examples/react/kitchen-sink-react-query-file-based/package.json
@@ -11,9 +11,9 @@
"dependencies": {
"@tanstack/react-query": "^5.66.0",
"@tanstack/react-query-devtools": "^5.66.0",
- "@tanstack/react-router": "^1.131.27",
- "@tanstack/react-router-devtools": "^1.131.27",
- "@tanstack/router-plugin": "^1.131.27",
+ "@tanstack/react-router": "^1.132.0-alpha.8",
+ "@tanstack/react-router-devtools": "^1.132.0-alpha.8",
+ "@tanstack/router-plugin": "^1.132.0-alpha.9",
"immer": "^10.1.1",
"react": "^19.0.0",
"react-dom": "^19.0.0",
@@ -28,6 +28,6 @@
"@types/react-dom": "^19.0.3",
"@vitejs/plugin-react": "^4.3.4",
"typescript": "^5.7.2",
- "vite": "^6.3.5"
+ "vite": "^7.1.1"
}
}
diff --git a/examples/react/kitchen-sink-react-query/package.json b/examples/react/kitchen-sink-react-query/package.json
index 6ccbefd8fc..0907bfd11f 100644
--- a/examples/react/kitchen-sink-react-query/package.json
+++ b/examples/react/kitchen-sink-react-query/package.json
@@ -11,8 +11,8 @@
"dependencies": {
"@tanstack/react-query": "^5.66.0",
"@tanstack/react-query-devtools": "^5.66.0",
- "@tanstack/react-router": "^1.131.27",
- "@tanstack/react-router-devtools": "^1.131.27",
+ "@tanstack/react-router": "^1.132.0-alpha.8",
+ "@tanstack/react-router-devtools": "^1.132.0-alpha.8",
"immer": "^10.1.1",
"react": "^19.0.0",
"react-dom": "^19.0.0",
@@ -27,6 +27,6 @@
"@types/react-dom": "^19.0.3",
"@vitejs/plugin-react": "^4.3.4",
"typescript": "^5.7.2",
- "vite": "^6.3.5"
+ "vite": "^7.1.1"
}
}
diff --git a/examples/react/kitchen-sink/package.json b/examples/react/kitchen-sink/package.json
index 5ca9eac8a0..6d621a178d 100644
--- a/examples/react/kitchen-sink/package.json
+++ b/examples/react/kitchen-sink/package.json
@@ -9,8 +9,8 @@
"start": "vite"
},
"dependencies": {
- "@tanstack/react-router": "^1.131.27",
- "@tanstack/react-router-devtools": "^1.131.27",
+ "@tanstack/react-router": "^1.132.0-alpha.8",
+ "@tanstack/react-router-devtools": "^1.132.0-alpha.8",
"immer": "^10.1.1",
"react": "^19.0.0",
"react-dom": "^19.0.0",
@@ -25,6 +25,6 @@
"@types/react-dom": "^19.0.3",
"@vitejs/plugin-react": "^4.3.4",
"typescript": "^5.7.2",
- "vite": "^6.3.5"
+ "vite": "^7.1.1"
}
}
diff --git a/examples/react/large-file-based/package.json b/examples/react/large-file-based/package.json
index a3d89e3cb5..cd724fcade 100644
--- a/examples/react/large-file-based/package.json
+++ b/examples/react/large-file-based/package.json
@@ -12,9 +12,9 @@
},
"dependencies": {
"@tanstack/react-query": "^5.66.0",
- "@tanstack/react-router": "^1.131.27",
- "@tanstack/react-router-devtools": "^1.131.27",
- "@tanstack/router-plugin": "^1.131.27",
+ "@tanstack/react-router": "^1.132.0-alpha.8",
+ "@tanstack/react-router-devtools": "^1.132.0-alpha.8",
+ "@tanstack/router-plugin": "^1.132.0-alpha.9",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"redaxios": "^0.5.1",
@@ -28,6 +28,6 @@
"@types/react-dom": "^19.0.3",
"@vitejs/plugin-react": "^4.3.4",
"typescript": "^5.7.2",
- "vite": "^6.3.5"
+ "vite": "^7.1.1"
}
}
diff --git a/examples/react/location-masking/package.json b/examples/react/location-masking/package.json
index 51e609b293..b10930328b 100644
--- a/examples/react/location-masking/package.json
+++ b/examples/react/location-masking/package.json
@@ -11,8 +11,8 @@
"dependencies": {
"@radix-ui/react-dialog": "^1.1.6",
"@tanstack/react-query": "^5.66.0",
- "@tanstack/react-router": "^1.131.27",
- "@tanstack/react-router-devtools": "^1.131.27",
+ "@tanstack/react-router": "^1.132.0-alpha.8",
+ "@tanstack/react-router-devtools": "^1.132.0-alpha.8",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"redaxios": "^0.5.1",
@@ -25,6 +25,6 @@
"@types/react-dom": "^19.0.3",
"@vitejs/plugin-react": "^4.3.4",
"typescript": "^5.7.2",
- "vite": "^6.3.5"
+ "vite": "^7.1.1"
}
}
diff --git a/examples/react/navigation-blocking/package.json b/examples/react/navigation-blocking/package.json
index add1b8a550..ba5fec5b6d 100644
--- a/examples/react/navigation-blocking/package.json
+++ b/examples/react/navigation-blocking/package.json
@@ -10,8 +10,8 @@
},
"dependencies": {
"@tanstack/react-query": "^5.66.0",
- "@tanstack/react-router": "^1.131.27",
- "@tanstack/react-router-devtools": "^1.131.27",
+ "@tanstack/react-router": "^1.132.0-alpha.8",
+ "@tanstack/react-router-devtools": "^1.132.0-alpha.8",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"redaxios": "^0.5.1",
@@ -24,6 +24,6 @@
"@types/react-dom": "^19.0.3",
"@vitejs/plugin-react": "^4.3.4",
"typescript": "^5.7.2",
- "vite": "^6.3.5"
+ "vite": "^7.1.1"
}
}
diff --git a/examples/react/quickstart-esbuild-file-based/package.json b/examples/react/quickstart-esbuild-file-based/package.json
index cdfcf5fb29..2abb912fc6 100644
--- a/examples/react/quickstart-esbuild-file-based/package.json
+++ b/examples/react/quickstart-esbuild-file-based/package.json
@@ -9,9 +9,9 @@
"start": "dev"
},
"dependencies": {
- "@tanstack/react-router": "^1.131.27",
- "@tanstack/react-router-devtools": "^1.131.27",
- "@tanstack/router-plugin": "^1.131.27",
+ "@tanstack/react-router": "^1.132.0-alpha.8",
+ "@tanstack/react-router-devtools": "^1.132.0-alpha.8",
+ "@tanstack/router-plugin": "^1.132.0-alpha.9",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"redaxios": "^0.5.1",
diff --git a/examples/react/quickstart-file-based/package.json b/examples/react/quickstart-file-based/package.json
index 299e78c6a1..15b22af228 100644
--- a/examples/react/quickstart-file-based/package.json
+++ b/examples/react/quickstart-file-based/package.json
@@ -9,9 +9,9 @@
"start": "vite"
},
"dependencies": {
- "@tanstack/react-router": "^1.131.27",
- "@tanstack/react-router-devtools": "^1.131.27",
- "@tanstack/router-plugin": "^1.131.27",
+ "@tanstack/react-router": "^1.132.0-alpha.8",
+ "@tanstack/react-router-devtools": "^1.132.0-alpha.8",
+ "@tanstack/router-plugin": "^1.132.0-alpha.9",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"redaxios": "^0.5.1",
@@ -25,6 +25,6 @@
"@types/react-dom": "^19.0.3",
"@vitejs/plugin-react": "^4.3.4",
"typescript": "^5.7.2",
- "vite": "^6.3.5"
+ "vite": "^7.1.1"
}
}
diff --git a/examples/react/quickstart-rspack-file-based/package.json b/examples/react/quickstart-rspack-file-based/package.json
index 99cddefd26..b86d97fc5e 100644
--- a/examples/react/quickstart-rspack-file-based/package.json
+++ b/examples/react/quickstart-rspack-file-based/package.json
@@ -8,8 +8,8 @@
"preview": "rsbuild preview"
},
"dependencies": {
- "@tanstack/react-router": "^1.131.27",
- "@tanstack/react-router-devtools": "^1.131.27",
+ "@tanstack/react-router": "^1.132.0-alpha.8",
+ "@tanstack/react-router-devtools": "^1.132.0-alpha.8",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"postcss": "^8.5.1",
@@ -19,7 +19,7 @@
"devDependencies": {
"@rsbuild/core": "1.2.4",
"@rsbuild/plugin-react": "1.1.0",
- "@tanstack/router-plugin": "^1.131.27",
+ "@tanstack/router-plugin": "^1.132.0-alpha.9",
"@types/react": "^19.0.8",
"@types/react-dom": "^19.0.3",
"typescript": "^5.6.2"
diff --git a/examples/react/quickstart-webpack-file-based/package.json b/examples/react/quickstart-webpack-file-based/package.json
index 765aecc25a..ed6c5382aa 100644
--- a/examples/react/quickstart-webpack-file-based/package.json
+++ b/examples/react/quickstart-webpack-file-based/package.json
@@ -7,14 +7,14 @@
"build": "webpack build && tsc --noEmit"
},
"dependencies": {
- "@tanstack/react-router": "^1.131.27",
- "@tanstack/react-router-devtools": "^1.131.27",
+ "@tanstack/react-router": "^1.132.0-alpha.8",
+ "@tanstack/react-router-devtools": "^1.132.0-alpha.8",
"react": "^19.0.0",
"react-dom": "^19.0.0"
},
"devDependencies": {
"@swc/core": "^1.10.15",
- "@tanstack/router-plugin": "^1.131.27",
+ "@tanstack/router-plugin": "^1.132.0-alpha.9",
"@types/react": "^19.0.8",
"@types/react-dom": "^19.0.3",
"html-webpack-plugin": "^5.6.3",
diff --git a/examples/react/quickstart/package.json b/examples/react/quickstart/package.json
index aaa3d9d055..ac2304a00e 100644
--- a/examples/react/quickstart/package.json
+++ b/examples/react/quickstart/package.json
@@ -9,8 +9,8 @@
"start": "vite"
},
"dependencies": {
- "@tanstack/react-router": "^1.131.27",
- "@tanstack/react-router-devtools": "^1.131.27",
+ "@tanstack/react-router": "^1.132.0-alpha.8",
+ "@tanstack/react-router-devtools": "^1.132.0-alpha.8",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"postcss": "^8.5.1",
@@ -22,6 +22,6 @@
"@types/react-dom": "^19.0.3",
"@vitejs/plugin-react": "^4.3.4",
"typescript": "^5.7.2",
- "vite": "^6.3.5"
+ "vite": "^7.1.1"
}
}
diff --git a/examples/react/router-monorepo-react-query/package.json b/examples/react/router-monorepo-react-query/package.json
index ca54061e3b..67ec1ecf64 100644
--- a/examples/react/router-monorepo-react-query/package.json
+++ b/examples/react/router-monorepo-react-query/package.json
@@ -12,9 +12,9 @@
"dependencies": {
"@tanstack/react-query": "^5.66.0",
"@tanstack/react-query-devtools": "^5.66.0",
- "@tanstack/react-router": "^1.131.27",
- "@tanstack/react-router-devtools": "^1.131.27",
- "@tanstack/router-plugin": "^1.131.27",
+ "@tanstack/react-router": "^1.132.0-alpha.8",
+ "@tanstack/react-router-devtools": "^1.132.0-alpha.8",
+ "@tanstack/router-plugin": "^1.132.0-alpha.9",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"redaxios": "^0.5.1"
@@ -25,7 +25,7 @@
"@types/react-dom": "^19.0.3",
"typescript": "^5.7.2",
"@vitejs/plugin-react": "^4.3.4",
- "vite": "^6.3.5",
+ "vite": "^7.1.1",
"vite-plugin-dts": "^4.5.0"
},
"keywords": [],
diff --git a/examples/react/router-monorepo-react-query/packages/app/package.json b/examples/react/router-monorepo-react-query/packages/app/package.json
index 3d0d06369f..e83345ec3f 100644
--- a/examples/react/router-monorepo-react-query/packages/app/package.json
+++ b/examples/react/router-monorepo-react-query/packages/app/package.json
@@ -20,11 +20,11 @@
"@types/react-dom": "^19.0.3",
"@vitejs/plugin-react": "^4.3.4",
"typescript": "^5.7.2",
- "@tanstack/react-router-devtools": "^1.131.27",
+ "@tanstack/react-router-devtools": "^1.132.0-alpha.8",
"postcss": "^8.5.1",
"autoprefixer": "^10.4.20",
"tailwindcss": "^3.4.17",
- "vite": "^6.3.5",
+ "vite": "^7.1.1",
"vite-plugin-dts": "^4.5.0"
},
"nx": {
diff --git a/examples/react/router-monorepo-react-query/packages/post-feature/package.json b/examples/react/router-monorepo-react-query/packages/post-feature/package.json
index ef4700d04f..fc6532deeb 100644
--- a/examples/react/router-monorepo-react-query/packages/post-feature/package.json
+++ b/examples/react/router-monorepo-react-query/packages/post-feature/package.json
@@ -19,7 +19,7 @@
"@types/react-dom": "^19.0.3",
"@vitejs/plugin-react": "^4.3.4",
"typescript": "^5.7.2",
- "vite": "^6.3.5",
+ "vite": "^7.1.1",
"vite-plugin-dts": "^4.5.0"
}
}
diff --git a/examples/react/router-monorepo-react-query/packages/post-query/package.json b/examples/react/router-monorepo-react-query/packages/post-query/package.json
index 6f856efc89..89c813fc70 100644
--- a/examples/react/router-monorepo-react-query/packages/post-query/package.json
+++ b/examples/react/router-monorepo-react-query/packages/post-query/package.json
@@ -15,6 +15,6 @@
"devDependencies": {
"@vitejs/plugin-react": "^4.3.4",
"typescript": "^5.7.2",
- "vite": "^6.3.5"
+ "vite": "^7.1.1"
}
}
diff --git a/examples/react/router-monorepo-react-query/packages/router/package.json b/examples/react/router-monorepo-react-query/packages/router/package.json
index 4186aec9ed..a5a21eea3e 100644
--- a/examples/react/router-monorepo-react-query/packages/router/package.json
+++ b/examples/react/router-monorepo-react-query/packages/router/package.json
@@ -8,10 +8,10 @@
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"dependencies": {
- "@tanstack/history": "^1.131.2",
+ "@tanstack/history": "^1.132.0-alpha.1",
"@tanstack/react-query": "^5.66.0",
- "@tanstack/react-router": "^1.131.27",
- "@tanstack/router-plugin": "^1.131.27",
+ "@tanstack/react-router": "^1.132.0-alpha.8",
+ "@tanstack/router-plugin": "^1.132.0-alpha.9",
"@router-mono-react-query/post-query": "workspace:*",
"redaxios": "^0.5.1",
"zod": "^3.24.2",
@@ -23,7 +23,7 @@
"@types/react-dom": "^19.0.3",
"@vitejs/plugin-react": "^4.3.4",
"typescript": "^5.7.2",
- "vite": "^6.3.5",
+ "vite": "^7.1.1",
"vite-plugin-dts": "^4.5.0"
}
}
diff --git a/examples/react/router-monorepo-simple-lazy/package.json b/examples/react/router-monorepo-simple-lazy/package.json
index d4a3029590..688faf3ec0 100644
--- a/examples/react/router-monorepo-simple-lazy/package.json
+++ b/examples/react/router-monorepo-simple-lazy/package.json
@@ -8,9 +8,9 @@
"dev": "pnpm router build && pnpm post-feature build && pnpm app dev"
},
"dependencies": {
- "@tanstack/react-router": "^1.131.27",
- "@tanstack/react-router-devtools": "^1.131.27",
- "@tanstack/router-plugin": "^1.131.27",
+ "@tanstack/react-router": "^1.132.0-alpha.8",
+ "@tanstack/react-router-devtools": "^1.132.0-alpha.8",
+ "@tanstack/router-plugin": "^1.132.0-alpha.9",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"redaxios": "^0.5.1"
@@ -21,7 +21,7 @@
"@types/react-dom": "^19.0.3",
"@vitejs/plugin-react": "^4.3.4",
"typescript": "^5.7.2",
- "vite": "^6.3.5",
+ "vite": "^7.1.1",
"vite-plugin-dts": "^4.5.0"
},
"keywords": [],
diff --git a/examples/react/router-monorepo-simple-lazy/packages/app/package.json b/examples/react/router-monorepo-simple-lazy/packages/app/package.json
index 83b440dbfa..62583965fb 100644
--- a/examples/react/router-monorepo-simple-lazy/packages/app/package.json
+++ b/examples/react/router-monorepo-simple-lazy/packages/app/package.json
@@ -19,11 +19,11 @@
"@types/react-dom": "^19.0.3",
"@vitejs/plugin-react": "^4.3.4",
"typescript": "^5.7.2",
- "@tanstack/react-router-devtools": "^1.131.27",
+ "@tanstack/react-router-devtools": "^1.132.0-alpha.8",
"postcss": "^8.5.1",
"autoprefixer": "^10.4.20",
"tailwindcss": "^3.4.17",
- "vite": "^6.3.5",
+ "vite": "^7.1.1",
"vite-plugin-dts": "^4.5.0"
},
"nx": {
diff --git a/examples/react/router-monorepo-simple-lazy/packages/post-feature/package.json b/examples/react/router-monorepo-simple-lazy/packages/post-feature/package.json
index 324c49737a..b241c9403e 100644
--- a/examples/react/router-monorepo-simple-lazy/packages/post-feature/package.json
+++ b/examples/react/router-monorepo-simple-lazy/packages/post-feature/package.json
@@ -26,7 +26,7 @@
"@types/react-dom": "^19.0.3",
"@vitejs/plugin-react": "^4.3.4",
"typescript": "^5.7.2",
- "vite": "^6.3.5",
+ "vite": "^7.1.1",
"vite-plugin-dts": "^4.5.0"
}
}
diff --git a/examples/react/router-monorepo-simple-lazy/packages/router/package.json b/examples/react/router-monorepo-simple-lazy/packages/router/package.json
index 6e117762ff..38cb555a8f 100644
--- a/examples/react/router-monorepo-simple-lazy/packages/router/package.json
+++ b/examples/react/router-monorepo-simple-lazy/packages/router/package.json
@@ -8,9 +8,9 @@
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"dependencies": {
- "@tanstack/history": "^1.131.2",
- "@tanstack/react-router": "^1.131.27",
- "@tanstack/router-plugin": "^1.131.27",
+ "@tanstack/history": "^1.132.0-alpha.1",
+ "@tanstack/react-router": "^1.132.0-alpha.8",
+ "@tanstack/router-plugin": "^1.132.0-alpha.9",
"redaxios": "^0.5.1",
"zod": "^3.24.2",
"react": "^19.0.0",
@@ -21,7 +21,7 @@
"@types/react-dom": "^19.0.3",
"@vitejs/plugin-react": "^4.3.4",
"typescript": "^5.7.2",
- "vite": "^6.3.5",
+ "vite": "^7.1.1",
"vite-plugin-dts": "^4.5.0"
}
}
diff --git a/examples/react/router-monorepo-simple/package.json b/examples/react/router-monorepo-simple/package.json
index 014b10473e..2148423baa 100644
--- a/examples/react/router-monorepo-simple/package.json
+++ b/examples/react/router-monorepo-simple/package.json
@@ -8,9 +8,9 @@
"dev": "pnpm router build && pnpm post-feature build && pnpm app dev"
},
"dependencies": {
- "@tanstack/react-router": "^1.131.27",
- "@tanstack/react-router-devtools": "^1.131.27",
- "@tanstack/router-plugin": "^1.131.27",
+ "@tanstack/react-router": "^1.132.0-alpha.8",
+ "@tanstack/react-router-devtools": "^1.132.0-alpha.8",
+ "@tanstack/router-plugin": "^1.132.0-alpha.9",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"redaxios": "^0.5.1"
@@ -21,7 +21,7 @@
"@types/react-dom": "^19.0.3",
"@vitejs/plugin-react": "^4.3.4",
"typescript": "^5.7.2",
- "vite": "^6.3.5",
+ "vite": "^7.1.1",
"vite-plugin-dts": "^4.5.0"
},
"keywords": [],
diff --git a/examples/react/router-monorepo-simple/packages/app/package.json b/examples/react/router-monorepo-simple/packages/app/package.json
index f810d00600..217cefae00 100644
--- a/examples/react/router-monorepo-simple/packages/app/package.json
+++ b/examples/react/router-monorepo-simple/packages/app/package.json
@@ -19,8 +19,8 @@
"@types/react-dom": "^19.0.3",
"@vitejs/plugin-react": "^4.3.4",
"typescript": "^5.7.2",
- "@tanstack/react-router-devtools": "^1.131.27",
- "vite": "^6.3.5",
+ "@tanstack/react-router-devtools": "^1.132.0-alpha.8",
+ "vite": "^7.1.1",
"postcss": "^8.5.1",
"autoprefixer": "^10.4.20",
"tailwindcss": "^3.4.17",
diff --git a/examples/react/router-monorepo-simple/packages/post-feature/package.json b/examples/react/router-monorepo-simple/packages/post-feature/package.json
index 2a5ff9288e..eaeb4539ff 100644
--- a/examples/react/router-monorepo-simple/packages/post-feature/package.json
+++ b/examples/react/router-monorepo-simple/packages/post-feature/package.json
@@ -17,7 +17,7 @@
"@types/react-dom": "^19.0.3",
"@vitejs/plugin-react": "^4.3.4",
"typescript": "^5.7.2",
- "vite": "^6.3.5",
+ "vite": "^7.1.1",
"vite-plugin-dts": "^4.5.0"
}
}
diff --git a/examples/react/router-monorepo-simple/packages/router/package.json b/examples/react/router-monorepo-simple/packages/router/package.json
index 3ed9caf884..7d2bd94072 100644
--- a/examples/react/router-monorepo-simple/packages/router/package.json
+++ b/examples/react/router-monorepo-simple/packages/router/package.json
@@ -8,9 +8,9 @@
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"dependencies": {
- "@tanstack/history": "^1.131.2",
- "@tanstack/react-router": "^1.131.27",
- "@tanstack/router-plugin": "^1.131.27",
+ "@tanstack/history": "^1.132.0-alpha.1",
+ "@tanstack/react-router": "^1.132.0-alpha.8",
+ "@tanstack/router-plugin": "^1.132.0-alpha.9",
"redaxios": "^0.5.1",
"zod": "^3.24.2",
"react": "^19.0.0",
@@ -21,7 +21,7 @@
"@types/react-dom": "^19.0.3",
"@vitejs/plugin-react": "^4.3.4",
"typescript": "^5.7.2",
- "vite": "^6.3.5",
+ "vite": "^7.1.1",
"vite-plugin-dts": "^4.5.0"
}
}
diff --git a/examples/react/scroll-restoration/package.json b/examples/react/scroll-restoration/package.json
index fe1be853f1..b99369a9c5 100644
--- a/examples/react/scroll-restoration/package.json
+++ b/examples/react/scroll-restoration/package.json
@@ -9,9 +9,9 @@
"start": "vite"
},
"dependencies": {
- "@tanstack/react-router": "^1.131.27",
+ "@tanstack/react-router": "^1.132.0-alpha.8",
"@tanstack/react-virtual": "^3.13.0",
- "@tanstack/react-router-devtools": "^1.131.27",
+ "@tanstack/react-router-devtools": "^1.132.0-alpha.8",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"postcss": "^8.5.1",
@@ -23,6 +23,6 @@
"@types/react-dom": "^19.0.3",
"@vitejs/plugin-react": "^4.3.4",
"typescript": "^5.7.2",
- "vite": "^6.3.5"
+ "vite": "^7.1.1"
}
}
diff --git a/examples/react/search-validator-adapters/package.json b/examples/react/search-validator-adapters/package.json
index e6bd20f7e2..a45fcfb353 100644
--- a/examples/react/search-validator-adapters/package.json
+++ b/examples/react/search-validator-adapters/package.json
@@ -10,13 +10,13 @@
"test:unit": "vitest"
},
"dependencies": {
- "@tanstack/arktype-adapter": "^1.131.27",
+ "@tanstack/arktype-adapter": "^1.132.0-alpha.8",
"@tanstack/react-query": "^5.66.0",
- "@tanstack/react-router": "^1.131.27",
- "@tanstack/react-router-devtools": "^1.131.27",
- "@tanstack/router-plugin": "^1.131.27",
- "@tanstack/valibot-adapter": "^1.131.27",
- "@tanstack/zod-adapter": "^1.131.27",
+ "@tanstack/react-router": "^1.132.0-alpha.8",
+ "@tanstack/react-router-devtools": "^1.132.0-alpha.8",
+ "@tanstack/router-plugin": "^1.132.0-alpha.9",
+ "@tanstack/valibot-adapter": "^1.132.0-alpha.8",
+ "@tanstack/zod-adapter": "^1.132.0-alpha.8",
"arktype": "^2.1.7",
"react": "^19.0.0",
"react-dom": "^19.0.0",
@@ -33,6 +33,6 @@
"@types/react-dom": "^19.0.3",
"@vitejs/plugin-react": "^4.3.4",
"typescript": "^5.7.2",
- "vite": "^6.3.5"
+ "vite": "^7.1.1"
}
}
diff --git a/examples/react/start-bare/package.json b/examples/react/start-bare/package.json
index 08e46031e5..aba78050a1 100644
--- a/examples/react/start-bare/package.json
+++ b/examples/react/start-bare/package.json
@@ -9,9 +9,9 @@
"start": "vite start"
},
"dependencies": {
- "@tanstack/react-router": "^1.131.27",
- "@tanstack/react-router-devtools": "^1.131.27",
- "@tanstack/react-start": "^1.131.27",
+ "@tanstack/react-router": "^1.132.0-alpha.8",
+ "@tanstack/react-router-devtools": "^1.132.0-alpha.8",
+ "@tanstack/react-start": "^1.132.0-alpha.11",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"zod": "^3.24.2"
@@ -20,8 +20,9 @@
"@types/node": "^22.5.4",
"@types/react": "^19.0.8",
"@types/react-dom": "^19.0.3",
+ "@vitejs/plugin-react": "^4.3.4",
"typescript": "^5.7.2",
- "vite": "^6.3.5",
+ "vite": "^7.1.1",
"vite-tsconfig-paths": "^5.1.4"
}
}
diff --git a/examples/react/start-bare/vite.config.ts b/examples/react/start-bare/vite.config.ts
index 1f5fd1961a..f10c86e79f 100644
--- a/examples/react/start-bare/vite.config.ts
+++ b/examples/react/start-bare/vite.config.ts
@@ -1,6 +1,7 @@
import { tanstackStart } from '@tanstack/react-start/plugin/vite'
import { defineConfig } from 'vite'
import tsConfigPaths from 'vite-tsconfig-paths'
+import viteReact from '@vitejs/plugin-react'
export default defineConfig({
server: {
@@ -11,5 +12,6 @@ export default defineConfig({
projects: ['./tsconfig.json'],
}),
tanstackStart(),
+ viteReact(),
],
})
diff --git a/examples/react/start-basic-auth/package.json b/examples/react/start-basic-auth/package.json
index 427828eee7..8ae3291554 100644
--- a/examples/react/start-basic-auth/package.json
+++ b/examples/react/start-basic-auth/package.json
@@ -11,9 +11,9 @@
},
"dependencies": {
"@prisma/client": "5.22.0",
- "@tanstack/react-router": "^1.131.27",
- "@tanstack/react-router-devtools": "^1.131.27",
- "@tanstack/react-start": "^1.131.27",
+ "@tanstack/react-router": "^1.132.0-alpha.8",
+ "@tanstack/react-router-devtools": "^1.132.0-alpha.8",
+ "@tanstack/react-start": "^1.132.0-alpha.11",
"prisma": "^5.22.0",
"react": "^19.0.0",
"react-dom": "^19.0.0",
@@ -21,6 +21,7 @@
"tailwind-merge": "^2.6.0"
},
"devDependencies": {
+ "@vitejs/plugin-react": "^4.3.4",
"@types/node": "^22.5.4",
"@types/react": "^19.0.8",
"@types/react-dom": "^19.0.3",
@@ -28,7 +29,7 @@
"autoprefixer": "^10.4.20",
"tailwindcss": "^3.4.17",
"typescript": "^5.7.2",
- "vite": "^6.3.5",
+ "vite": "^7.1.1",
"vite-tsconfig-paths": "^5.1.4"
}
}
diff --git a/examples/react/start-basic-auth/vite.config.ts b/examples/react/start-basic-auth/vite.config.ts
index 1f5fd1961a..f10c86e79f 100644
--- a/examples/react/start-basic-auth/vite.config.ts
+++ b/examples/react/start-basic-auth/vite.config.ts
@@ -1,6 +1,7 @@
import { tanstackStart } from '@tanstack/react-start/plugin/vite'
import { defineConfig } from 'vite'
import tsConfigPaths from 'vite-tsconfig-paths'
+import viteReact from '@vitejs/plugin-react'
export default defineConfig({
server: {
@@ -11,5 +12,6 @@ export default defineConfig({
projects: ['./tsconfig.json'],
}),
tanstackStart(),
+ viteReact(),
],
})
diff --git a/examples/react/start-basic-react-query/package.json b/examples/react/start-basic-react-query/package.json
index 262d1e9aa0..7f0cc072b4 100644
--- a/examples/react/start-basic-react-query/package.json
+++ b/examples/react/start-basic-react-query/package.json
@@ -11,10 +11,10 @@
"dependencies": {
"@tanstack/react-query": "^5.66.0",
"@tanstack/react-query-devtools": "^5.66.0",
- "@tanstack/react-router": "^1.131.27",
- "@tanstack/react-router-ssr-query": "^1.131.27",
- "@tanstack/react-router-devtools": "^1.131.27",
- "@tanstack/react-start": "^1.131.27",
+ "@tanstack/react-router": "^1.132.0-alpha.8",
+ "@tanstack/react-router-ssr-query": "^1.132.0-alpha.8",
+ "@tanstack/react-router-devtools": "^1.132.0-alpha.8",
+ "@tanstack/react-start": "^1.132.0-alpha.11",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"redaxios": "^0.5.1",
@@ -24,11 +24,12 @@
"@types/node": "^22.5.4",
"@types/react": "^19.0.8",
"@types/react-dom": "^19.0.3",
+ "@vitejs/plugin-react": "^4.3.4",
"postcss": "^8.5.1",
"autoprefixer": "^10.4.20",
"tailwindcss": "^3.4.17",
"typescript": "^5.7.2",
- "vite": "^6.3.5",
+ "vite": "^7.1.1",
"vite-tsconfig-paths": "^5.1.4"
}
}
diff --git a/examples/react/start-basic-react-query/vite.config.ts b/examples/react/start-basic-react-query/vite.config.ts
index 1f5fd1961a..f10c86e79f 100644
--- a/examples/react/start-basic-react-query/vite.config.ts
+++ b/examples/react/start-basic-react-query/vite.config.ts
@@ -1,6 +1,7 @@
import { tanstackStart } from '@tanstack/react-start/plugin/vite'
import { defineConfig } from 'vite'
import tsConfigPaths from 'vite-tsconfig-paths'
+import viteReact from '@vitejs/plugin-react'
export default defineConfig({
server: {
@@ -11,5 +12,6 @@ export default defineConfig({
projects: ['./tsconfig.json'],
}),
tanstackStart(),
+ viteReact(),
],
})
diff --git a/examples/react/start-basic-rsc/package.json b/examples/react/start-basic-rsc/package.json
index 754091755d..bbabbcd155 100644
--- a/examples/react/start-basic-rsc/package.json
+++ b/examples/react/start-basic-rsc/package.json
@@ -10,9 +10,9 @@
},
"dependencies": {
"@babel/plugin-syntax-typescript": "^7.25.9",
- "@tanstack/react-router": "^1.131.27",
- "@tanstack/react-router-devtools": "^1.131.27",
- "@tanstack/react-start": "^1.131.27",
+ "@tanstack/react-router": "^1.132.0-alpha.8",
+ "@tanstack/react-router-devtools": "^1.132.0-alpha.8",
+ "@tanstack/react-start": "^1.132.0-alpha.11",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"redaxios": "^0.5.1",
@@ -21,11 +21,12 @@
"devDependencies": {
"@types/react": "^19.0.8",
"@types/react-dom": "^19.0.3",
+ "@vitejs/plugin-react": "^4.3.4",
"postcss": "^8.5.1",
"autoprefixer": "^10.4.20",
"tailwindcss": "^3.4.17",
"typescript": "^5.7.2",
- "vite": "^6.3.5",
+ "vite": "^7.1.1",
"vite-tsconfig-paths": "^5.1.4"
},
"overrides": {
diff --git a/examples/react/start-basic-rsc/vite.config.ts b/examples/react/start-basic-rsc/vite.config.ts
index 1f5fd1961a..f10c86e79f 100644
--- a/examples/react/start-basic-rsc/vite.config.ts
+++ b/examples/react/start-basic-rsc/vite.config.ts
@@ -1,6 +1,7 @@
import { tanstackStart } from '@tanstack/react-start/plugin/vite'
import { defineConfig } from 'vite'
import tsConfigPaths from 'vite-tsconfig-paths'
+import viteReact from '@vitejs/plugin-react'
export default defineConfig({
server: {
@@ -11,5 +12,6 @@ export default defineConfig({
projects: ['./tsconfig.json'],
}),
tanstackStart(),
+ viteReact(),
],
})
diff --git a/examples/react/start-basic-static/package.json b/examples/react/start-basic-static/package.json
index 129c87e330..056e10e328 100644
--- a/examples/react/start-basic-static/package.json
+++ b/examples/react/start-basic-static/package.json
@@ -9,9 +9,10 @@
"start": "vite start"
},
"dependencies": {
- "@tanstack/react-router": "^1.131.27",
- "@tanstack/react-router-devtools": "^1.131.27",
- "@tanstack/react-start": "^1.131.27",
+ "@tanstack/react-router": "^1.132.0-alpha.8",
+ "@tanstack/react-router-devtools": "^1.132.0-alpha.8",
+ "@tanstack/react-start": "^1.132.0-alpha.11",
+ "@tanstack/start-static-server-functions": "^1.132.0-alpha.11",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"redaxios": "^0.5.1",
@@ -25,7 +26,7 @@
"postcss": "^8.4.49",
"tailwindcss": "^3.4.15",
"typescript": "^5.6.2",
- "vite": "^6.3.5",
+ "vite": "^7.1.1",
"vite-tsconfig-paths": "^5.1.3"
}
}
diff --git a/examples/react/start-basic-static/src/routes/deferred.tsx b/examples/react/start-basic-static/src/routes/deferred.tsx
index e59a871e7b..07810ddc39 100644
--- a/examples/react/start-basic-static/src/routes/deferred.tsx
+++ b/examples/react/start-basic-static/src/routes/deferred.tsx
@@ -1,14 +1,17 @@
import { Await, createFileRoute } from '@tanstack/react-router'
import { createServerFn } from '@tanstack/react-start'
import { Suspense, useState } from 'react'
+import { staticFunctionMiddleware } from '@tanstack/start-static-server-functions'
-const personServerFn = createServerFn({ method: 'GET', type: 'static' })
+const personServerFn = createServerFn({ method: 'GET' })
+ .middleware([staticFunctionMiddleware])
.validator((d: string) => d)
.handler(({ data: name }) => {
return { name, randomNumber: Math.floor(Math.random() * 100) }
})
-const slowServerFn = createServerFn({ method: 'GET', type: 'static' })
+const slowServerFn = createServerFn({ method: 'GET' })
+ .middleware([staticFunctionMiddleware])
.validator((d: string) => d)
.handler(async ({ data: name }) => {
await new Promise((r) => setTimeout(r, 1000))
diff --git a/examples/react/start-basic-static/src/routes/users.$userId.tsx b/examples/react/start-basic-static/src/routes/users.$userId.tsx
index d166885e29..2d2d32279d 100644
--- a/examples/react/start-basic-static/src/routes/users.$userId.tsx
+++ b/examples/react/start-basic-static/src/routes/users.$userId.tsx
@@ -4,8 +4,10 @@ import { createServerFn } from '@tanstack/react-start'
import type { ErrorComponentProps } from '@tanstack/react-router'
import type { User } from '~/utils/users'
import { NotFound } from '~/components/NotFound'
+import { staticFunctionMiddleware } from '@tanstack/start-static-server-functions'
-const fetchUser = createServerFn({ method: 'GET', type: 'static' })
+const fetchUser = createServerFn({ method: 'GET' })
+ .middleware([staticFunctionMiddleware])
.validator((d: string) => d)
.handler(async ({ data: userId }) => {
return axios
diff --git a/examples/react/start-basic-static/src/routes/users.tsx b/examples/react/start-basic-static/src/routes/users.tsx
index 95eeacaf63..98fb79518b 100644
--- a/examples/react/start-basic-static/src/routes/users.tsx
+++ b/examples/react/start-basic-static/src/routes/users.tsx
@@ -2,9 +2,11 @@ import { Link, Outlet, createFileRoute } from '@tanstack/react-router'
import axios from 'redaxios'
import { createServerFn } from '@tanstack/react-start'
import type { User } from '../utils/users'
+import { staticFunctionMiddleware } from '@tanstack/start-static-server-functions'
-const fetchUsers = createServerFn({ method: 'GET', type: 'static' }).handler(
- async () => {
+const fetchUsers = createServerFn({ method: 'GET' })
+ .middleware([staticFunctionMiddleware])
+ .handler(async () => {
console.info('Fetching users...')
const res = await axios.get>(
'https://jsonplaceholder.typicode.com/users',
@@ -13,8 +15,7 @@ const fetchUsers = createServerFn({ method: 'GET', type: 'static' }).handler(
return res.data
.slice(0, 10)
.map((u) => ({ id: u.id, name: u.name, email: u.email }))
- },
-)
+ })
export const Route = createFileRoute('/users')({
loader: async () => fetchUsers(),
diff --git a/examples/react/start-basic-static/src/utils/posts.tsx b/examples/react/start-basic-static/src/utils/posts.tsx
index 79f52eea47..82e568ceef 100644
--- a/examples/react/start-basic-static/src/utils/posts.tsx
+++ b/examples/react/start-basic-static/src/utils/posts.tsx
@@ -2,6 +2,7 @@ import { createServerFn } from '@tanstack/react-start'
import axios from 'redaxios'
import { notFound } from '@tanstack/react-router'
import { logMiddleware } from './loggingMiddleware'
+import { staticFunctionMiddleware } from '@tanstack/start-static-server-functions'
export type PostType = {
id: string
@@ -9,8 +10,8 @@ export type PostType = {
body: string
}
-export const fetchPost = createServerFn({ method: 'GET', type: 'static' })
- .middleware([logMiddleware])
+export const fetchPost = createServerFn({ method: 'GET' })
+ .middleware([logMiddleware, staticFunctionMiddleware])
.validator((d: string) => d)
.handler(async ({ data }) => {
console.info(`Fetching post with id ${data}...`)
@@ -27,8 +28,8 @@ export const fetchPost = createServerFn({ method: 'GET', type: 'static' })
return post
})
-export const fetchPosts = createServerFn({ method: 'GET', type: 'static' })
- .middleware([logMiddleware])
+export const fetchPosts = createServerFn({ method: 'GET' })
+ .middleware([logMiddleware, staticFunctionMiddleware])
.handler(async () => {
console.info('Fetching posts...')
return axios
diff --git a/examples/react/start-basic-static/vite.config.ts b/examples/react/start-basic-static/vite.config.ts
index 303ac171c9..07451c7d66 100644
--- a/examples/react/start-basic-static/vite.config.ts
+++ b/examples/react/start-basic-static/vite.config.ts
@@ -20,6 +20,9 @@ export default defineConfig({
sitemap: {
host: 'https://localhost:3000',
},
+ prerender: {
+ failOnError: false,
+ },
}),
],
})
diff --git a/examples/react/start-basic/package.json b/examples/react/start-basic/package.json
index 819bc12fe5..4539714bbf 100644
--- a/examples/react/start-basic/package.json
+++ b/examples/react/start-basic/package.json
@@ -9,9 +9,9 @@
"start": "node .output/server/index.mjs"
},
"dependencies": {
- "@tanstack/react-router": "^1.131.27",
- "@tanstack/react-router-devtools": "^1.131.27",
- "@tanstack/react-start": "^1.131.27",
+ "@tanstack/react-router": "^1.132.0-alpha.8",
+ "@tanstack/react-router-devtools": "^1.132.0-alpha.8",
+ "@tanstack/react-start": "^1.132.0-alpha.11",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"tailwind-merge": "^2.6.0",
@@ -26,7 +26,7 @@
"postcss": "^8.5.1",
"tailwindcss": "^3.4.17",
"typescript": "^5.7.2",
- "vite": "^6.3.5",
+ "vite": "^7.1.1",
"vite-tsconfig-paths": "^5.1.4"
}
}
diff --git a/examples/react/start-basic/src/routes/index.tsx b/examples/react/start-basic/src/routes/index.tsx
index 37c8d237bd..09a907cb18 100644
--- a/examples/react/start-basic/src/routes/index.tsx
+++ b/examples/react/start-basic/src/routes/index.tsx
@@ -1,4 +1,5 @@
import { createFileRoute } from '@tanstack/react-router'
+
export const Route = createFileRoute('/')({
component: Home,
})
diff --git a/examples/react/start-basic/vite.config.ts b/examples/react/start-basic/vite.config.ts
index 70067dfa49..f10c86e79f 100644
--- a/examples/react/start-basic/vite.config.ts
+++ b/examples/react/start-basic/vite.config.ts
@@ -11,7 +11,7 @@ export default defineConfig({
tsConfigPaths({
projects: ['./tsconfig.json'],
}),
- tanstackStart({ customViteReactPlugin: true }),
+ tanstackStart(),
viteReact(),
],
})
diff --git a/examples/react/start-clerk-basic/package.json b/examples/react/start-clerk-basic/package.json
index 8a0e5a1262..bb256161f7 100644
--- a/examples/react/start-clerk-basic/package.json
+++ b/examples/react/start-clerk-basic/package.json
@@ -10,9 +10,10 @@
},
"dependencies": {
"@clerk/tanstack-react-start": "^0.19.0",
- "@tanstack/react-router": "^1.131.27",
- "@tanstack/react-router-devtools": "^1.131.27",
- "@tanstack/react-start": "^1.131.27",
+ "@tanstack/react-router": "^1.132.0-alpha.8",
+ "@tanstack/react-router-devtools": "^1.132.0-alpha.8",
+ "@tanstack/react-start": "^1.132.0-alpha.11",
+ "@vitejs/plugin-react": "^4.3.4",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"redaxios": "^0.5.1",
@@ -26,7 +27,7 @@
"autoprefixer": "^10.4.20",
"tailwindcss": "^3.4.17",
"typescript": "^5.7.2",
- "vite": "^6.3.5",
+ "vite": "^7.1.1",
"vite-tsconfig-paths": "^5.1.4"
}
}
diff --git a/examples/react/start-clerk-basic/src/routes/__root.tsx b/examples/react/start-clerk-basic/src/routes/__root.tsx
index 1842003cea..80ce274116 100644
--- a/examples/react/start-clerk-basic/src/routes/__root.tsx
+++ b/examples/react/start-clerk-basic/src/routes/__root.tsx
@@ -17,13 +17,13 @@ import { TanStackRouterDevtools } from '@tanstack/react-router-devtools'
import { createServerFn } from '@tanstack/react-start'
import * as React from 'react'
import { getAuth } from '@clerk/tanstack-react-start/server'
-import { getWebRequest } from '@tanstack/react-start/server'
+import { getRequest } from '@tanstack/react-start/server'
import { DefaultCatchBoundary } from '~/components/DefaultCatchBoundary.js'
import { NotFound } from '~/components/NotFound.js'
import appCss from '~/styles/app.css?url'
const fetchClerkAuth = createServerFn({ method: 'GET' }).handler(async () => {
- const { userId } = await getAuth(getWebRequest()!)
+ const { userId } = await getAuth(getRequest())
return {
userId,
diff --git a/examples/react/start-clerk-basic/src/server.ts b/examples/react/start-clerk-basic/src/server.ts
index 7fb77bd8cb..116dda52ff 100644
--- a/examples/react/start-clerk-basic/src/server.ts
+++ b/examples/react/start-clerk-basic/src/server.ts
@@ -11,4 +11,6 @@ const handler = createStartHandler({
const clerkHandler = createClerkHandler(handler)
-export default clerkHandler(defaultStreamHandler)
+export default {
+ fetch: clerkHandler(defaultStreamHandler),
+}
diff --git a/examples/react/start-clerk-basic/vite.config.ts b/examples/react/start-clerk-basic/vite.config.ts
index 1f5fd1961a..f10c86e79f 100644
--- a/examples/react/start-clerk-basic/vite.config.ts
+++ b/examples/react/start-clerk-basic/vite.config.ts
@@ -1,6 +1,7 @@
import { tanstackStart } from '@tanstack/react-start/plugin/vite'
import { defineConfig } from 'vite'
import tsConfigPaths from 'vite-tsconfig-paths'
+import viteReact from '@vitejs/plugin-react'
export default defineConfig({
server: {
@@ -11,5 +12,6 @@ export default defineConfig({
projects: ['./tsconfig.json'],
}),
tanstackStart(),
+ viteReact(),
],
})
diff --git a/examples/react/start-convex-trellaux/package.json b/examples/react/start-convex-trellaux/package.json
index 0791371413..c5ba95605c 100644
--- a/examples/react/start-convex-trellaux/package.json
+++ b/examples/react/start-convex-trellaux/package.json
@@ -14,10 +14,10 @@
"@convex-dev/react-query": "0.0.0-alpha.8",
"@tanstack/react-query": "^5.66.0",
"@tanstack/react-query-devtools": "^5.66.0",
- "@tanstack/react-router": "^1.131.27",
- "@tanstack/react-router-ssr-query": "^1.131.27",
- "@tanstack/react-router-devtools": "^1.131.27",
- "@tanstack/react-start": "^1.131.27",
+ "@tanstack/react-router": "^1.132.0-alpha.8",
+ "@tanstack/react-router-ssr-query": "^1.132.0-alpha.8",
+ "@tanstack/react-router-devtools": "^1.132.0-alpha.8",
+ "@tanstack/react-start": "^1.132.0-alpha.11",
"concurrently": "^8.2.2",
"convex": "^1.19.0",
"ky": "^1.7.4",
@@ -33,11 +33,12 @@
"devDependencies": {
"@types/react": "^19.0.8",
"@types/react-dom": "^19.0.3",
+ "@vitejs/plugin-react": "^4.3.4",
"postcss": "^8.5.1",
"autoprefixer": "^10.4.20",
"tailwindcss": "^3.4.17",
"typescript": "^5.7.2",
- "vite": "^6.3.5",
+ "vite": "^7.1.1",
"vite-tsconfig-paths": "^5.1.4"
}
}
diff --git a/examples/react/start-convex-trellaux/vite.config.ts b/examples/react/start-convex-trellaux/vite.config.ts
index 1f5fd1961a..f10c86e79f 100644
--- a/examples/react/start-convex-trellaux/vite.config.ts
+++ b/examples/react/start-convex-trellaux/vite.config.ts
@@ -1,6 +1,7 @@
import { tanstackStart } from '@tanstack/react-start/plugin/vite'
import { defineConfig } from 'vite'
import tsConfigPaths from 'vite-tsconfig-paths'
+import viteReact from '@vitejs/plugin-react'
export default defineConfig({
server: {
@@ -11,5 +12,6 @@ export default defineConfig({
projects: ['./tsconfig.json'],
}),
tanstackStart(),
+ viteReact(),
],
})
diff --git a/examples/react/start-counter/package.json b/examples/react/start-counter/package.json
index acbea16c31..c4326137c1 100644
--- a/examples/react/start-counter/package.json
+++ b/examples/react/start-counter/package.json
@@ -9,9 +9,9 @@
"start": "vite start"
},
"dependencies": {
- "@tanstack/react-router": "^1.131.27",
- "@tanstack/react-router-devtools": "^1.131.27",
- "@tanstack/react-start": "^1.131.27",
+ "@tanstack/react-router": "^1.132.0-alpha.8",
+ "@tanstack/react-router-devtools": "^1.132.0-alpha.8",
+ "@tanstack/react-start": "^1.132.0-alpha.11",
"react": "^19.0.0",
"react-dom": "^19.0.0"
},
@@ -19,7 +19,8 @@
"@types/node": "^22.5.4",
"@types/react": "^19.0.8",
"@types/react-dom": "^19.0.3",
+ "@vitejs/plugin-react": "^4.3.4",
"typescript": "^5.7.2",
- "vite": "^6.3.5"
+ "vite": "^7.1.1"
}
}
diff --git a/examples/react/start-counter/vite.config.ts b/examples/react/start-counter/vite.config.ts
index 86790438cf..bae3acaefe 100644
--- a/examples/react/start-counter/vite.config.ts
+++ b/examples/react/start-counter/vite.config.ts
@@ -1,9 +1,10 @@
import { tanstackStart } from '@tanstack/react-start/plugin/vite'
import { defineConfig } from 'vite'
+import viteReact from '@vitejs/plugin-react'
export default defineConfig({
server: {
port: 3000,
},
- plugins: [tanstackStart()],
+ plugins: [tanstackStart(), viteReact()],
})
diff --git a/examples/react/start-large/package.json b/examples/react/start-large/package.json
index 5cc9131bcc..65eb87b515 100644
--- a/examples/react/start-large/package.json
+++ b/examples/react/start-large/package.json
@@ -12,9 +12,9 @@
},
"dependencies": {
"@tanstack/react-query": "^5.66.0",
- "@tanstack/react-router": "^1.131.27",
- "@tanstack/react-router-devtools": "^1.131.27",
- "@tanstack/react-start": "^1.131.27",
+ "@tanstack/react-router": "^1.132.0-alpha.8",
+ "@tanstack/react-router-devtools": "^1.132.0-alpha.8",
+ "@tanstack/react-start": "^1.132.0-alpha.11",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"redaxios": "^0.5.1",
@@ -25,11 +25,12 @@
"@types/node": "^22.5.4",
"@types/react": "^19.0.8",
"@types/react-dom": "^19.0.3",
+ "@vitejs/plugin-react": "^4.3.4",
"postcss": "^8.5.1",
"autoprefixer": "^10.4.20",
"tailwindcss": "^3.4.17",
"typescript": "^5.7.2",
- "vite": "^6.3.5",
+ "vite": "^7.1.1",
"vite-tsconfig-paths": "^5.1.4"
},
"keywords": [],
diff --git a/examples/react/start-large/src/routes/search/searchPlaceholder.tsx b/examples/react/start-large/src/routes/search/searchPlaceholder.tsx
index eb7f95c39a..f16813520f 100644
--- a/examples/react/start-large/src/routes/search/searchPlaceholder.tsx
+++ b/examples/react/start-large/src/routes/search/searchPlaceholder.tsx
@@ -68,7 +68,6 @@ export const Route = createFileRoute('/search/searchPlaceholder')({
return {
search,
- external,
}
},
})
diff --git a/examples/react/start-large/vite.config.ts b/examples/react/start-large/vite.config.ts
index 1f5fd1961a..f10c86e79f 100644
--- a/examples/react/start-large/vite.config.ts
+++ b/examples/react/start-large/vite.config.ts
@@ -1,6 +1,7 @@
import { tanstackStart } from '@tanstack/react-start/plugin/vite'
import { defineConfig } from 'vite'
import tsConfigPaths from 'vite-tsconfig-paths'
+import viteReact from '@vitejs/plugin-react'
export default defineConfig({
server: {
@@ -11,5 +12,6 @@ export default defineConfig({
projects: ['./tsconfig.json'],
}),
tanstackStart(),
+ viteReact(),
],
})
diff --git a/examples/react/start-material-ui/package.json b/examples/react/start-material-ui/package.json
index a83f3644ee..a69dd55a82 100644
--- a/examples/react/start-material-ui/package.json
+++ b/examples/react/start-material-ui/package.json
@@ -14,9 +14,9 @@
"@emotion/styled": "11.14.0",
"@fontsource-variable/roboto": "5.2.5",
"@mui/material": "6.4.7",
- "@tanstack/react-router": "^1.131.27",
- "@tanstack/react-start": "^1.131.27",
- "@tanstack/react-router-devtools": "^1.131.27",
+ "@tanstack/react-router": "^1.132.0-alpha.8",
+ "@tanstack/react-start": "^1.132.0-alpha.11",
+ "@tanstack/react-router-devtools": "^1.132.0-alpha.8",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"zod": "^3.24.2"
@@ -25,8 +25,9 @@
"@types/node": "^22.5.4",
"@types/react": "^19.0.8",
"@types/react-dom": "^19.0.3",
+ "@vitejs/plugin-react": "^4.3.4",
"typescript": "^5.7.2",
- "vite": "^6.3.5",
+ "vite": "^7.1.1",
"vite-tsconfig-paths": "^5.1.4"
}
}
diff --git a/examples/react/start-material-ui/vite.config.ts b/examples/react/start-material-ui/vite.config.ts
index 1c59bcc8f9..5bd46872f1 100644
--- a/examples/react/start-material-ui/vite.config.ts
+++ b/examples/react/start-material-ui/vite.config.ts
@@ -1,6 +1,7 @@
import { tanstackStart } from '@tanstack/react-start/plugin/vite'
import { defineConfig } from 'vite'
import tsConfigPaths from 'vite-tsconfig-paths'
+import viteReact from '@vitejs/plugin-react'
export default defineConfig({
server: {
@@ -14,5 +15,6 @@ export default defineConfig({
projects: ['./tsconfig.json'],
}),
tanstackStart(),
+ viteReact(),
],
})
diff --git a/examples/react/start-supabase-basic/package.json b/examples/react/start-supabase-basic/package.json
index 91cccdd0a8..f14c6498a6 100644
--- a/examples/react/start-supabase-basic/package.json
+++ b/examples/react/start-supabase-basic/package.json
@@ -15,9 +15,9 @@
"dependencies": {
"@supabase/ssr": "^0.5.2",
"@supabase/supabase-js": "^2.48.1",
- "@tanstack/react-router": "^1.131.27",
- "@tanstack/react-router-devtools": "^1.131.27",
- "@tanstack/react-start": "^1.131.27",
+ "@tanstack/react-router": "^1.132.0-alpha.8",
+ "@tanstack/react-router-devtools": "^1.132.0-alpha.8",
+ "@tanstack/react-start": "^1.132.0-alpha.11",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"redaxios": "^0.5.1"
@@ -25,11 +25,12 @@
"devDependencies": {
"@types/react": "^19.0.8",
"@types/react-dom": "^19.0.3",
+ "@vitejs/plugin-react": "^4.3.4",
"autoprefixer": "^10.4.20",
"postcss": "^8.5.1",
"tailwindcss": "^3.4.17",
"typescript": "^5.7.2",
- "vite": "^6.3.5",
+ "vite": "^7.1.1",
"vite-tsconfig-paths": "^5.1.4"
}
}
diff --git a/examples/react/start-supabase-basic/src/utils/supabase.ts b/examples/react/start-supabase-basic/src/utils/supabase.ts
index 39ad47a8fa..b06ffb81cd 100644
--- a/examples/react/start-supabase-basic/src/utils/supabase.ts
+++ b/examples/react/start-supabase-basic/src/utils/supabase.ts
@@ -1,4 +1,4 @@
-import { parseCookies, setCookie } from '@tanstack/react-start/server'
+import { getCookies, setCookie } from '@tanstack/react-start/server'
import { createServerClient } from '@supabase/ssr'
export function getSupabaseServerClient() {
@@ -8,7 +8,7 @@ export function getSupabaseServerClient() {
{
cookies: {
getAll() {
- return Object.entries(parseCookies()).map(([name, value]) => ({
+ return Object.entries(getCookies()).map(([name, value]) => ({
name,
value,
}))
diff --git a/examples/react/start-supabase-basic/vite.config.ts b/examples/react/start-supabase-basic/vite.config.ts
index 1f5fd1961a..f10c86e79f 100644
--- a/examples/react/start-supabase-basic/vite.config.ts
+++ b/examples/react/start-supabase-basic/vite.config.ts
@@ -1,6 +1,7 @@
import { tanstackStart } from '@tanstack/react-start/plugin/vite'
import { defineConfig } from 'vite'
import tsConfigPaths from 'vite-tsconfig-paths'
+import viteReact from '@vitejs/plugin-react'
export default defineConfig({
server: {
@@ -11,5 +12,6 @@ export default defineConfig({
projects: ['./tsconfig.json'],
}),
tanstackStart(),
+ viteReact(),
],
})
diff --git a/examples/react/start-tailwind-v4/package.json b/examples/react/start-tailwind-v4/package.json
index ae924e84a5..313576d77f 100644
--- a/examples/react/start-tailwind-v4/package.json
+++ b/examples/react/start-tailwind-v4/package.json
@@ -9,9 +9,9 @@
"start": "node .output/server/index.mjs"
},
"dependencies": {
- "@tanstack/react-router": "^1.131.27",
- "@tanstack/react-router-devtools": "^1.131.27",
- "@tanstack/react-start": "^1.131.27",
+ "@tanstack/react-router": "^1.132.0-alpha.8",
+ "@tanstack/react-router-devtools": "^1.132.0-alpha.8",
+ "@tanstack/react-start": "^1.132.0-alpha.11",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"tailwind-merge": "^2.6.0",
@@ -22,9 +22,10 @@
"@types/node": "^22.5.4",
"@types/react": "^19.0.8",
"@types/react-dom": "^19.0.3",
+ "@vitejs/plugin-react": "^4.3.4",
"tailwindcss": "^4.1.6",
"typescript": "^5.7.2",
- "vite": "^6.3.5",
+ "vite": "^7.1.1",
"vite-tsconfig-paths": "^5.1.4"
}
}
diff --git a/examples/react/start-tailwind-v4/vite.config.ts b/examples/react/start-tailwind-v4/vite.config.ts
index 6a8f14e7c0..360b4f7dda 100644
--- a/examples/react/start-tailwind-v4/vite.config.ts
+++ b/examples/react/start-tailwind-v4/vite.config.ts
@@ -2,6 +2,7 @@ import { tanstackStart } from '@tanstack/react-start/plugin/vite'
import { defineConfig } from 'vite'
import tsConfigPaths from 'vite-tsconfig-paths'
import tailwindcss from '@tailwindcss/vite'
+import viteReact from '@vitejs/plugin-react'
export default defineConfig({
server: {
@@ -12,6 +13,7 @@ export default defineConfig({
projects: ['./tsconfig.json'],
}),
tanstackStart(),
+ viteReact(),
tailwindcss(),
],
})
diff --git a/examples/react/start-trellaux/package.json b/examples/react/start-trellaux/package.json
index 58ae9ca86f..fc6e07cfaa 100644
--- a/examples/react/start-trellaux/package.json
+++ b/examples/react/start-trellaux/package.json
@@ -11,10 +11,10 @@
"dependencies": {
"@tanstack/react-query": "^5.66.0",
"@tanstack/react-query-devtools": "^5.66.0",
- "@tanstack/react-router": "^1.131.27",
- "@tanstack/react-router-ssr-query": "^1.131.27",
- "@tanstack/react-router-devtools": "^1.131.27",
- "@tanstack/react-start": "^1.131.27",
+ "@tanstack/react-router": "^1.132.0-alpha.8",
+ "@tanstack/react-router-ssr-query": "^1.132.0-alpha.8",
+ "@tanstack/react-router-devtools": "^1.132.0-alpha.8",
+ "@tanstack/react-start": "^1.132.0-alpha.11",
"ky": "^1.7.4",
"msw": "^2.7.0",
"react": "^19.0.0",
@@ -28,11 +28,12 @@
"devDependencies": {
"@types/react": "^19.0.8",
"@types/react-dom": "^19.0.3",
+ "@vitejs/plugin-react": "^4.3.4",
"postcss": "^8.5.1",
"autoprefixer": "^10.4.20",
"tailwindcss": "^3.4.17",
"typescript": "^5.6.2",
- "vite": "^6.3.5",
+ "vite": "^7.1.1",
"vite-tsconfig-paths": "^5.1.4"
}
}
diff --git a/examples/react/start-trellaux/vite.config.ts b/examples/react/start-trellaux/vite.config.ts
index 1f5fd1961a..f10c86e79f 100644
--- a/examples/react/start-trellaux/vite.config.ts
+++ b/examples/react/start-trellaux/vite.config.ts
@@ -1,6 +1,7 @@
import { tanstackStart } from '@tanstack/react-start/plugin/vite'
import { defineConfig } from 'vite'
import tsConfigPaths from 'vite-tsconfig-paths'
+import viteReact from '@vitejs/plugin-react'
export default defineConfig({
server: {
@@ -11,5 +12,6 @@ export default defineConfig({
projects: ['./tsconfig.json'],
}),
tanstackStart(),
+ viteReact(),
],
})
diff --git a/examples/react/start-workos/package.json b/examples/react/start-workos/package.json
index 7cda059ff2..d9dc2163a8 100644
--- a/examples/react/start-workos/package.json
+++ b/examples/react/start-workos/package.json
@@ -14,9 +14,9 @@
"license": "MIT",
"dependencies": {
"@radix-ui/themes": "^3.2.1",
- "@tanstack/react-router": "^1.131.27",
- "@tanstack/react-router-devtools": "^1.131.27",
- "@tanstack/react-start": "^1.131.27",
+ "@tanstack/react-router": "^1.132.0-alpha.8",
+ "@tanstack/react-router-devtools": "^1.132.0-alpha.8",
+ "@tanstack/react-start": "^1.132.0-alpha.11",
"@workos-inc/node": "^7.45.0",
"iron-session": "^8.0.4",
"jose": "^6.0.10",
@@ -26,11 +26,12 @@
"devDependencies": {
"@types/react": "^19.0.8",
"@types/react-dom": "^19.0.3",
+ "@vitejs/plugin-react": "^4.3.4",
"postcss": "^8.5.1",
"autoprefixer": "^10.4.20",
"tailwindcss": "^3.4.17",
"typescript": "^5.7.2",
- "vite": "^6.3.5",
+ "vite": "^7.1.1",
"vite-tsconfig-paths": "^5.1.4"
}
}
diff --git a/examples/react/start-workos/src/authkit/serverFunctions.ts b/examples/react/start-workos/src/authkit/serverFunctions.ts
index 8ce62c746b..f41ddb9dd0 100644
--- a/examples/react/start-workos/src/authkit/serverFunctions.ts
+++ b/examples/react/start-workos/src/authkit/serverFunctions.ts
@@ -31,7 +31,7 @@ export const getSignUpUrl = createServerFn({ method: 'GET' })
return getAuthorizationUrl({ data: { returnPathname, screenHint: 'sign-up' } });
});
-export const signOut = createServerFn({ method: 'POST', response: 'full' })
+export const signOut = createServerFn({ method: 'POST' })
.validator((data?: string) => data)
.handler(async ({ data: returnTo }) => {
const cookieName = getConfig('cookieName') || 'wos_session';
diff --git a/examples/react/start-workos/src/routes/logout.tsx b/examples/react/start-workos/src/routes/logout.tsx
index 41e8bc0b88..401d6cbc99 100644
--- a/examples/react/start-workos/src/routes/logout.tsx
+++ b/examples/react/start-workos/src/routes/logout.tsx
@@ -3,5 +3,7 @@ import { signOut } from '../authkit/serverFunctions';
export const Route = createFileRoute('/logout')({
preload: false,
- loader: () => signOut(),
+ loader: async () => {
+ await signOut();
+ },
});
diff --git a/examples/react/start-workos/vite.config.ts b/examples/react/start-workos/vite.config.ts
index cd888de96e..fce3baa54d 100644
--- a/examples/react/start-workos/vite.config.ts
+++ b/examples/react/start-workos/vite.config.ts
@@ -1,6 +1,7 @@
import { defineConfig } from 'vite';
import tsConfigPaths from 'vite-tsconfig-paths';
import { tanstackStart } from '@tanstack/react-start/plugin/vite';
+import viteReact from '@vitejs/plugin-react';
export default defineConfig({
server: {
@@ -11,5 +12,6 @@ export default defineConfig({
projects: ['./tsconfig.json'],
}),
tanstackStart(),
+ viteReact(),
],
});
diff --git a/examples/react/view-transitions/package.json b/examples/react/view-transitions/package.json
index f5b7a3e8be..9e2092d5c3 100644
--- a/examples/react/view-transitions/package.json
+++ b/examples/react/view-transitions/package.json
@@ -9,9 +9,9 @@
"start": "vite"
},
"dependencies": {
- "@tanstack/react-router": "^1.131.27",
- "@tanstack/react-router-devtools": "^1.131.27",
- "@tanstack/router-plugin": "^1.131.27",
+ "@tanstack/react-router": "^1.132.0-alpha.8",
+ "@tanstack/react-router-devtools": "^1.132.0-alpha.8",
+ "@tanstack/router-plugin": "^1.132.0-alpha.9",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"redaxios": "^0.5.1",
@@ -25,6 +25,6 @@
"@types/react-dom": "^19.0.3",
"@vitejs/plugin-react": "^4.3.4",
"typescript": "^5.7.2",
- "vite": "^6.3.5"
+ "vite": "^7.1.1"
}
}
diff --git a/examples/react/with-framer-motion/package.json b/examples/react/with-framer-motion/package.json
index 125088bd0b..2efe53a5b7 100644
--- a/examples/react/with-framer-motion/package.json
+++ b/examples/react/with-framer-motion/package.json
@@ -9,8 +9,8 @@
"start": "vite"
},
"dependencies": {
- "@tanstack/react-router": "^1.131.27",
- "@tanstack/react-router-devtools": "^1.131.27",
+ "@tanstack/react-router": "^1.132.0-alpha.8",
+ "@tanstack/react-router-devtools": "^1.132.0-alpha.8",
"framer-motion": "^11.18.2",
"react": "^19.0.0",
"react-dom": "^19.0.0",
@@ -25,6 +25,6 @@
"@types/react-dom": "^19.0.3",
"@vitejs/plugin-react": "^4.3.4",
"typescript": "^5.7.2",
- "vite": "^6.3.5"
+ "vite": "^7.1.1"
}
}
diff --git a/examples/react/with-trpc-react-query/package.json b/examples/react/with-trpc-react-query/package.json
index 7bdc7a81d1..97194eae0f 100644
--- a/examples/react/with-trpc-react-query/package.json
+++ b/examples/react/with-trpc-react-query/package.json
@@ -12,9 +12,9 @@
"dependencies": {
"@tanstack/react-query": "^5.66.0",
"@tanstack/react-query-devtools": "^5.66.0",
- "@tanstack/react-router": "^1.131.27",
- "@tanstack/react-router-devtools": "^1.131.27",
- "@tanstack/router-plugin": "^1.131.27",
+ "@tanstack/react-router": "^1.132.0-alpha.8",
+ "@tanstack/react-router-devtools": "^1.132.0-alpha.8",
+ "@tanstack/router-plugin": "^1.132.0-alpha.9",
"@trpc/client": "^11.4.3",
"@trpc/server": "^11.4.3",
"@trpc/tanstack-react-query": "^11.4.3",
@@ -33,6 +33,6 @@
"@types/react-dom": "^19.0.3",
"@vitejs/plugin-react": "^4.3.4",
"tsx": "^4.20.3",
- "vite": "^6.3.5"
+ "vite": "^7.1.1"
}
}
diff --git a/examples/react/with-trpc-react-query/src/server/server.ts b/examples/react/with-trpc-react-query/src/server/server.ts
index 1f8b4a3c47..b2b3fd2485 100644
--- a/examples/react/with-trpc-react-query/src/server/server.ts
+++ b/examples/react/with-trpc-react-query/src/server/server.ts
@@ -24,7 +24,7 @@ export const createServer = async (
) => {
const app = express()
- app.use('/trpc', trpcMiddleWare)
+ app.use('/trpc', trpcMiddleWare as any)
if (!isProd) {
const vite = await import('vite')
diff --git a/examples/react/with-trpc/package.json b/examples/react/with-trpc/package.json
index c70d3a3d99..d175f1bca4 100644
--- a/examples/react/with-trpc/package.json
+++ b/examples/react/with-trpc/package.json
@@ -10,9 +10,9 @@
"start": "NODE_ENV=production node dist/server/server.js"
},
"dependencies": {
- "@tanstack/react-router": "^1.131.27",
- "@tanstack/react-router-devtools": "^1.131.27",
- "@tanstack/router-plugin": "^1.131.27",
+ "@tanstack/react-router": "^1.132.0-alpha.8",
+ "@tanstack/react-router-devtools": "^1.132.0-alpha.8",
+ "@tanstack/router-plugin": "^1.132.0-alpha.9",
"@trpc/client": "^11.4.3",
"@trpc/server": "^11.4.3",
"autoprefixer": "^10.4.20",
@@ -30,6 +30,6 @@
"@types/react-dom": "^19.0.3",
"@vitejs/plugin-react": "^4.3.4",
"tsx": "^4.20.3",
- "vite": "^6.3.5"
+ "vite": "^7.1.1"
}
}
diff --git a/examples/react/with-trpc/src/server/server.ts b/examples/react/with-trpc/src/server/server.ts
index 1f8b4a3c47..b2b3fd2485 100644
--- a/examples/react/with-trpc/src/server/server.ts
+++ b/examples/react/with-trpc/src/server/server.ts
@@ -24,7 +24,7 @@ export const createServer = async (
) => {
const app = express()
- app.use('/trpc', trpcMiddleWare)
+ app.use('/trpc', trpcMiddleWare as any)
if (!isProd) {
const vite = await import('vite')
diff --git a/examples/solid/basic-devtools-panel/package.json b/examples/solid/basic-devtools-panel/package.json
index 4ce5f54c2f..e08a7090b8 100644
--- a/examples/solid/basic-devtools-panel/package.json
+++ b/examples/solid/basic-devtools-panel/package.json
@@ -9,8 +9,8 @@
"start": "vite"
},
"dependencies": {
- "@tanstack/solid-router": "^1.131.27",
- "@tanstack/solid-router-devtools": "^1.131.27",
+ "@tanstack/solid-router": "^1.132.0-alpha.8",
+ "@tanstack/solid-router-devtools": "^1.132.0-alpha.8",
"solid-js": "^1.9.5",
"redaxios": "^0.5.1",
"postcss": "^8.5.1",
@@ -18,8 +18,8 @@
"tailwindcss": "^3.4.17"
},
"devDependencies": {
- "vite-plugin-solid": "^2.11.6",
+ "vite-plugin-solid": "^2.11.8",
"typescript": "^5.7.2",
- "vite": "^6.3.5"
+ "vite": "^7.1.1"
}
}
diff --git a/examples/solid/basic-file-based/package.json b/examples/solid/basic-file-based/package.json
index 38fb420733..111b199056 100644
--- a/examples/solid/basic-file-based/package.json
+++ b/examples/solid/basic-file-based/package.json
@@ -9,8 +9,8 @@
"start": "vite"
},
"dependencies": {
- "@tanstack/solid-router": "^1.131.27",
- "@tanstack/solid-router-devtools": "^1.131.27",
+ "@tanstack/solid-router": "^1.132.0-alpha.8",
+ "@tanstack/solid-router-devtools": "^1.132.0-alpha.8",
"autoprefixer": "^10.4.20",
"postcss": "^8.5.1",
"redaxios": "^0.5.1",
@@ -19,9 +19,9 @@
"zod": "^3.24.2"
},
"devDependencies": {
- "@tanstack/router-plugin": "^1.131.27",
+ "@tanstack/router-plugin": "^1.132.0-alpha.9",
"typescript": "^5.7.2",
- "vite": "^6.3.5",
- "vite-plugin-solid": "^2.11.2"
+ "vite": "^7.1.1",
+ "vite-plugin-solid": "^2.11.8"
}
}
diff --git a/examples/solid/basic-non-nested-devtools/package.json b/examples/solid/basic-non-nested-devtools/package.json
index 8a6e98fffd..7de1d869a5 100644
--- a/examples/solid/basic-non-nested-devtools/package.json
+++ b/examples/solid/basic-non-nested-devtools/package.json
@@ -9,8 +9,8 @@
"start": "vite"
},
"dependencies": {
- "@tanstack/solid-router": "^1.131.27",
- "@tanstack/solid-router-devtools": "^1.131.27",
+ "@tanstack/solid-router": "^1.132.0-alpha.8",
+ "@tanstack/solid-router-devtools": "^1.132.0-alpha.8",
"redaxios": "^0.5.1",
"postcss": "^8.5.1",
"solid-js": "^1.9.5",
@@ -21,7 +21,7 @@
"@types/react": "^19.0.8",
"@types/react-dom": "^19.0.3",
"typescript": "^5.7.2",
- "vite": "^6.3.5",
- "vite-plugin-solid": "^2.11.2"
+ "vite": "^7.1.1",
+ "vite-plugin-solid": "^2.11.8"
}
}
diff --git a/examples/solid/basic-solid-query-file-based/package.json b/examples/solid/basic-solid-query-file-based/package.json
index 9fd42f656d..e731e16545 100644
--- a/examples/solid/basic-solid-query-file-based/package.json
+++ b/examples/solid/basic-solid-query-file-based/package.json
@@ -12,8 +12,8 @@
"dependencies": {
"@tanstack/solid-query": "^5.71.9",
"@tanstack/solid-query-devtools": "^5.71.9",
- "@tanstack/solid-router": "^1.131.27",
- "@tanstack/solid-router-devtools": "^1.131.27",
+ "@tanstack/solid-router": "^1.132.0-alpha.8",
+ "@tanstack/solid-router-devtools": "^1.132.0-alpha.8",
"solid-js": "^1.9.5",
"redaxios": "^0.5.1",
"postcss": "^8.5.1",
@@ -22,9 +22,9 @@
"zod": "^3.24.2"
},
"devDependencies": {
- "@tanstack/router-plugin": "^1.131.27",
+ "@tanstack/router-plugin": "^1.132.0-alpha.9",
"typescript": "^5.7.2",
- "vite": "^6.3.5",
- "vite-plugin-solid": "^2.11.2"
+ "vite": "^7.1.1",
+ "vite-plugin-solid": "^2.11.8"
}
}
diff --git a/examples/solid/basic-solid-query/package.json b/examples/solid/basic-solid-query/package.json
index a8753480b6..a76789d211 100644
--- a/examples/solid/basic-solid-query/package.json
+++ b/examples/solid/basic-solid-query/package.json
@@ -11,8 +11,8 @@
"dependencies": {
"@tanstack/solid-query": "^5.71.9",
"@tanstack/solid-query-devtools": "^5.71.9",
- "@tanstack/solid-router": "^1.131.27",
- "@tanstack/solid-router-devtools": "^1.131.27",
+ "@tanstack/solid-router": "^1.132.0-alpha.8",
+ "@tanstack/solid-router-devtools": "^1.132.0-alpha.8",
"solid-js": "^1.9.5",
"redaxios": "^0.5.1",
"postcss": "^8.5.1",
@@ -20,9 +20,9 @@
"tailwindcss": "^3.4.17"
},
"devDependencies": {
- "@tanstack/router-plugin": "^1.131.27",
+ "@tanstack/router-plugin": "^1.132.0-alpha.9",
"typescript": "^5.7.2",
- "vite": "^6.3.5",
- "vite-plugin-solid": "^2.11.2"
+ "vite": "^7.1.1",
+ "vite-plugin-solid": "^2.11.8"
}
}
diff --git a/examples/solid/basic-ssr-streaming-file-based/package.json b/examples/solid/basic-ssr-streaming-file-based/package.json
index e510325686..749e1f3c14 100644
--- a/examples/solid/basic-ssr-streaming-file-based/package.json
+++ b/examples/solid/basic-ssr-streaming-file-based/package.json
@@ -11,13 +11,12 @@
"debug": "node --inspect-brk server"
},
"dependencies": {
- "@tanstack/solid-router": "^1.131.27",
- "@tanstack/solid-router-devtools": "^1.131.27",
+ "@tanstack/solid-router": "^1.132.0-alpha.8",
+ "@tanstack/solid-router-devtools": "^1.132.0-alpha.8",
"autoprefixer": "^10.4.20",
"compression": "^1.7.5",
"express": "^4.21.2",
"get-port": "^7.1.0",
- "isbot": "^5.1.22",
"node-fetch": "^3.3.2",
"postcss": "^8.5.1",
"redaxios": "^0.5.1",
@@ -26,10 +25,10 @@
"zod": "^3.24.2"
},
"devDependencies": {
- "@tanstack/router-plugin": "^1.131.27",
+ "@tanstack/router-plugin": "^1.132.0-alpha.9",
"@types/express": "^4.17.21",
"typescript": "^5.7.2",
- "vite": "^6.3.5",
- "vite-plugin-solid": "^2.11.2"
+ "vite": "^7.1.1",
+ "vite-plugin-solid": "^2.11.8"
}
}
diff --git a/examples/solid/basic/package.json b/examples/solid/basic/package.json
index bf87ae2799..e00a929292 100644
--- a/examples/solid/basic/package.json
+++ b/examples/solid/basic/package.json
@@ -9,8 +9,8 @@
"start": "vite"
},
"dependencies": {
- "@tanstack/solid-router": "^1.131.27",
- "@tanstack/solid-router-devtools": "^1.131.27",
+ "@tanstack/solid-router": "^1.132.0-alpha.8",
+ "@tanstack/solid-router-devtools": "^1.132.0-alpha.8",
"redaxios": "^0.5.1",
"postcss": "^8.5.1",
"solid-js": "^1.9.5",
@@ -21,7 +21,7 @@
"@types/react": "^19.0.8",
"@types/react-dom": "^19.0.3",
"typescript": "^5.7.2",
- "vite": "^6.3.5",
- "vite-plugin-solid": "^2.11.2"
+ "vite": "^7.1.1",
+ "vite-plugin-solid": "^2.11.8"
}
}
diff --git a/examples/solid/kitchen-sink-file-based/package.json b/examples/solid/kitchen-sink-file-based/package.json
index 483d1f7acb..ec4450c694 100644
--- a/examples/solid/kitchen-sink-file-based/package.json
+++ b/examples/solid/kitchen-sink-file-based/package.json
@@ -9,8 +9,8 @@
"start": "vite"
},
"dependencies": {
- "@tanstack/solid-router": "^1.131.27",
- "@tanstack/solid-router-devtools": "^1.131.27",
+ "@tanstack/solid-router": "^1.132.0-alpha.8",
+ "@tanstack/solid-router-devtools": "^1.132.0-alpha.8",
"immer": "^10.1.1",
"solid-js": "^1.9.5",
"redaxios": "^0.5.1",
@@ -20,9 +20,9 @@
"zod": "^3.24.2"
},
"devDependencies": {
- "@tanstack/router-plugin": "^1.131.27",
+ "@tanstack/router-plugin": "^1.132.0-alpha.9",
"typescript": "^5.7.2",
- "vite": "^6.3.5",
- "vite-plugin-solid": "^2.11.2"
+ "vite": "^7.1.1",
+ "vite-plugin-solid": "^2.11.8"
}
}
diff --git a/examples/solid/quickstart-file-based/package.json b/examples/solid/quickstart-file-based/package.json
index 123e3178d7..940c3351bf 100644
--- a/examples/solid/quickstart-file-based/package.json
+++ b/examples/solid/quickstart-file-based/package.json
@@ -9,8 +9,8 @@
"start": "vite"
},
"dependencies": {
- "@tanstack/solid-router": "^1.131.27",
- "@tanstack/solid-router-devtools": "^1.131.27",
+ "@tanstack/solid-router": "^1.132.0-alpha.8",
+ "@tanstack/solid-router-devtools": "^1.132.0-alpha.8",
"autoprefixer": "^10.4.20",
"postcss": "^8.5.1",
"redaxios": "^0.5.1",
@@ -19,9 +19,9 @@
"zod": "^3.24.2"
},
"devDependencies": {
- "@tanstack/router-plugin": "^1.131.27",
+ "@tanstack/router-plugin": "^1.132.0-alpha.9",
"typescript": "^5.7.2",
- "vite": "^6.3.5",
- "vite-plugin-solid": "^2.11.2"
+ "vite": "^7.1.1",
+ "vite-plugin-solid": "^2.11.8"
}
}
diff --git a/examples/solid/start-bare/package.json b/examples/solid/start-bare/package.json
index a4a46cc667..2d9888a4e4 100644
--- a/examples/solid/start-bare/package.json
+++ b/examples/solid/start-bare/package.json
@@ -9,9 +9,9 @@
"start": "vite start"
},
"dependencies": {
- "@tanstack/solid-router": "^1.131.27",
- "@tanstack/solid-router-devtools": "^1.131.27",
- "@tanstack/solid-start": "^1.131.27",
+ "@tanstack/solid-router": "^1.132.0-alpha.8",
+ "@tanstack/solid-router-devtools": "^1.132.0-alpha.8",
+ "@tanstack/solid-start": "^1.132.0-alpha.11",
"solid-js": "^1.9.5",
"redaxios": "^0.5.1",
"tailwind-merge": "^2.6.0",
@@ -19,10 +19,10 @@
},
"devDependencies": {
"@types/node": "^22.10.2",
- "vite-plugin-solid": "^2.11.2",
+ "vite-plugin-solid": "^2.11.8",
"combinate": "^1.1.11",
"typescript": "^5.7.2",
- "vite": "^6.3.5",
+ "vite": "^7.1.1",
"vite-tsconfig-paths": "^5.1.4"
}
}
diff --git a/examples/solid/start-bare/vite.config.ts b/examples/solid/start-bare/vite.config.ts
index bae1bfaad6..1a2219f443 100644
--- a/examples/solid/start-bare/vite.config.ts
+++ b/examples/solid/start-bare/vite.config.ts
@@ -1,6 +1,7 @@
import { defineConfig } from 'vite'
import tsConfigPaths from 'vite-tsconfig-paths'
import { tanstackStart } from '@tanstack/solid-start/plugin/vite'
+import viteSolid from 'vite-plugin-solid'
export default defineConfig({
server: {
@@ -11,5 +12,6 @@ export default defineConfig({
projects: ['./tsconfig.json'],
}),
tanstackStart(),
+ viteSolid({ ssr: true }),
],
})
diff --git a/examples/solid/start-basic-static/package.json b/examples/solid/start-basic-static/package.json
index b3373d60eb..3fe66d41c7 100644
--- a/examples/solid/start-basic-static/package.json
+++ b/examples/solid/start-basic-static/package.json
@@ -9,9 +9,10 @@
"start": "vite start"
},
"dependencies": {
- "@tanstack/solid-router": "^1.131.27",
- "@tanstack/solid-router-devtools": "^1.131.27",
- "@tanstack/solid-start": "^1.131.27",
+ "@tanstack/solid-router": "^1.132.0-alpha.8",
+ "@tanstack/solid-router-devtools": "^1.132.0-alpha.8",
+ "@tanstack/solid-start": "^1.132.0-alpha.11",
+ "@tanstack/start-static-server-functions": "^1.132.0-alpha.11",
"solid-js": "^1.9.5",
"redaxios": "^0.5.1",
"tailwind-merge": "^2.5.5"
@@ -22,7 +23,8 @@
"postcss": "^8.4.49",
"tailwindcss": "^3.4.15",
"typescript": "^5.6.2",
- "vite": "^6.3.5",
- "vite-tsconfig-paths": "^5.1.3"
+ "vite": "^7.1.1",
+ "vite-tsconfig-paths": "^5.1.3",
+ "vite-plugin-solid": "^2.11.8"
}
}
diff --git a/examples/solid/start-basic-static/src/routes/__root.tsx b/examples/solid/start-basic-static/src/routes/__root.tsx
index c439d9dfcd..6d60d836c7 100644
--- a/examples/solid/start-basic-static/src/routes/__root.tsx
+++ b/examples/solid/start-basic-static/src/routes/__root.tsx
@@ -73,68 +73,63 @@ function RootComponent() {
function RootLayout({ children }: { children: Solid.JSX.Element }) {
return (
-
-
-
-
-
-
-
- Home
- {' '}
-
- Posts
- {' '}
-
- Users
- {' '}
-
- Pathless Layout
- {' '}
-
- Deferred
- {' '}
-
- This Route Does Not Exist
-
-
-
- {children}
-
-
-
-
+ <>
+
+
+ Home
+ {' '}
+
+ Posts
+ {' '}
+
+ Users
+ {' '}
+
+ Pathless Layout
+ {' '}
+
+ Deferred
+ {' '}
+
+ This Route Does Not Exist
+
+
+
+ {children}
+
+
+ >
)
}
diff --git a/examples/solid/start-basic-static/src/routes/deferred.tsx b/examples/solid/start-basic-static/src/routes/deferred.tsx
index ce617191eb..17ea8b7400 100644
--- a/examples/solid/start-basic-static/src/routes/deferred.tsx
+++ b/examples/solid/start-basic-static/src/routes/deferred.tsx
@@ -1,14 +1,17 @@
import { Await, createFileRoute } from '@tanstack/solid-router'
import { createServerFn } from '@tanstack/solid-start'
import { Suspense, createSignal } from 'solid-js'
+import { staticFunctionMiddleware } from '@tanstack/start-static-server-functions'
-const personServerFn = createServerFn({ method: 'GET', type: 'static' })
+const personServerFn = createServerFn({ method: 'GET' })
+ .middleware([staticFunctionMiddleware])
.validator((d: string) => d)
.handler(({ data: name }) => {
return { name, randomNumber: Math.floor(Math.random() * 100) }
})
-const slowServerFn = createServerFn({ method: 'GET', type: 'static' })
+const slowServerFn = createServerFn({ method: 'GET' })
+ .middleware([staticFunctionMiddleware])
.validator((d: string) => d)
.handler(async ({ data: name }) => {
await new Promise((r) => setTimeout(r, 1000))
diff --git a/examples/solid/start-basic-static/src/routes/posts.$postId.tsx b/examples/solid/start-basic-static/src/routes/posts.$postId.tsx
index 73bbe72553..df0b03af9e 100644
--- a/examples/solid/start-basic-static/src/routes/posts.$postId.tsx
+++ b/examples/solid/start-basic-static/src/routes/posts.$postId.tsx
@@ -12,7 +12,7 @@ export const Route = createFileRoute('/posts/$postId')({
},
})
-export function PostErrorComponent({ error }: ErrorComponentProps) {
+function PostErrorComponent({ error }: ErrorComponentProps) {
return
}
@@ -21,12 +21,12 @@ function PostComponent() {
return (
-
{post.title}
-
{post.body}
+
{post().title}
+
{post().body}
fetchPost({
data: postId,
}),
- errorComponent: PostErrorComponent,
component: PostDeepComponent,
})
diff --git a/examples/solid/start-basic-static/src/routes/users.$userId.tsx b/examples/solid/start-basic-static/src/routes/users.$userId.tsx
index 928077c240..2c667b8ceb 100644
--- a/examples/solid/start-basic-static/src/routes/users.$userId.tsx
+++ b/examples/solid/start-basic-static/src/routes/users.$userId.tsx
@@ -4,8 +4,10 @@ import { createServerFn } from '@tanstack/solid-start'
import type { ErrorComponentProps } from '@tanstack/solid-router'
import type { User } from '~/utils/users'
import { NotFound } from '~/components/NotFound'
+import { staticFunctionMiddleware } from '@tanstack/start-static-server-functions'
-const fetchUser = createServerFn({ method: 'GET', type: 'static' })
+const fetchUser = createServerFn({ method: 'GET' })
+ .middleware([staticFunctionMiddleware])
.validator((d: string) => d)
.handler(async ({ data: userId }) => {
return axios
@@ -29,7 +31,7 @@ export const Route = createFileRoute('/users/$userId')({
},
})
-export function UserErrorComponent({ error }: ErrorComponentProps) {
+function UserErrorComponent({ error }: ErrorComponentProps) {
return
}
diff --git a/examples/solid/start-basic-static/src/routes/users.tsx b/examples/solid/start-basic-static/src/routes/users.tsx
index 1b5e9e23a2..19a36135ac 100644
--- a/examples/solid/start-basic-static/src/routes/users.tsx
+++ b/examples/solid/start-basic-static/src/routes/users.tsx
@@ -2,9 +2,11 @@ import { Link, Outlet, createFileRoute } from '@tanstack/solid-router'
import axios from 'redaxios'
import { createServerFn } from '@tanstack/solid-start'
import type { User } from '../utils/users'
+import { staticFunctionMiddleware } from '@tanstack/start-static-server-functions'
-const fetchUsers = createServerFn({ method: 'GET', type: 'static' }).handler(
- async () => {
+const fetchUsers = createServerFn({ method: 'GET' })
+ .middleware([staticFunctionMiddleware])
+ .handler(async () => {
console.info('Fetching users...')
const res = await axios.get
>(
'https://jsonplaceholder.typicode.com/users',
@@ -13,8 +15,7 @@ const fetchUsers = createServerFn({ method: 'GET', type: 'static' }).handler(
return res.data
.slice(0, 10)
.map((u) => ({ id: u.id, name: u.name, email: u.email }))
- },
-)
+ })
export const Route = createFileRoute('/users')({
loader: async () => fetchUsers(),
diff --git a/examples/solid/start-basic-static/src/utils/posts.tsx b/examples/solid/start-basic-static/src/utils/posts.tsx
index 204230b7fe..01a6673569 100644
--- a/examples/solid/start-basic-static/src/utils/posts.tsx
+++ b/examples/solid/start-basic-static/src/utils/posts.tsx
@@ -2,6 +2,7 @@ import { createServerFn } from '@tanstack/solid-start'
import axios from 'redaxios'
import { notFound } from '@tanstack/solid-router'
import { logMiddleware } from './loggingMiddleware'
+import { staticFunctionMiddleware } from '@tanstack/start-static-server-functions'
export type PostType = {
id: string
@@ -9,8 +10,8 @@ export type PostType = {
body: string
}
-export const fetchPost = createServerFn({ method: 'GET', type: 'static' })
- .middleware([logMiddleware])
+export const fetchPost = createServerFn({ method: 'GET' })
+ .middleware([logMiddleware, staticFunctionMiddleware])
.validator((d: string) => d)
.handler(async ({ data }) => {
console.info(`Fetching post with id ${data}...`)
@@ -27,8 +28,8 @@ export const fetchPost = createServerFn({ method: 'GET', type: 'static' })
return post
})
-export const fetchPosts = createServerFn({ method: 'GET', type: 'static' })
- .middleware([logMiddleware])
+export const fetchPosts = createServerFn({ method: 'GET' })
+ .middleware([logMiddleware, staticFunctionMiddleware])
.handler(async () => {
console.info('Fetching posts...')
return axios
diff --git a/examples/solid/start-basic-static/vite.config.ts b/examples/solid/start-basic-static/vite.config.ts
index 213bd9189e..97fcbafb57 100644
--- a/examples/solid/start-basic-static/vite.config.ts
+++ b/examples/solid/start-basic-static/vite.config.ts
@@ -1,6 +1,7 @@
import { tanstackStart } from '@tanstack/solid-start/plugin/vite'
import { defineConfig } from 'vite'
import tsConfigPaths from 'vite-tsconfig-paths'
+import viteSolid from 'vite-plugin-solid'
export default defineConfig({
server: {
@@ -13,7 +14,20 @@ export default defineConfig({
tanstackStart({
spa: {
enabled: true,
+ prerender: {
+ crawlLinks: true,
+ },
+ },
+ sitemap: {
+ host: 'https://localhost:3000',
+ },
+ prerender: {
+ failOnError: true,
+ filter: (page) => {
+ return !page.path.includes('exist')
+ },
},
}),
+ viteSolid({ ssr: true }),
],
})
diff --git a/examples/solid/start-basic/package.json b/examples/solid/start-basic/package.json
index b60df07623..9ce6e62a15 100644
--- a/examples/solid/start-basic/package.json
+++ b/examples/solid/start-basic/package.json
@@ -9,9 +9,9 @@
"start": "vite start"
},
"dependencies": {
- "@tanstack/solid-router": "^1.131.27",
- "@tanstack/solid-router-devtools": "^1.131.27",
- "@tanstack/solid-start": "^1.131.27",
+ "@tanstack/solid-router": "^1.132.0-alpha.8",
+ "@tanstack/solid-router-devtools": "^1.132.0-alpha.8",
+ "@tanstack/solid-start": "^1.132.0-alpha.11",
"solid-js": "^1.9.5",
"redaxios": "^0.5.1",
"tailwind-merge": "^2.6.0"
@@ -22,8 +22,8 @@
"postcss": "^8.5.1",
"tailwindcss": "^3.4.17",
"typescript": "^5.7.2",
- "vite": "^6.3.5",
- "vite-plugin-solid": "^2.11.7",
+ "vite": "^7.1.1",
+ "vite-plugin-solid": "^2.11.8",
"vite-tsconfig-paths": "^5.1.4"
}
}
diff --git a/examples/solid/start-basic/src/utils/posts.tsx b/examples/solid/start-basic/src/utils/posts.tsx
index e29706d38c..22db5ebb5f 100644
--- a/examples/solid/start-basic/src/utils/posts.tsx
+++ b/examples/solid/start-basic/src/utils/posts.tsx
@@ -8,7 +8,7 @@ export type PostType = {
body: string
}
-export const fetchPost = createServerFn({ method: 'GET', type: 'static' })
+export const fetchPost = createServerFn({ method: 'GET' })
.validator((d: string) => d)
.handler(async ({ data }) => {
console.info(`Fetching post with id ${data}...`)
@@ -28,7 +28,6 @@ export const fetchPost = createServerFn({ method: 'GET', type: 'static' })
export const fetchPosts = createServerFn({
method: 'GET',
- type: 'static',
}).handler(async () => {
console.info('Fetching posts...')
return axios
diff --git a/examples/solid/start-basic/vite.config.ts b/examples/solid/start-basic/vite.config.ts
index 93d987e62a..1a2219f443 100644
--- a/examples/solid/start-basic/vite.config.ts
+++ b/examples/solid/start-basic/vite.config.ts
@@ -11,7 +11,7 @@ export default defineConfig({
tsConfigPaths({
projects: ['./tsconfig.json'],
}),
- tanstackStart({ customViteSolidPlugin: true }),
+ tanstackStart(),
viteSolid({ ssr: true }),
],
})
diff --git a/labeler-config.yml b/labeler-config.yml
index 015ae4ec3a..bce0cbe37b 100644
--- a/labeler-config.yml
+++ b/labeler-config.yml
@@ -25,9 +25,6 @@
'package: react-start-client':
- changed-files:
- any-glob-to-any-file: 'packages/react-start-client/**/*'
-'package: react-start-plugin':
- - changed-files:
- - any-glob-to-any-file: 'packages/react-start-plugin/**/*'
'package: react-start-server':
- changed-files:
- any-glob-to-any-file: 'packages/react-start-server/**/*'
@@ -73,9 +70,6 @@
'package: solid-start-client':
- changed-files:
- any-glob-to-any-file: 'packages/solid-start-client/**/*'
-'package: solid-start-plugin':
- - changed-files:
- - any-glob-to-any-file: 'packages/solid-start-plugin/**/*'
'package: solid-start-server':
- changed-files:
- any-glob-to-any-file: 'packages/solid-start-server/**/*'
@@ -88,15 +82,9 @@
'package: start-server-core':
- changed-files:
- any-glob-to-any-file: 'packages/start-server-core/**/*'
-'package: start-server-functions-client':
+'package: start-static-server-functions':
- changed-files:
- - any-glob-to-any-file: 'packages/start-server-functions-client/**/*'
-'package: start-server-functions-fetcher':
- - changed-files:
- - any-glob-to-any-file: 'packages/start-server-functions-fetcher/**/*'
-'package: start-server-functions-server':
- - changed-files:
- - any-glob-to-any-file: 'packages/start-server-functions-server/**/*'
+ - any-glob-to-any-file: 'packages/start-static-server-functions/**/*'
'package: start-storage-context':
- changed-files:
- any-glob-to-any-file: 'packages/start-storage-context/**/*'
diff --git a/package.json b/package.json
index f4d91cf9ba..ec29778600 100644
--- a/package.json
+++ b/package.json
@@ -61,13 +61,13 @@
"rimraf": "^6.0.1",
"tinyglobby": "^0.2.12",
"typescript": "^5.9.0",
- "vite": "6.3.5",
- "vitest": "^3.0.6",
"typescript54": "npm:typescript@5.4",
"typescript55": "npm:typescript@5.5",
"typescript56": "npm:typescript@5.6",
"typescript57": "npm:typescript@5.7",
- "typescript58": "npm:typescript@5.8"
+ "typescript58": "npm:typescript@5.8",
+ "vite": "^7.1.1",
+ "vitest": "^3.2.4"
},
"pnpm": {
"overrides": {
@@ -99,15 +99,10 @@
"@tanstack/arktype-adapter": "workspace:*",
"@tanstack/react-start": "workspace:*",
"@tanstack/react-start-client": "workspace:*",
- "@tanstack/react-start-plugin": "workspace:*",
"@tanstack/react-start-server": "workspace:*",
"@tanstack/solid-start": "workspace:*",
"@tanstack/solid-start-client": "workspace:*",
- "@tanstack/solid-start-plugin": "workspace:*",
"@tanstack/solid-start-server": "workspace:*",
- "@tanstack/start-server-functions-fetcher": "workspace:*",
- "@tanstack/start-server-functions-client": "workspace:*",
- "@tanstack/start-server-functions-server": "workspace:*",
"@tanstack/start-plugin-core": "workspace:*",
"@tanstack/start-client-core": "workspace:*",
"@tanstack/start-server-core": "workspace:*",
@@ -115,7 +110,8 @@
"@tanstack/eslint-plugin-router": "workspace:*",
"@tanstack/server-functions-plugin": "workspace:*",
"@tanstack/directive-functions-plugin": "workspace:*",
- "@tanstack/router-utils": "workspace:*"
+ "@tanstack/router-utils": "workspace:*",
+ "@tanstack/start-static-server-functions": "workspace:*"
}
}
}
diff --git a/packages/arktype-adapter/package.json b/packages/arktype-adapter/package.json
index 2ac8442be1..6a75108ab2 100644
--- a/packages/arktype-adapter/package.json
+++ b/packages/arktype-adapter/package.json
@@ -1,6 +1,6 @@
{
"name": "@tanstack/arktype-adapter",
- "version": "1.131.27",
+ "version": "1.132.0-alpha.8",
"description": "Modern and scalable routing for React applications",
"author": "Tanner Linsley",
"license": "MIT",
diff --git a/packages/directive-functions-plugin/package.json b/packages/directive-functions-plugin/package.json
index 62c5b30da8..d98148407c 100644
--- a/packages/directive-functions-plugin/package.json
+++ b/packages/directive-functions-plugin/package.json
@@ -1,6 +1,6 @@
{
"name": "@tanstack/directive-functions-plugin",
- "version": "1.131.2",
+ "version": "1.132.0-alpha.9",
"description": "Modern and scalable routing for React applications",
"author": "Tanner Linsley",
"license": "MIT",
@@ -77,9 +77,10 @@
"@types/babel__code-frame": "^7.0.6",
"@types/babel__core": "^7.20.5",
"@types/babel__traverse": "^7.20.7",
- "vite": "^6.0.0"
+ "dedent": "^1.6.0",
+ "vite": "^7.1.1"
},
"peerDependencies": {
- "vite": ">=6.0.0"
+ "vite": ">=6.0.0 || >=7.0.0"
}
}
diff --git a/packages/directive-functions-plugin/tests/compiler.test.ts b/packages/directive-functions-plugin/tests/compiler.test.ts
index e405a7411e..a943f7f080 100644
--- a/packages/directive-functions-plugin/tests/compiler.test.ts
+++ b/packages/directive-functions-plugin/tests/compiler.test.ts
@@ -825,12 +825,14 @@ describe('server function compilation', () => {
expect(client.compiledResult.code).toMatchInlineSnapshot(`
"import { createClientRpc } from "my-rpc-lib-client";
const generator_1 = createClientRpc("test_ts--generator_1");
- const generator = generator_1;"`)
+ const generator = generator_1;"
+ `)
expect(ssr.compiledResult.code).toMatchInlineSnapshot(`
"import { createSsrRpc } from "my-rpc-lib-server";
const generator_1 = createSsrRpc("test_ts--generator_1");
- const generator = generator_1;"`)
+ const generator = generator_1;"
+ `)
expect(server.compiledResult.code).toMatchInlineSnapshot(`
"import { createServerRpc } from "my-rpc-lib-server";
@@ -839,7 +841,8 @@ describe('server function compilation', () => {
return 'hello world';
});
const generator = generator_1;
- export { generator_1 };"`)
+ export { generator_1 };"
+ `)
})
test('async generator function', () => {
const code = `
@@ -864,12 +867,14 @@ describe('server function compilation', () => {
expect(client.compiledResult.code).toMatchInlineSnapshot(`
"import { createClientRpc } from "my-rpc-lib-client";
const asyncGenerator_1 = createClientRpc("test_ts--asyncGenerator_1");
- const asyncGenerator = asyncGenerator_1;"`)
+ const asyncGenerator = asyncGenerator_1;"
+ `)
expect(ssr.compiledResult.code).toMatchInlineSnapshot(`
"import { createSsrRpc } from "my-rpc-lib-server";
const asyncGenerator_1 = createSsrRpc("test_ts--asyncGenerator_1");
- const asyncGenerator = asyncGenerator_1;"`)
+ const asyncGenerator = asyncGenerator_1;"
+ `)
expect(server.compiledResult.code).toMatchInlineSnapshot(`
"import { createServerRpc } from "my-rpc-lib-server";
@@ -878,6 +883,7 @@ describe('server function compilation', () => {
return 'hello world';
});
const asyncGenerator = asyncGenerator_1;
- export { asyncGenerator_1 };"`)
+ export { asyncGenerator_1 };"
+ `)
})
})
diff --git a/packages/eslint-plugin-router/package.json b/packages/eslint-plugin-router/package.json
index f52e05f35f..c28a627330 100644
--- a/packages/eslint-plugin-router/package.json
+++ b/packages/eslint-plugin-router/package.json
@@ -1,6 +1,6 @@
{
"name": "@tanstack/eslint-plugin-router",
- "version": "1.131.2",
+ "version": "1.132.0-alpha.1",
"description": "ESLint plugin for TanStack Router",
"author": "Manuel Schiller",
"license": "MIT",
diff --git a/packages/history/package.json b/packages/history/package.json
index 022d1a175d..f6a63175a9 100644
--- a/packages/history/package.json
+++ b/packages/history/package.json
@@ -1,6 +1,6 @@
{
"name": "@tanstack/history",
- "version": "1.131.2",
+ "version": "1.132.0-alpha.1",
"description": "Modern and scalable routing for React applications",
"author": "Tanner Linsley",
"license": "MIT",
diff --git a/packages/react-router-devtools/package.json b/packages/react-router-devtools/package.json
index a60807bc08..5091824a04 100644
--- a/packages/react-router-devtools/package.json
+++ b/packages/react-router-devtools/package.json
@@ -1,6 +1,6 @@
{
"name": "@tanstack/react-router-devtools",
- "version": "1.131.27",
+ "version": "1.132.0-alpha.8",
"description": "Modern and scalable routing for React applications",
"author": "Tanner Linsley",
"license": "MIT",
diff --git a/packages/react-router-ssr-query/package.json b/packages/react-router-ssr-query/package.json
index 6f9f0092cc..8a5f99dd05 100644
--- a/packages/react-router-ssr-query/package.json
+++ b/packages/react-router-ssr-query/package.json
@@ -1,6 +1,6 @@
{
"name": "@tanstack/react-router-ssr-query",
- "version": "1.131.27",
+ "version": "1.132.0-alpha.8",
"description": "Modern and scalable routing for React applications",
"author": "Tanner Linsley",
"license": "MIT",
diff --git a/packages/react-router/package.json b/packages/react-router/package.json
index f96dfc6b4b..801cd0bcb1 100644
--- a/packages/react-router/package.json
+++ b/packages/react-router/package.json
@@ -1,6 +1,6 @@
{
"name": "@tanstack/react-router",
- "version": "1.131.27",
+ "version": "1.132.0-alpha.8",
"description": "Modern and scalable routing for React applications",
"author": "Tanner Linsley",
"license": "MIT",
diff --git a/packages/react-router/src/ScriptOnce.tsx b/packages/react-router/src/ScriptOnce.tsx
index 5cae90d3c7..54614183d3 100644
--- a/packages/react-router/src/ScriptOnce.tsx
+++ b/packages/react-router/src/ScriptOnce.tsx
@@ -13,7 +13,7 @@ export function ScriptOnce({
)
diff --git a/packages/react-router/src/fileRoute.ts b/packages/react-router/src/fileRoute.ts
index 0b77e986e7..674e62bcc8 100644
--- a/packages/react-router/src/fileRoute.ts
+++ b/packages/react-router/src/fileRoute.ts
@@ -20,6 +20,7 @@ import type {
FileBaseRouteOptions,
FileRoutesByPath,
LazyRouteOptions,
+ Register,
RegisteredRouter,
ResolveParams,
Route,
@@ -76,6 +77,7 @@ export class FileRoute<
}
createRoute = <
+ TRegister extends Register = Register,
TSearchValidator = undefined,
TParams = ResolveParams,
TRouteContextFn = AnyContext,
@@ -83,8 +85,10 @@ export class FileRoute<
TLoaderDeps extends Record = {},
TLoaderFn = undefined,
TChildren = unknown,
+ TSSR = unknown,
>(
options?: FileBaseRouteOptions<
+ TRegister,
TParentRoute,
TId,
TPath,
@@ -94,7 +98,9 @@ export class FileRoute<
TLoaderFn,
AnyContext,
TRouteContextFn,
- TBeforeLoadFn
+ TBeforeLoadFn,
+ AnyContext,
+ TSSR
> &
UpdatableRouteOptions<
TParentRoute,
@@ -109,6 +115,7 @@ export class FileRoute<
TBeforeLoadFn
>,
): Route<
+ TRegister,
TParentRoute,
TPath,
TFullPath,
@@ -122,7 +129,8 @@ export class FileRoute<
TLoaderDeps,
TLoaderFn,
TChildren,
- unknown
+ unknown,
+ TSSR
> => {
warning(
this.silent,
diff --git a/packages/react-router/src/index.tsx b/packages/react-router/src/index.tsx
index ed78317315..af3f75ad64 100644
--- a/packages/react-router/src/index.tsx
+++ b/packages/react-router/src/index.tsx
@@ -1,6 +1,3 @@
-export { default as invariant } from 'tiny-invariant'
-export { default as warning } from 'tiny-warning'
-
export {
defer,
TSR_DEFERRED_PROMISE,
@@ -22,16 +19,15 @@ export {
defaultStringifySearch,
parseSearchWith,
stringifySearchWith,
- escapeJSON, // SSR
functionalUpdate,
replaceEqualDeep,
isPlainObject,
isPlainArray,
deepEqual,
- shallow,
createControlledPromise,
retainSearchParams,
stripSearchParams,
+ createSerializationAdapter,
} from '@tanstack/router-core'
export type {
@@ -112,6 +108,8 @@ export type {
RouteById,
RootRouteOptions,
CreateFileRoute,
+ SerializationAdapter,
+ AnySerializationAdapter,
} from '@tanstack/router-core'
export {
@@ -250,7 +248,7 @@ export { useMatch } from './useMatch'
export { useLoaderDeps } from './useLoaderDeps'
export { useLoaderData } from './useLoaderData'
-export { redirect, isRedirect } from '@tanstack/router-core'
+export { redirect, isRedirect, createRouterConfig } from '@tanstack/router-core'
export {
RouteApi,
@@ -352,3 +350,4 @@ export { ScriptOnce } from './ScriptOnce'
export { Asset } from './Asset'
export { HeadContent } from './HeadContent'
export { Scripts } from './Scripts'
+export type * from './ssr/serializer'
diff --git a/packages/react-router/src/link.tsx b/packages/react-router/src/link.tsx
index c72d0e8567..6fea974ffe 100644
--- a/packages/react-router/src/link.tsx
+++ b/packages/react-router/src/link.tsx
@@ -7,12 +7,12 @@ import {
preloadWarning,
removeTrailingSlash,
} from '@tanstack/router-core'
+import { useActiveLocation } from './useActiveLocation'
import { useRouterState } from './useRouterState'
import { useRouter } from './useRouter'
import { useForwardedRef, useIntersectionObserver } from './utils'
-import { useMatch } from './useMatch'
import type {
AnyRouter,
Constrain,
@@ -99,19 +99,27 @@ export function useLinkProps<
structuralSharing: true as any,
})
- const from = useMatch({
- strict: false,
- select: (match) => options.from ?? match.fullPath,
+ // subscribe to location here to re-build fromPath if it changes
+ const routerLocation = useRouterState({
+ select: (s) => s.location,
+ structuralSharing: true as any,
})
- const next = React.useMemo(
- () => router.buildLocation({ ...options, from } as any),
+ const { getFromPath } = useActiveLocation()
+
+ const from = getFromPath(options.from)
+
+ const _options = React.useMemo(
+ () => {
+ return { ...options, from }
+ },
// eslint-disable-next-line react-hooks/exhaustive-deps
[
router,
+ routerLocation,
currentSearch,
- options._fromLocation,
from,
+ options._fromLocation,
options.hash,
options.to,
options.search,
@@ -122,6 +130,11 @@ export function useLinkProps<
],
)
+ const next = React.useMemo(
+ () => router.buildLocation({ ..._options } as any),
+ [router, _options],
+ )
+
const isExternal = type === 'external'
const preload =
@@ -180,34 +193,12 @@ export function useLinkProps<
},
})
- const doPreload = React.useCallback(
- () => {
- router.preloadRoute({ ...options, from } as any).catch((err) => {
- console.warn(err)
- console.warn(preloadWarning)
- })
- },
- // eslint-disable-next-line react-hooks/exhaustive-deps
- [
- router,
- options.to,
- options._fromLocation,
- from,
- options.search,
- options.hash,
- options.params,
- options.state,
- options.mask,
- options.unsafeRelative,
- options.hashScrollIntoView,
- options.href,
- options.ignoreBlocker,
- options.reloadDocument,
- options.replace,
- options.resetScroll,
- options.viewTransition,
- ],
- )
+ const doPreload = React.useCallback(() => {
+ router.preloadRoute({ ..._options } as any).catch((err) => {
+ console.warn(err)
+ console.warn(preloadWarning)
+ })
+ }, [router, _options])
const preloadViewportIoCallback = React.useCallback(
(entry: IntersectionObserverEntry | undefined) => {
@@ -235,25 +226,6 @@ export function useLinkProps<
}
}, [disabled, doPreload, preload])
- if (isExternal) {
- return {
- ...propsSafeToSpread,
- ref: innerRef as React.ComponentPropsWithRef<'a'>['ref'],
- type,
- href: to,
- ...(children && { children }),
- ...(target && { target }),
- ...(disabled && { disabled }),
- ...(style && { style }),
- ...(className && { className }),
- ...(onClick && { onClick }),
- ...(onFocus && { onFocus }),
- ...(onMouseEnter && { onMouseEnter }),
- ...(onMouseLeave && { onMouseLeave }),
- ...(onTouchStart && { onTouchStart }),
- }
- }
-
// The click handler
const handleClick = (e: React.MouseEvent) => {
if (
@@ -277,8 +249,7 @@ export function useLinkProps<
// All is well? Navigate!
// N.B. we don't call `router.commitLocation(next) here because we want to run `validateSearch` before committing
router.navigate({
- ...options,
- from,
+ ..._options,
replace,
resetScroll,
hashScrollIntoView,
@@ -289,6 +260,25 @@ export function useLinkProps<
}
}
+ if (isExternal) {
+ return {
+ ...propsSafeToSpread,
+ ref: innerRef as React.ComponentPropsWithRef<'a'>['ref'],
+ type,
+ href: to,
+ ...(children && { children }),
+ ...(target && { target }),
+ ...(disabled && { disabled }),
+ ...(style && { style }),
+ ...(className && { className }),
+ ...(onClick && { onClick }),
+ ...(onFocus && { onFocus }),
+ ...(onMouseEnter && { onMouseEnter }),
+ ...(onMouseLeave && { onMouseLeave }),
+ ...(onTouchStart && { onTouchStart }),
+ }
+ }
+
// The click handler
const handleFocus = (_: React.MouseEvent) => {
if (disabled) return
diff --git a/packages/react-router/src/route.tsx b/packages/react-router/src/route.tsx
index 42fb9c388c..f6589ffec5 100644
--- a/packages/react-router/src/route.tsx
+++ b/packages/react-router/src/route.tsx
@@ -21,6 +21,7 @@ import type {
ErrorComponentProps,
NotFoundError,
NotFoundRouteProps,
+ Register,
RegisteredRouter,
ResolveFullPath,
ResolveId,
@@ -158,6 +159,7 @@ export class RouteApi<
}
export class Route<
+ in out TRegister extends Register = Register,
in out TParentRoute extends RouteConstraints['TParentRoute'] = AnyRoute,
in out TPath extends RouteConstraints['TPath'] = '/',
in out TFullPath extends RouteConstraints['TFullPath'] = ResolveFullPath<
@@ -179,8 +181,10 @@ export class Route<
in out TLoaderFn = undefined,
in out TChildren = unknown,
in out TFileRouteTypes = unknown,
+ in out TSSR = unknown,
>
extends BaseRoute<
+ TRegister,
TParentRoute,
TPath,
TFullPath,
@@ -194,10 +198,12 @@ export class Route<
TLoaderDeps,
TLoaderFn,
TChildren,
- TFileRouteTypes
+ TFileRouteTypes,
+ TSSR
>
implements
RouteCore<
+ TRegister,
TParentRoute,
TPath,
TFullPath,
@@ -211,7 +217,8 @@ export class Route<
TLoaderDeps,
TLoaderFn,
TChildren,
- TFileRouteTypes
+ TFileRouteTypes,
+ TSSR
>
{
/**
@@ -219,6 +226,7 @@ export class Route<
*/
constructor(
options?: RouteOptions<
+ TRegister,
TParentRoute,
TId,
TCustomId,
@@ -230,7 +238,8 @@ export class Route<
TLoaderFn,
TRouterContext,
TRouteContextFn,
- TBeforeLoadFn
+ TBeforeLoadFn,
+ TSSR
>,
) {
super(options)
@@ -291,6 +300,7 @@ export class Route<
}
export function createRoute<
+ TRegister extends Register = Register,
TParentRoute extends RouteConstraints['TParentRoute'] = AnyRoute,
TPath extends RouteConstraints['TPath'] = '/',
TFullPath extends RouteConstraints['TFullPath'] = ResolveFullPath<
@@ -310,8 +320,10 @@ export function createRoute<
TLoaderDeps extends Record = {},
TLoaderFn = undefined,
TChildren = unknown,
+ TSSR = unknown,
>(
options: RouteOptions<
+ TRegister,
TParentRoute,
TId,
TCustomId,
@@ -323,9 +335,11 @@ export function createRoute<
TLoaderFn,
AnyContext,
TRouteContextFn,
- TBeforeLoadFn
+ TBeforeLoadFn,
+ TSSR
>,
): Route<
+ TRegister,
TParentRoute,
TPath,
TFullPath,
@@ -338,9 +352,11 @@ export function createRoute<
TBeforeLoadFn,
TLoaderDeps,
TLoaderFn,
- TChildren
+ TChildren,
+ TSSR
> {
return new Route<
+ TRegister,
TParentRoute,
TPath,
TFullPath,
@@ -353,36 +369,53 @@ export function createRoute<
TBeforeLoadFn,
TLoaderDeps,
TLoaderFn,
- TChildren
+ TChildren,
+ TSSR
>(options)
}
-export type AnyRootRoute = RootRoute
+export type AnyRootRoute = RootRoute<
+ any,
+ any,
+ any,
+ any,
+ any,
+ any,
+ any,
+ any,
+ any
+>
export function createRootRouteWithContext() {
return <
+ TRegister extends Register = Register,
TRouteContextFn = AnyContext,
TBeforeLoadFn = AnyContext,
TSearchValidator = undefined,
TLoaderDeps extends Record = {},
TLoaderFn = undefined,
+ TSSR = unknown,
>(
options?: RootRouteOptions<
+ TRegister,
TSearchValidator,
TRouterContext,
TRouteContextFn,
TBeforeLoadFn,
TLoaderDeps,
- TLoaderFn
+ TLoaderFn,
+ TSSR
>,
) => {
return createRootRoute<
+ TRegister,
TSearchValidator,
TRouterContext,
TRouteContextFn,
TBeforeLoadFn,
TLoaderDeps,
- TLoaderFn
+ TLoaderFn,
+ TSSR
>(options as any)
}
}
@@ -393,6 +426,7 @@ export function createRootRouteWithContext() {
export const rootRouteWithContext = createRootRouteWithContext
export class RootRoute<
+ in out TRegister extends Register = Register,
in out TSearchValidator = undefined,
in out TRouterContext = {},
in out TRouteContextFn = AnyContext,
@@ -401,8 +435,10 @@ export class RootRoute<
in out TLoaderFn = undefined,
in out TChildren = unknown,
in out TFileRouteTypes = unknown,
+ in out TSSR = unknown,
>
extends BaseRootRoute<
+ TRegister,
TSearchValidator,
TRouterContext,
TRouteContextFn,
@@ -410,10 +446,12 @@ export class RootRoute<
TLoaderDeps,
TLoaderFn,
TChildren,
- TFileRouteTypes
+ TFileRouteTypes,
+ TSSR
>
implements
RootRouteCore<
+ TRegister,
TSearchValidator,
TRouterContext,
TRouteContextFn,
@@ -421,7 +459,8 @@ export class RootRoute<
TLoaderDeps,
TLoaderFn,
TChildren,
- TFileRouteTypes
+ TFileRouteTypes,
+ TSSR
>
{
/**
@@ -429,12 +468,14 @@ export class RootRoute<
*/
constructor(
options?: RootRouteOptions<
+ TRegister,
TSearchValidator,
TRouterContext,
TRouteContextFn,
TBeforeLoadFn,
TLoaderDeps,
- TLoaderFn
+ TLoaderFn,
+ TSSR
>,
) {
super(options)
@@ -495,22 +536,27 @@ export class RootRoute<
}
export function createRootRoute<
+ TRegister extends Register = Register,
TSearchValidator = undefined,
TRouterContext = {},
TRouteContextFn = AnyContext,
TBeforeLoadFn = AnyContext,
TLoaderDeps extends Record = {},
TLoaderFn = undefined,
+ TSSR = unknown,
>(
options?: RootRouteOptions<
+ TRegister,
TSearchValidator,
TRouterContext,
TRouteContextFn,
TBeforeLoadFn,
TLoaderDeps,
- TLoaderFn
+ TLoaderFn,
+ TSSR
>,
): RootRoute<
+ TRegister,
TSearchValidator,
TRouterContext,
TRouteContextFn,
@@ -518,15 +564,20 @@ export function createRootRoute<
TLoaderDeps,
TLoaderFn,
unknown,
- unknown
+ unknown,
+ TSSR
> {
return new RootRoute<
+ TRegister,
TSearchValidator,
TRouterContext,
TRouteContextFn,
TBeforeLoadFn,
TLoaderDeps,
- TLoaderFn
+ TLoaderFn,
+ unknown,
+ unknown,
+ TSSR
>(options)
}
@@ -560,6 +611,7 @@ export type ErrorRouteComponent = AsyncRouteComponent
export type NotFoundRouteComponent = RouteTypes['component']
export class NotFoundRoute<
+ TRegister extends Register,
TParentRoute extends AnyRootRoute,
TRouterContext = AnyContext,
TRouteContextFn = AnyContext,
@@ -568,7 +620,9 @@ export class NotFoundRoute<
TLoaderDeps extends Record = {},
TLoaderFn = undefined,
TChildren = unknown,
+ TSSR = unknown,
> extends Route<
+ TRegister,
TParentRoute,
'/404',
'/404',
@@ -581,11 +635,13 @@ export class NotFoundRoute<
TBeforeLoadFn,
TLoaderDeps,
TLoaderFn,
- TChildren
+ TChildren,
+ TSSR
> {
constructor(
options: Omit<
RouteOptions<
+ TRegister,
TParentRoute,
string,
string,
@@ -597,7 +653,8 @@ export class NotFoundRoute<
TLoaderFn,
TRouterContext,
TRouteContextFn,
- TBeforeLoadFn
+ TBeforeLoadFn,
+ TSSR
>,
| 'caseSensitive'
| 'parseParams'
diff --git a/packages/react-router/src/scroll-restoration.tsx b/packages/react-router/src/scroll-restoration.tsx
index 1a8bdd9f7a..3527a2db37 100644
--- a/packages/react-router/src/scroll-restoration.tsx
+++ b/packages/react-router/src/scroll-restoration.tsx
@@ -8,6 +8,17 @@ import { ScriptOnce } from './ScriptOnce'
export function ScrollRestoration() {
const router = useRouter()
+ if (!router.isScrollRestoring || !router.isServer) {
+ return null
+ }
+ if (typeof router.options.scrollRestoration === 'function') {
+ const shouldRestore = router.options.scrollRestoration({
+ location: router.latestLocation,
+ })
+ if (!shouldRestore) {
+ return null
+ }
+ }
const getKey =
router.options.getScrollRestorationKey || defaultGetScrollRestorationKey
const userKey = getKey(router.latestLocation)
@@ -16,10 +27,6 @@ export function ScrollRestoration() {
? userKey
: undefined
- if (!router.isScrollRestoring || !router.isServer) {
- return null
- }
-
const restoreScrollOptions: Parameters[0] = {
storageKey,
shouldScrollRestoration: true,
diff --git a/packages/react-start-client/src/serializer.ts b/packages/react-router/src/ssr/serializer.ts
similarity index 72%
rename from packages/react-start-client/src/serializer.ts
rename to packages/react-router/src/ssr/serializer.ts
index 4ae5650859..9a1743c18a 100644
--- a/packages/react-start-client/src/serializer.ts
+++ b/packages/react-router/src/ssr/serializer.ts
@@ -1,6 +1,6 @@
import type * as React from 'react'
-declare module '@tanstack/start-client-core' {
+declare module '@tanstack/router-core' {
export interface SerializerExtensions {
ReadableStream: React.JSX.Element
}
diff --git a/packages/react-router/src/useActiveLocation.ts b/packages/react-router/src/useActiveLocation.ts
new file mode 100644
index 0000000000..c7220fdaca
--- /dev/null
+++ b/packages/react-router/src/useActiveLocation.ts
@@ -0,0 +1,57 @@
+import { last } from '@tanstack/router-core'
+import { useCallback, useEffect, useState } from 'react'
+import { useRouter } from './useRouter'
+import { useMatch } from './useMatch'
+import { useRouterState } from './useRouterState'
+import type { ParsedLocation } from '@tanstack/router-core'
+
+export type UseActiveLocationResult = {
+ activeLocation: ParsedLocation
+ getFromPath: (from?: string) => string
+ setActiveLocation: (location?: ParsedLocation) => void
+}
+
+export const useActiveLocation = (
+ location?: ParsedLocation,
+): UseActiveLocationResult => {
+ const router = useRouter()
+ const routerLocation = useRouterState({ select: (state) => state.location })
+ const [activeLocation, setActiveLocation] = useState(
+ location ?? routerLocation,
+ )
+ const [customActiveLocation, setCustomActiveLocation] = useState<
+ ParsedLocation | undefined
+ >(location)
+
+ useEffect(() => {
+ setActiveLocation(customActiveLocation ?? routerLocation)
+ }, [routerLocation, customActiveLocation])
+
+ const matchIndex = useMatch({
+ strict: false,
+ select: (match) => match.index,
+ })
+
+ const getFromPath = useCallback(
+ (from?: string) => {
+ const activeLocationMatches = router.matchRoutes(activeLocation, {
+ _buildLocation: false,
+ })
+
+ const activeLocationMatch = last(activeLocationMatches)
+
+ return (
+ from ??
+ activeLocationMatch?.fullPath ??
+ router.state.matches[matchIndex]!.fullPath
+ )
+ },
+ [activeLocation, matchIndex, router],
+ )
+
+ return {
+ activeLocation,
+ getFromPath,
+ setActiveLocation: setCustomActiveLocation,
+ }
+}
diff --git a/packages/react-router/src/useNavigate.tsx b/packages/react-router/src/useNavigate.tsx
index 1fcef97967..c12cffb9c9 100644
--- a/packages/react-router/src/useNavigate.tsx
+++ b/packages/react-router/src/useNavigate.tsx
@@ -1,6 +1,6 @@
import * as React from 'react'
import { useRouter } from './useRouter'
-import { useMatch } from './useMatch'
+import { useActiveLocation } from './useActiveLocation'
import type {
AnyRouter,
FromPathOption,
@@ -15,29 +15,21 @@ export function useNavigate<
>(_defaultOpts?: {
from?: FromPathOption
}): UseNavigateResult {
- const { navigate, state } = useRouter()
+ const router = useRouter()
- // Just get the index of the current match to avoid rerenders
- // as much as possible
- const matchIndex = useMatch({
- strict: false,
- select: (match) => match.index,
- })
+ const { getFromPath, activeLocation } = useActiveLocation()
return React.useCallback(
(options: NavigateOptions) => {
- const from =
- options.from ??
- _defaultOpts?.from ??
- state.matches[matchIndex]!.fullPath
+ const from = getFromPath(options.from ?? _defaultOpts?.from)
- return navigate({
+ return router.navigate({
...options,
from,
})
},
// eslint-disable-next-line react-hooks/exhaustive-deps
- [_defaultOpts?.from, navigate],
+ [_defaultOpts?.from, router, getFromPath, activeLocation],
) as UseNavigateResult
}
diff --git a/packages/react-router/tests/link.test.tsx b/packages/react-router/tests/link.test.tsx
index 80578b6f4a..570f66d334 100644
--- a/packages/react-router/tests/link.test.tsx
+++ b/packages/react-router/tests/link.test.tsx
@@ -24,6 +24,7 @@ import {
createRoute,
createRouteMask,
createRouter,
+ getRouteApi,
redirect,
retainSearchParams,
stripSearchParams,
@@ -4374,6 +4375,7 @@ describe('Link', () => {
})
const postRoute = createRoute({
+ ssr: false,
getParentRoute: () => rootRoute,
path: '/posts',
loader: () => sleep(WAIT_TIME),
@@ -5073,7 +5075,9 @@ describe.each([{ basepath: '' }, { basepath: '/basepath' }])(
return (
<>
Param Route
- Link to ./a
+
+ Link to ./a
+
Link to c
@@ -5093,7 +5097,12 @@ describe.each([{ basepath: '' }, { basepath: '/basepath' }])(
return (
<>
Param A Route
- Link to .. from /param/foo/a
+
+ Link to .. from /param/foo/a
+
+
+ Link to .. from current active route
+
>
)
@@ -5280,6 +5289,27 @@ describe.each([{ basepath: '' }, { basepath: '/basepath' }])(
expect(window.location.pathname).toBe(`${basepath}/param/foo`)
})
+ test('should navigate to a parent link based on active location', async () => {
+ const router = setupRouter()
+
+ render( )
+
+ await act(async () => {
+ history.push(`${basepath}/param/foo/a/b`)
+ })
+
+ const relativeLink = await screen.findByTestId('link-to-previous')
+
+ expect(relativeLink.getAttribute('href')).toBe(`${basepath}/param/foo/a`)
+
+ // Click the link and ensure the new location
+ await act(async () => {
+ fireEvent.click(relativeLink)
+ })
+
+ expect(window.location.pathname).toBe(`${basepath}/param/foo/a`)
+ })
+
test('should navigate to a child link based on pathname', async () => {
const router = setupRouter()
@@ -5407,3 +5437,712 @@ describe.each([{ basepath: '' }, { basepath: '/basepath' }])(
})
},
)
+
+describe('relative links to current route', () => {
+ test.each([true, false])(
+ 'should navigate to current route when using "." in nested route structure from Index Route with trailingSlash: %s',
+ async (trailingSlash: boolean) => {
+ const tail = trailingSlash ? '/' : ''
+
+ const rootRoute = createRootRoute()
+
+ const IndexComponent = () => {
+ return (
+ <>
+
+ Post
+
+
+ Search
+
+
+ Search2
+
+
+ >
+ )
+ }
+
+ const indexRoute = createRoute({
+ getParentRoute: () => rootRoute,
+ path: '/',
+ component: IndexComponent,
+ validateSearch: z.object({
+ param1: z.string().optional(),
+ }),
+ })
+
+ const postRoute = createRoute({
+ getParentRoute: () => indexRoute,
+ path: 'post',
+ component: () => (
+ <>
+ Post
+ >
+ ),
+ })
+
+ const router = createRouter({
+ routeTree: rootRoute.addChildren([indexRoute, postRoute]),
+ history,
+ trailingSlash: trailingSlash ? 'always' : 'never',
+ })
+
+ render( )
+
+ const postButton = await screen.findByTestId('posts-link')
+ const searchButton = await screen.findByTestId('search-link')
+ const searchButton2 = await screen.findByTestId('search2-link')
+
+ await act(() => fireEvent.click(postButton))
+
+ expect(window.location.pathname).toBe(`/post${tail}`)
+
+ await act(() => fireEvent.click(searchButton))
+
+ expect(router.state.location.pathname).toBe(`/post${tail}`)
+ expect(router.state.location.search).toEqual({ param1: 'value1' })
+
+ await act(() => fireEvent.click(searchButton2))
+
+ expect(router.state.location.pathname).toBe(`/post${tail}`)
+ expect(router.state.location.search).toEqual({ param1: 'value2' })
+ },
+ )
+
+ test.each([true, false])(
+ 'should navigate to current route with search params when using "." in nested route structure from Index Route with trailingSlash: %s',
+ async (trailingSlash: boolean) => {
+ const tail = trailingSlash ? '/' : ''
+
+ const rootRoute = createRootRoute()
+
+ const IndexComponent = () => {
+ return (
+ <>
+
+ Post
+
+
+ Search
+
+
+ Search2
+
+
+ >
+ )
+ }
+
+ const indexRoute = createRoute({
+ getParentRoute: () => rootRoute,
+ path: '/',
+ component: IndexComponent,
+ validateSearch: z.object({
+ param1: z.string().optional(),
+ }),
+ })
+
+ const postRoute = createRoute({
+ getParentRoute: () => indexRoute,
+ path: 'post',
+ component: () => Post
,
+ })
+
+ const router = createRouter({
+ routeTree: rootRoute.addChildren([indexRoute, postRoute]),
+ history,
+ trailingSlash: trailingSlash ? 'always' : 'never',
+ })
+
+ render( )
+
+ const postButton = await screen.findByTestId('posts-link')
+
+ await act(() => fireEvent.click(postButton))
+
+ expect(window.location.pathname).toBe(`/post${tail}`)
+
+ const searchButton = await screen.findByTestId('search-link')
+
+ await act(() => fireEvent.click(searchButton))
+
+ expect(router.state.location.pathname).toBe(`/post${tail}`)
+ expect(router.state.location.search).toEqual({ param1: 'value1' })
+
+ const searchButton2 = await screen.findByTestId('search2-link')
+
+ await act(() => fireEvent.click(searchButton2))
+
+ expect(router.state.location.pathname).toBe(`/post${tail}`)
+ expect(router.state.location.search).toEqual({ param1: 'value2' })
+ },
+ )
+
+ test.each([true, false])(
+ 'should navigate to current route with changing path params when using "." in nested route structure with trailingSlash: %s',
+ async (trailingSlash) => {
+ const tail = trailingSlash ? '/' : ''
+ const rootRoute = createRootRoute()
+
+ const IndexComponent = () => {
+ return (
+ <>
+ Index
+
+ Posts
+
+ >
+ )
+ }
+
+ const indexRoute = createRoute({
+ getParentRoute: () => rootRoute,
+ path: '/',
+ component: IndexComponent,
+ })
+
+ const layoutRoute = createRoute({
+ getParentRoute: () => rootRoute,
+ id: '_layout',
+ component: () => {
+ return (
+ <>
+ Layout
+
+ >
+ )
+ },
+ })
+
+ const PostsComponent = () => {
+ return (
+ <>
+ Posts
+
+ To first post
+
+
+ To second post
+
+
+ >
+ )
+ }
+
+ const postsRoute = createRoute({
+ getParentRoute: () => layoutRoute,
+ path: 'posts',
+ component: PostsComponent,
+ })
+
+ const PostComponent = () => {
+ const params = useParams({ strict: false })
+ return (
+ <>
+
+ Params: {params.postId}
+
+ >
+ )
+ }
+
+ const postRoute = createRoute({
+ getParentRoute: () => postsRoute,
+ path: '$postId',
+ component: PostComponent,
+ })
+
+ const router = createRouter({
+ routeTree: rootRoute.addChildren([
+ indexRoute,
+ layoutRoute.addChildren([postsRoute.addChildren([postRoute])]),
+ ]),
+ trailingSlash: trailingSlash ? 'always' : 'never',
+ })
+
+ render( )
+
+ const postsButton = await screen.findByTestId('posts-link')
+
+ await act(() => fireEvent.click(postsButton))
+
+ expect(
+ await screen.findByTestId('posts-index-heading'),
+ ).toBeInTheDocument()
+ expect(window.location.pathname).toEqual(`/posts${tail}`)
+
+ const firstPostButton = await screen.findByTestId('first-post-link')
+
+ await act(() => fireEvent.click(firstPostButton))
+
+ expect(await screen.findByTestId('post-id1')).toBeInTheDocument()
+ expect(window.location.pathname).toEqual(`/posts/id1${tail}`)
+
+ const secondPostButton = await screen.findByTestId('second-post-link')
+
+ await act(() => fireEvent.click(secondPostButton))
+
+ expect(await screen.findByTestId('post-id2')).toBeInTheDocument()
+ expect(window.location.pathname).toEqual(`/posts/id2${tail}`)
+ },
+ )
+})
+
+describe('relative links to from route', () => {
+ test.each([true, false])(
+ 'should navigate to from route when using "." in nested route structure from Index Route with trailingSlash: %s',
+ async (trailingSlash: boolean) => {
+ const tail = trailingSlash ? '/' : ''
+
+ const rootRoute = createRootRoute()
+
+ const IndexComponent = () => {
+ return (
+ <>
+
+ Post
+
+
+ Search
+
+
+ Go To Home
+
+
+ >
+ )
+ }
+
+ const indexRoute = createRoute({
+ getParentRoute: () => rootRoute,
+ path: '/',
+ component: IndexComponent,
+ validateSearch: z.object({
+ param1: z.string().optional(),
+ }),
+ })
+
+ const postRoute = createRoute({
+ getParentRoute: () => indexRoute,
+ path: 'post',
+ component: () => Post
,
+ })
+
+ const router = createRouter({
+ routeTree: rootRoute.addChildren([indexRoute, postRoute]),
+ history,
+ trailingSlash: trailingSlash ? 'always' : 'never',
+ })
+
+ render( )
+
+ const postButton = await screen.findByTestId('posts-link')
+
+ await act(() => fireEvent.click(postButton))
+
+ expect(router.state.location.pathname).toBe(`/post${tail}`)
+
+ const searchButton = await screen.findByTestId('search-link')
+
+ await act(() => fireEvent.click(searchButton))
+
+ expect(router.state.location.pathname).toBe(`/post${tail}`)
+ expect(router.state.location.search).toEqual({ param1: 'value1' })
+
+ const homeBtn = await screen.findByTestId('home-link')
+
+ await act(() => fireEvent.click(homeBtn))
+
+ expect(router.state.location.pathname).toBe(`/`)
+ expect(router.state.location.search).toEqual({})
+ },
+ )
+
+ test.each([true, false])(
+ 'should navigate to from route with path params when using "." in nested route structure with trailingSlash: %s',
+ async (trailingSlash) => {
+ const tail = trailingSlash ? '/' : ''
+ const rootRoute = createRootRoute()
+
+ const IndexComponent = () => {
+ return (
+ <>
+ Index
+
+ Posts
+
+ >
+ )
+ }
+
+ const indexRoute = createRoute({
+ getParentRoute: () => rootRoute,
+ path: '/',
+ component: IndexComponent,
+ })
+
+ const layoutRoute = createRoute({
+ getParentRoute: () => rootRoute,
+ id: '_layout',
+ component: () => {
+ return (
+ <>
+ Layout
+
+ >
+ )
+ },
+ })
+
+ const PostsComponent = () => {
+ return (
+ <>
+ Posts
+
+ To first post
+
+
+ To second post
+
+
+ To posts list
+
+
+ >
+ )
+ }
+
+ const PostDetailComponent = () => {
+ return (
+ <>
+ Post Detail
+
+ To post info
+
+
+ To post notes
+
+
+ To index detail options
+
+
+ >
+ )
+ }
+
+ const PostInfoComponent = () => {
+ return (
+ <>
+ Post Info
+ >
+ )
+ }
+
+ const PostNotesComponent = () => {
+ return (
+ <>
+ Post Notes
+ >
+ )
+ }
+
+ const postsRoute = createRoute({
+ getParentRoute: () => layoutRoute,
+ path: 'posts',
+ component: PostsComponent,
+ })
+
+ const postDetailRoute = createRoute({
+ getParentRoute: () => postsRoute,
+ path: '$postId',
+ component: PostDetailComponent,
+ })
+
+ const postInfoRoute = createRoute({
+ getParentRoute: () => postDetailRoute,
+ path: 'info',
+ component: PostInfoComponent,
+ })
+
+ const postNotesRoute = createRoute({
+ getParentRoute: () => postDetailRoute,
+ path: 'notes',
+ component: PostNotesComponent,
+ })
+
+ const router = createRouter({
+ routeTree: rootRoute.addChildren([
+ indexRoute,
+ layoutRoute.addChildren([
+ postsRoute.addChildren([
+ postDetailRoute.addChildren([postInfoRoute, postNotesRoute]),
+ ]),
+ ]),
+ ]),
+ trailingSlash: trailingSlash ? 'always' : 'never',
+ })
+
+ render( )
+
+ const postsButton = await screen.findByTestId('posts-link')
+
+ fireEvent.click(postsButton)
+
+ expect(
+ await screen.findByTestId('posts-index-heading'),
+ ).toBeInTheDocument()
+ expect(window.location.pathname).toEqual(`/posts${tail}`)
+
+ const firstPostButton = await screen.findByTestId('first-post-link')
+
+ fireEvent.click(firstPostButton)
+
+ expect(
+ await screen.findByTestId('post-detail-index-heading'),
+ ).toBeInTheDocument()
+ expect(window.location.pathname).toEqual(`/posts/1${tail}`)
+
+ const postInfoButton = await screen.findByTestId('post-info-link')
+
+ fireEvent.click(postInfoButton)
+
+ expect(await screen.findByTestId('post-info-heading')).toBeInTheDocument()
+ expect(window.location.pathname).toEqual(`/posts/1/info${tail}`)
+
+ const toPostDetailIndexButton = await screen.findByTestId(
+ 'to-post-detail-index-link',
+ )
+
+ fireEvent.click(toPostDetailIndexButton)
+
+ expect(
+ await screen.findByTestId('post-detail-index-heading'),
+ ).toBeInTheDocument()
+ expect(screen.queryByTestId('post-info-heading')).not.toBeInTheDocument()
+ expect(window.location.pathname).toEqual(`/posts/1${tail}`)
+
+ const postNotesButton = await screen.findByTestId('post-notes-link')
+
+ fireEvent.click(postNotesButton)
+
+ expect(
+ await screen.findByTestId('post-notes-heading'),
+ ).toBeInTheDocument()
+ expect(window.location.pathname).toEqual(`/posts/1/notes${tail}`)
+
+ const toPostsIndexButton = await screen.findByTestId(
+ 'to-posts-index-link',
+ )
+
+ fireEvent.click(toPostsIndexButton)
+
+ expect(
+ await screen.findByTestId('posts-index-heading'),
+ ).toBeInTheDocument()
+ expect(screen.queryByTestId('post-notes-heading')).not.toBeInTheDocument()
+ expect(
+ screen.queryByTestId('post-detail-index-heading'),
+ ).not.toBeInTheDocument()
+ expect(window.location.pathname).toEqual(`/posts${tail}`)
+
+ const secondPostButton = await screen.findByTestId('second-post-link')
+
+ fireEvent.click(secondPostButton)
+
+ expect(
+ await screen.findByTestId('post-detail-index-heading'),
+ ).toBeInTheDocument()
+ expect(window.location.pathname).toEqual(`/posts/2${tail}`)
+ },
+ )
+})
+
+describe('when on /posts/$postId and navigating to ../ with default `from` /posts', () => {
+ async function runTest(navigateVia: 'Route' | 'RouteApi') {
+ const rootRoute = createRootRoute()
+
+ const IndexComponent = () => {
+ return (
+ <>
+ Index
+
+ Posts
+
+
+ To first post
+
+ >
+ )
+ }
+
+ const indexRoute = createRoute({
+ getParentRoute: () => rootRoute,
+ path: '/',
+ component: IndexComponent,
+ })
+
+ const layoutRoute = createRoute({
+ getParentRoute: () => rootRoute,
+ id: '_layout',
+ component: () => {
+ return (
+ <>
+ Layout
+
+ >
+ )
+ },
+ })
+
+ const PostsComponent = () => {
+ const LinkViaRoute = () => (
+
+ To Home
+
+ )
+
+ const LinkViaRouteApi = () => {
+ const RouteApiLink = getRouteApi('/_layout/posts').Link
+ return (
+
+ To Home
+
+ )
+ }
+
+ return (
+ <>
+ Posts
+ {navigateVia === 'Route' ? : }
+
+ >
+ )
+ }
+
+ const postsRoute = createRoute({
+ getParentRoute: () => layoutRoute,
+ path: 'posts',
+ component: PostsComponent,
+ })
+
+ const PostComponent = () => {
+ const params = useParams({ strict: false })
+ return (
+ <>
+ Params: {params.postId}
+
+ >
+ )
+ }
+
+ const postRoute = createRoute({
+ getParentRoute: () => postsRoute,
+ path: '$postId',
+ component: PostComponent,
+ })
+
+ const PostIndexComponent = () => {
+ return (
+ <>
+ Post Index
+ >
+ )
+ }
+
+ const postIndexRoute = createRoute({
+ getParentRoute: () => postRoute,
+ path: '/',
+ component: PostIndexComponent,
+ })
+
+ const DetailsComponent = () => {
+ return (
+ <>
+ Details!
+ >
+ )
+ }
+
+ const detailsRoute = createRoute({
+ getParentRoute: () => postRoute,
+ path: 'details',
+ component: DetailsComponent,
+ })
+
+ const router = createRouter({
+ routeTree: rootRoute.addChildren([
+ indexRoute,
+ layoutRoute.addChildren([
+ postsRoute.addChildren([
+ postRoute.addChildren([postIndexRoute, detailsRoute]),
+ ]),
+ ]),
+ ]),
+ })
+
+ render( )
+
+ const postsButton = await screen.findByTestId('index-to-first-post-link')
+
+ fireEvent.click(postsButton)
+
+ expect(await screen.findByTestId('details-heading')).toBeInTheDocument()
+
+ expect(window.location.pathname).toEqual('/posts/id1/details')
+
+ const homeButton = await screen.findByTestId('link-to-home')
+
+ fireEvent.click(homeButton)
+
+ expect(await screen.findByTestId('index-heading')).toBeInTheDocument()
+ expect(window.location.pathname).toEqual('/')
+ }
+
+ test('Route', () => runTest('Route'))
+ test('RouteApi', () => runTest('RouteApi'))
+})
diff --git a/packages/react-router/tests/routeContext.test.tsx b/packages/react-router/tests/routeContext.test.tsx
index 7a38a272d9..eef424c867 100644
--- a/packages/react-router/tests/routeContext.test.tsx
+++ b/packages/react-router/tests/routeContext.test.tsx
@@ -1602,6 +1602,7 @@ describe('loader in the route definition', () => {
path: '/',
})
const aboutRoute = createRoute({
+ ssr: false,
getParentRoute: () => rootRoute,
path: '/about',
beforeLoad: async () => {
@@ -1652,7 +1653,9 @@ describe('loader in the route definition', () => {
)
},
})
+
const aboutRoute = createRoute({
+ ssr: false,
getParentRoute: () => rootRoute,
path: '/about',
beforeLoad: async () => {
diff --git a/packages/react-router/tests/router.test.tsx b/packages/react-router/tests/router.test.tsx
index 594a271eaa..3ba3249ec7 100644
--- a/packages/react-router/tests/router.test.tsx
+++ b/packages/react-router/tests/router.test.tsx
@@ -59,7 +59,7 @@ export function validateSearchParams<
}
function createTestRouter(
- options: RouterOptions &
+ options: RouterOptions &
Required, 'history'>>,
) {
const rootRoute = createRootRoute({
diff --git a/packages/react-router/tests/useNavigate.test.tsx b/packages/react-router/tests/useNavigate.test.tsx
index 8d98abdf28..fa731c0b16 100644
--- a/packages/react-router/tests/useNavigate.test.tsx
+++ b/packages/react-router/tests/useNavigate.test.tsx
@@ -1504,7 +1504,8 @@ test.each([true, false])(
})
const PostsComponent = () => {
- const navigate = postsRoute.useNavigate()
+ const navigate = useNavigate()
+
return (
<>
Posts
@@ -1619,7 +1620,7 @@ test.each([true, false])(
})
const PostsComponent = () => {
- const navigate = postsRoute.useNavigate()
+ const navigate = useNavigate()
return (
<>
Posts
@@ -1776,6 +1777,343 @@ test.each([true, false])(
},
)
+test.each([true, false])(
+ 'should navigate to from route when using "." in nested route structure from Index Route with trailingSlash: %s',
+ async (trailingSlash: boolean) => {
+ const tail = trailingSlash ? '/' : ''
+
+ const rootRoute = createRootRoute()
+
+ const IndexComponent = () => {
+ const navigate = useNavigate()
+ return (
+ <>
+ {
+ navigate({
+ to: '/post',
+ })
+ }}
+ >
+ Post
+
+
+ navigate({
+ to: '.',
+ search: {
+ param1: 'value1',
+ },
+ })
+ }
+ >
+ Search
+
+
+ navigate({
+ from: '/',
+ to: '.',
+ })
+ }
+ >
+ Go To Home
+
+
+ >
+ )
+ }
+
+ const indexRoute = createRoute({
+ getParentRoute: () => rootRoute,
+ path: '/',
+ component: IndexComponent,
+ validateSearch: z.object({
+ param1: z.string().optional(),
+ }),
+ })
+
+ const postRoute = createRoute({
+ getParentRoute: () => indexRoute,
+ path: 'post',
+ component: () => Post
,
+ })
+
+ const router = createRouter({
+ routeTree: rootRoute.addChildren([indexRoute, postRoute]),
+ history,
+ trailingSlash: trailingSlash ? 'always' : 'never',
+ })
+
+ render( )
+
+ const postButton = await screen.findByTestId('posts-btn')
+
+ await act(() => fireEvent.click(postButton))
+
+ expect(router.state.location.pathname).toBe(`/post${tail}`)
+
+ const searchButton = await screen.findByTestId('search-btn')
+
+ await act(() => fireEvent.click(searchButton))
+
+ expect(router.state.location.pathname).toBe(`/post${tail}`)
+ expect(router.state.location.search).toEqual({ param1: 'value1' })
+
+ const homeBtn = await screen.findByTestId('home-btn')
+
+ await act(() => fireEvent.click(homeBtn))
+
+ expect(router.state.location.pathname).toBe(`/`)
+ expect(router.state.location.search).toEqual({})
+ },
+)
+
+test.each([true, false])(
+ 'should navigate to from route with path params when using "." in nested route structure with trailingSlash: %s',
+ async (trailingSlash) => {
+ const tail = trailingSlash ? '/' : ''
+ const rootRoute = createRootRoute()
+
+ const IndexComponent = () => {
+ const navigate = useNavigate()
+ return (
+ <>
+ Index
+ navigate({ to: '/posts' })}
+ >
+ Posts
+
+ >
+ )
+ }
+
+ const indexRoute = createRoute({
+ getParentRoute: () => rootRoute,
+ path: '/',
+ component: IndexComponent,
+ })
+
+ const layoutRoute = createRoute({
+ getParentRoute: () => rootRoute,
+ id: '_layout',
+ component: () => {
+ return (
+ <>
+ Layout
+
+ >
+ )
+ },
+ })
+
+ const PostsComponent = () => {
+ const navigate = postsRoute.useNavigate()
+ return (
+ <>
+ Posts
+
+ navigate({
+ to: '$postId',
+ params: { postId: '1' },
+ })
+ }
+ >
+ To first post
+
+
+ navigate({
+ to: '$postId',
+ params: { postId: '2' },
+ })
+ }
+ >
+ To second post
+
+
+ navigate({
+ from: '/posts',
+ to: '.',
+ })
+ }
+ >
+ To posts list
+
+
+ >
+ )
+ }
+
+ const PostDetailComponent = () => {
+ const navigate = postDetailRoute.useNavigate()
+ return (
+ <>
+ Post Detail
+
+ navigate({
+ to: 'info',
+ })
+ }
+ >
+ To post info
+
+
+ navigate({
+ to: 'notes',
+ })
+ }
+ >
+ To post notes
+
+
+ navigate({
+ from: '/posts/$postId',
+ to: '.',
+ })
+ }
+ >
+ To index detail options
+
+
+ >
+ )
+ }
+
+ const PostInfoComponent = () => {
+ return (
+ <>
+ Post Info
+ >
+ )
+ }
+
+ const PostNotesComponent = () => {
+ return (
+ <>
+ Post Notes
+ >
+ )
+ }
+
+ const postsRoute = createRoute({
+ getParentRoute: () => layoutRoute,
+ path: 'posts',
+ component: PostsComponent,
+ })
+
+ const postDetailRoute = createRoute({
+ getParentRoute: () => postsRoute,
+ path: '$postId',
+ component: PostDetailComponent,
+ })
+
+ const postInfoRoute = createRoute({
+ getParentRoute: () => postDetailRoute,
+ path: 'info',
+ component: PostInfoComponent,
+ })
+
+ const postNotesRoute = createRoute({
+ getParentRoute: () => postDetailRoute,
+ path: 'notes',
+ component: PostNotesComponent,
+ })
+
+ const router = createRouter({
+ routeTree: rootRoute.addChildren([
+ indexRoute,
+ layoutRoute.addChildren([
+ postsRoute.addChildren([
+ postDetailRoute.addChildren([postInfoRoute, postNotesRoute]),
+ ]),
+ ]),
+ ]),
+ trailingSlash: trailingSlash ? 'always' : 'never',
+ })
+
+ render( )
+
+ const postsButton = await screen.findByTestId('posts-btn')
+
+ fireEvent.click(postsButton)
+
+ expect(await screen.findByTestId('posts-index-heading')).toBeInTheDocument()
+ expect(window.location.pathname).toEqual(`/posts${tail}`)
+
+ const firstPostButton = await screen.findByTestId('first-post-btn')
+
+ fireEvent.click(firstPostButton)
+
+ expect(
+ await screen.findByTestId('post-detail-index-heading'),
+ ).toBeInTheDocument()
+ expect(window.location.pathname).toEqual(`/posts/1${tail}`)
+
+ const postInfoButton = await screen.findByTestId('post-info-btn')
+
+ fireEvent.click(postInfoButton)
+
+ expect(await screen.findByTestId('post-info-heading')).toBeInTheDocument()
+ expect(window.location.pathname).toEqual(`/posts/1/info${tail}`)
+
+ const toPostDetailIndexButton = await screen.findByTestId(
+ 'to-post-detail-index-btn',
+ )
+
+ fireEvent.click(toPostDetailIndexButton)
+
+ expect(
+ await screen.findByTestId('post-detail-index-heading'),
+ ).toBeInTheDocument()
+ expect(screen.queryByTestId('post-info-heading')).not.toBeInTheDocument()
+ expect(window.location.pathname).toEqual(`/posts/1${tail}`)
+
+ const postNotesButton = await screen.findByTestId('post-notes-btn')
+
+ fireEvent.click(postNotesButton)
+
+ expect(await screen.findByTestId('post-notes-heading')).toBeInTheDocument()
+ expect(window.location.pathname).toEqual(`/posts/1/notes${tail}`)
+
+ const toPostsIndexButton = await screen.findByTestId('to-posts-index-btn')
+
+ fireEvent.click(toPostsIndexButton)
+
+ expect(await screen.findByTestId('posts-index-heading')).toBeInTheDocument()
+ expect(screen.queryByTestId('post-notes-heading')).not.toBeInTheDocument()
+ expect(
+ screen.queryByTestId('post-detail-index-heading'),
+ ).not.toBeInTheDocument()
+ expect(window.location.pathname).toEqual(`/posts${tail}`)
+
+ const secondPostButton = await screen.findByTestId('second-post-btn')
+
+ fireEvent.click(secondPostButton)
+
+ expect(
+ await screen.findByTestId('post-detail-index-heading'),
+ ).toBeInTheDocument()
+ expect(window.location.pathname).toEqual(`/posts/2${tail}`)
+ },
+)
+
describe('when on /posts/$postId and navigating to ../ with default `from` /posts', () => {
async function runTest(navigateVia: 'Route' | 'RouteApi') {
const rootRoute = createRootRoute()
@@ -1975,7 +2313,11 @@ describe.each([{ basepath: '' }, { basepath: '/basepath' }])(
return (
<>
Param Route
- navigate({ to: './a' })}>
+
+ navigate({ from: paramRoute.fullPath, to: './a' })
+ }
+ >
Link to ./a
Param A Route
- navigate({ to: '..' })}>
+
+ navigate({ from: paramARoute.fullPath, to: '..' })
+ }
+ >
Link to .. from /param/foo/a
+ navigate({ to: '..' })}
+ data-testid={'link-to-previous'}
+ >
+ Link to .. from current active route
+
>
)
@@ -2150,6 +2502,25 @@ describe.each([{ basepath: '' }, { basepath: '/basepath' }])(
expect(window.location.pathname).toBe(`${basepath}/param/foo`)
})
+ test('should navigate to a parent link based on active location', async () => {
+ const router = setupRouter()
+
+ render( )
+
+ await act(async () => {
+ history.push(`${basepath}/param/foo/a/b`)
+ })
+
+ const relativeLink = await screen.findByTestId('link-to-previous')
+
+ // Click the link and ensure the new location
+ await act(async () => {
+ fireEvent.click(relativeLink)
+ })
+
+ expect(window.location.pathname).toBe(`${basepath}/param/foo/a`)
+ })
+
test('should navigate to same route with different params', async () => {
const router = setupRouter()
diff --git a/packages/react-start-client/package.json b/packages/react-start-client/package.json
index d7c1709c2d..54f9bbfabd 100644
--- a/packages/react-start-client/package.json
+++ b/packages/react-start-client/package.json
@@ -1,6 +1,6 @@
{
"name": "@tanstack/react-start-client",
- "version": "1.131.27",
+ "version": "1.132.0-alpha.11",
"description": "Modern and scalable routing for React applications",
"author": "Tanner Linsley",
"license": "MIT",
@@ -46,10 +46,6 @@
"import": {
"types": "./dist/esm/index.d.ts",
"default": "./dist/esm/index.js"
- },
- "require": {
- "types": "./dist/cjs/index.d.cts",
- "default": "./dist/cjs/index.cjs"
}
},
"./package.json": "./package.json"
@@ -60,7 +56,7 @@
"src"
],
"engines": {
- "node": ">=12"
+ "node": ">=22.12.0"
},
"dependencies": {
"@tanstack/react-router": "workspace:*",
diff --git a/packages/react-start-client/src/Meta.tsx b/packages/react-start-client/src/Meta.tsx
deleted file mode 100644
index 6a91ca59ef..0000000000
--- a/packages/react-start-client/src/Meta.tsx
+++ /dev/null
@@ -1,10 +0,0 @@
-import { HeadContent } from '@tanstack/react-router'
-
-export const Meta = () => {
- if (process.env.NODE_ENV === 'development') {
- console.warn(
- 'The Meta component is deprecated. Use `HeadContent` from `@tanstack/react-router` instead.',
- )
- }
- return
-}
diff --git a/packages/react-start-client/src/Scripts.tsx b/packages/react-start-client/src/Scripts.tsx
deleted file mode 100644
index 9db5f5c53e..0000000000
--- a/packages/react-start-client/src/Scripts.tsx
+++ /dev/null
@@ -1,8 +0,0 @@
-import { Scripts as RouterScripts } from '@tanstack/react-router'
-
-export const Scripts = () => {
- if (process.env.NODE_ENV === 'development') {
- console.warn('The Scripts component was moved to `@tanstack/react-router`')
- }
- return
-}
diff --git a/packages/react-start-client/src/index.tsx b/packages/react-start-client/src/index.tsx
index d728c17e0f..ac78eae4b4 100644
--- a/packages/react-start-client/src/index.tsx
+++ b/packages/react-start-client/src/index.tsx
@@ -1,14 +1,14 @@
export {
mergeHeaders,
- startSerializer,
createIsomorphicFn,
createServerFn,
createMiddleware,
registerGlobalMiddleware,
globalMiddleware,
- serverOnly,
- clientOnly,
+ createServerOnlyFn,
+ createClientOnlyFn,
json,
+ createClientRpc,
} from '@tanstack/start-client-core'
export {
type DehydratedRouter,
@@ -26,7 +26,6 @@ export {
type FetcherBaseOptions,
type ServerFn,
type ServerFnCtx,
- type ServerFnResponseType,
type JsonResponse,
type IntersectAllValidatorInputs,
type IntersectAllValidatorOutputs,
@@ -54,9 +53,6 @@ export {
type FunctionMiddlewareServerNextFn,
type FunctionServerResultWithContext,
} from '@tanstack/start-client-core'
-export { Meta } from './Meta'
-export { Scripts } from './Scripts'
export { StartClient } from './StartClient'
export { renderRsc } from './renderRSC'
export { useServerFn } from './useServerFn'
-export * from './serializer'
diff --git a/packages/react-start-client/src/tests/createServerFn.test-d.tsx b/packages/react-start-client/src/tests/createServerFn.test-d.tsx
index 7dbff3030d..e554271677 100644
--- a/packages/react-start-client/src/tests/createServerFn.test-d.tsx
+++ b/packages/react-start-client/src/tests/createServerFn.test-d.tsx
@@ -10,6 +10,8 @@ test('createServerFn returns RSC', () => {
}))
expectTypeOf(fn()).toEqualTypeOf<
- Promise<{ rscs: readonly [ReadableStream, ReadableStream] }>
+ Promise<{
+ rscs: readonly [ReadableStream, ReadableStream]
+ }>
>()
})
diff --git a/packages/react-start-client/vite.config.ts b/packages/react-start-client/vite.config.ts
index e1356092ad..da4238fe1e 100644
--- a/packages/react-start-client/vite.config.ts
+++ b/packages/react-start-client/vite.config.ts
@@ -20,5 +20,6 @@ export default mergeConfig(
tanstackViteConfig({
srcDir: './src',
entry: './src/index.tsx',
+ cjs: false,
}),
)
diff --git a/packages/react-start-plugin/README.md b/packages/react-start-plugin/README.md
deleted file mode 100644
index 45e57a4d5b..0000000000
--- a/packages/react-start-plugin/README.md
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-# TanStack React Start - Plugin
-
-This package is not meant to be used directly. It is a dependency of [`@tanstack/react-start`](https://www.npmjs.com/package/@tanstack/react-start).
-
-TanStack React Start is a fullstack-framework made for SSR, Streaming, Server Functions, API Routes, bundling and more powered by [TanStack Router](https://tanstack.com/router).
-
-Head over to [tanstack.com/start](https://tanstack.com/start) for more information about getting started.
diff --git a/packages/react-start-plugin/eslint.config.js b/packages/react-start-plugin/eslint.config.js
deleted file mode 100644
index 8ce6ad05fc..0000000000
--- a/packages/react-start-plugin/eslint.config.js
+++ /dev/null
@@ -1,5 +0,0 @@
-// @ts-check
-
-import rootConfig from '../../eslint.config.js'
-
-export default [...rootConfig]
diff --git a/packages/react-start-plugin/package.json b/packages/react-start-plugin/package.json
deleted file mode 100644
index bc068fc0a6..0000000000
--- a/packages/react-start-plugin/package.json
+++ /dev/null
@@ -1,75 +0,0 @@
-{
- "name": "@tanstack/react-start-plugin",
- "version": "1.131.27",
- "description": "Modern and scalable routing for React applications",
- "author": "Tanner Linsley",
- "license": "MIT",
- "repository": {
- "type": "git",
- "url": "https://github.com/TanStack/router.git",
- "directory": "packages/react-start-plugin"
- },
- "homepage": "https://tanstack.com/start",
- "funding": {
- "type": "github",
- "url": "https://github.com/sponsors/tannerlinsley"
- },
- "keywords": [
- "react",
- "location",
- "router",
- "routing",
- "async",
- "async router",
- "typescript"
- ],
- "scripts": {
- "clean": "rimraf ./dist && rimraf ./coverage",
- "clean:snapshots": "rimraf **/*snapshot* --glob",
- "test": "pnpm test:eslint && pnpm test:types && pnpm test:build && pnpm test:unit",
- "test:unit": "exit 0; vitest",
- "test:eslint": "eslint ./src",
- "test:types": "pnpm run \"/^test:types:ts[0-9]{2}$/\"",
- "test:types:ts54": "node ../../node_modules/typescript54/lib/tsc.js",
- "test:types:ts55": "node ../../node_modules/typescript55/lib/tsc.js",
- "test:types:ts56": "node ../../node_modules/typescript56/lib/tsc.js",
- "test:types:ts57": "node ../../node_modules/typescript57/lib/tsc.js",
- "test:types:ts58": "node ../../node_modules/typescript58/lib/tsc.js",
- "test:types:ts59": "tsc",
- "test:build": "publint --strict && attw --ignore-rules no-resolution --pack .",
- "build": "vite build"
- },
- "type": "module",
- "types": "dist/esm/index.d.ts",
- "module": "dist/esm/index.js",
- "exports": {
- ".": {
- "import": {
- "types": "./dist/esm/index.d.ts",
- "default": "./dist/esm/index.js"
- }
- },
- "./package.json": "./package.json"
- },
- "sideEffects": false,
- "files": [
- "dist",
- "src"
- ],
- "engines": {
- "node": ">=12"
- },
- "dependencies": {
- "@tanstack/start-plugin-core": "workspace:*",
- "pathe": "^2.0.3",
- "zod": "^3.24.2"
- },
- "devDependencies": {
- "@vitejs/plugin-react": "^4.3.4",
- "vite": "^6.0.0"
- },
- "peerDependencies": {
- "@vitejs/plugin-react": ">=4.3.4",
- "vite": ">=6.0.0"
- }
-}
diff --git a/packages/react-start-plugin/src/index.ts b/packages/react-start-plugin/src/index.ts
deleted file mode 100644
index 517f13edcb..0000000000
--- a/packages/react-start-plugin/src/index.ts
+++ /dev/null
@@ -1,136 +0,0 @@
-import { fileURLToPath } from 'node:url'
-import viteReact from '@vitejs/plugin-react'
-import { TanStackStartVitePluginCore } from '@tanstack/start-plugin-core'
-import path from 'pathe'
-import { getTanStackStartOptions } from './schema'
-import type { TanStackStartInputConfig, WithReactPlugin } from './schema'
-import type { PluginOption } from 'vite'
-
-export type {
- TanStackStartInputConfig,
- TanStackStartOutputConfig,
- WithReactPlugin,
-} from './schema'
-
-function hasRootExport(
- exportsField?: Record | string,
-): boolean {
- if (!exportsField) return false
-
- if (typeof exportsField === 'string') {
- // shorthand form: "exports": "./index.js"
- return true
- }
-
- if (typeof exportsField === 'object') {
- return '.' in exportsField
- }
-
- return false
-}
-
-export function TanStackStartVitePlugin(
- opts?: TanStackStartInputConfig & WithReactPlugin,
-): Array {
- type OptionsWithReact = ReturnType &
- WithReactPlugin
- const options: OptionsWithReact = getTanStackStartOptions(opts)
-
- if (opts?.customViteReactPlugin !== true) {
- console.warn(
- `please add the vite-react plugin to your Vite config and set 'customViteReactPlugin: true'`,
- )
- console.warn(
- `TanStack Start will not configure the vite-react plugin in future anymore.`,
- )
- }
-
- const isInsideRouterMonoRepo = (() => {
- const currentDir = path.dirname(fileURLToPath(import.meta.url))
- return path.basename(path.resolve(currentDir, '../../../')) === 'packages'
- })()
-
- return [
- {
- name: 'tanstack-react-start:config',
- configEnvironment() {
- return {
- resolve: {
- dedupe: ['react', 'react-dom', '@tanstack/react-router'],
-
- external: isInsideRouterMonoRepo
- ? ['@tanstack/react-router', '@tanstack/react-router-devtools']
- : undefined,
- },
-
- optimizeDeps: {
- exclude: ['@tanstack/react-router-devtools'],
- include: [
- 'react',
- 'react/jsx-runtime',
- 'react/jsx-dev-runtime',
- 'react-dom',
- 'react-dom/client',
- '@tanstack/react-router',
- ],
- },
- }
- },
- },
- TanStackStartVitePluginCore(
- {
- framework: 'react',
- getVirtualServerRootHandler(ctx) {
- return `
-import { toWebRequest, defineEventHandler } from '@tanstack/react-start/server';
-import serverEntry from '${ctx.serverEntryFilepath}';
-
-export default defineEventHandler(function(event) {
- const request = toWebRequest(event);
- return serverEntry({ request });
-});`
- },
- getVirtualClientEntry(ctx) {
- return `
-import { StrictMode, startTransition } from 'react';
-import { hydrateRoot } from 'react-dom/client';
-import { StartClient } from '@tanstack/react-start';
-import { createRouter } from '${ctx.routerFilepath}';
-
-const router = createRouter();
-
-startTransition(() => {
- hydrateRoot(
- document,
-
-
-
- );
-});`
- },
- getVirtualServerEntry(ctx) {
- return `
-import { createStartHandler, defaultStreamHandler } from '@tanstack/react-start/server';
-import { createRouter } from '${ctx.routerFilepath}';
-
-export default createStartHandler({
- createRouter,
-})(defaultStreamHandler);`
- },
- crawlPackages(opts) {
- if (opts.name === '@tanstack/react-router-devtools') {
- return 'exclude'
- }
- if (hasRootExport(opts.exports) && 'react' in opts.peerDependencies) {
- return 'include'
- }
- return undefined
- },
- },
- options,
- ),
- !opts?.customViteReactPlugin && viteReact(options.react),
- ]
-}
-
-export { TanStackStartVitePlugin as tanstackStart }
diff --git a/packages/react-start-plugin/src/schema.ts b/packages/react-start-plugin/src/schema.ts
deleted file mode 100644
index 8e7f7b73c6..0000000000
--- a/packages/react-start-plugin/src/schema.ts
+++ /dev/null
@@ -1,33 +0,0 @@
-import { z } from 'zod'
-import {
- createTanStackConfig,
- createTanStackStartOptionsSchema,
-} from '@tanstack/start-plugin-core'
-import type { Options as ViteReactOptions } from '@vitejs/plugin-react'
-
-export type WithReactPlugin = {
- react?: ViteReactOptions
- customViteReactPlugin?: boolean
-}
-
-const frameworkPlugin = {
- react: z.custom().optional(),
- customViteReactPlugin: z.boolean().optional().default(false),
-}
-
-// eslint-disable-next-line unused-imports/no-unused-vars
-const TanStackStartOptionsSchema =
- createTanStackStartOptionsSchema(frameworkPlugin)
-
-const defaultConfig = createTanStackConfig(frameworkPlugin)
-
-export function getTanStackStartOptions(opts?: TanStackStartInputConfig) {
- return defaultConfig.parse(opts)
-}
-
-export type TanStackStartInputConfig = z.input<
- typeof TanStackStartOptionsSchema
->
-export type TanStackStartOutputConfig = ReturnType<
- typeof getTanStackStartOptions
->
diff --git a/packages/react-start-plugin/tsconfig.json b/packages/react-start-plugin/tsconfig.json
deleted file mode 100644
index 090ec3917d..0000000000
--- a/packages/react-start-plugin/tsconfig.json
+++ /dev/null
@@ -1,10 +0,0 @@
-{
- "extends": "../../tsconfig.json",
- "include": ["src", "vite.config.ts", "tests"],
- "exclude": ["tests/**/test-files/**", "tests/**/snapshots/**"],
- "compilerOptions": {
- "outDir": "dist/esm",
- "target": "esnext",
- "noEmit": true
- }
-}
diff --git a/packages/react-start-server/package.json b/packages/react-start-server/package.json
index 8f72d70d39..0619f1d240 100644
--- a/packages/react-start-server/package.json
+++ b/packages/react-start-server/package.json
@@ -1,6 +1,6 @@
{
"name": "@tanstack/react-start-server",
- "version": "1.131.27",
+ "version": "1.132.0-alpha.11",
"description": "Modern and scalable routing for React applications",
"author": "Tanner Linsley",
"license": "MIT",
@@ -45,10 +45,6 @@
"import": {
"types": "./dist/esm/index.d.ts",
"default": "./dist/esm/index.js"
- },
- "require": {
- "types": "./dist/cjs/index.d.cts",
- "default": "./dist/cjs/index.cjs"
}
},
"./package.json": "./package.json"
@@ -59,20 +55,17 @@
"src"
],
"engines": {
- "node": ">=12"
+ "node": ">=22.12.0"
},
"dependencies": {
"@tanstack/history": "workspace:*",
"@tanstack/react-router": "workspace:*",
"@tanstack/router-core": "workspace:*",
"@tanstack/start-client-core": "workspace:*",
- "@tanstack/start-server-core": "workspace:*",
- "h3": "1.13.0",
- "isbot": "^5.1.22"
+ "@tanstack/start-server-core": "workspace:*"
},
"devDependencies": {
"@vitejs/plugin-react": "^4.3.4",
- "esbuild": "^0.25.0",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"typescript": "^5.7.2"
diff --git a/packages/react-start-server/vite-minify-plugin.ts b/packages/react-start-server/vite-minify-plugin.ts
deleted file mode 100644
index d8da290266..0000000000
--- a/packages/react-start-server/vite-minify-plugin.ts
+++ /dev/null
@@ -1,25 +0,0 @@
-import { transform as esbuildTransform } from 'esbuild'
-import type { Plugin } from 'vite'
-
-export default function minifyScriptPlugin(): Plugin {
- return {
- name: 'vite-plugin-minify-script',
- enforce: 'pre',
- async transform(code, id) {
- if (!id.endsWith('?script-string')) {
- return null
- }
-
- const result = await esbuildTransform(code, {
- loader: 'ts',
- minify: true,
- target: 'esnext',
- })
-
- return {
- code: `export default ${JSON.stringify(result.code)};`,
- map: null,
- }
- },
- }
-}
diff --git a/packages/react-start-server/vite.config.ts b/packages/react-start-server/vite.config.ts
index e05e5cc394..9a1d38f579 100644
--- a/packages/react-start-server/vite.config.ts
+++ b/packages/react-start-server/vite.config.ts
@@ -2,11 +2,9 @@ import { defineConfig, mergeConfig } from 'vitest/config'
import { tanstackViteConfig } from '@tanstack/config/vite'
import react from '@vitejs/plugin-react'
import packageJson from './package.json'
-import minifyScriptPlugin from './vite-minify-plugin'
-import type { ViteUserConfig } from 'vitest/config'
const config = defineConfig({
- plugins: [minifyScriptPlugin(), react()] as ViteUserConfig['plugins'],
+ plugins: [react()],
test: {
name: packageJson.name,
watch: false,
@@ -19,5 +17,6 @@ export default mergeConfig(
tanstackViteConfig({
srcDir: './src',
entry: './src/index.tsx',
+ cjs: false,
}),
)
diff --git a/packages/react-start/package.json b/packages/react-start/package.json
index 1311f21f6f..b703730e8d 100644
--- a/packages/react-start/package.json
+++ b/packages/react-start/package.json
@@ -1,6 +1,6 @@
{
"name": "@tanstack/react-start",
- "version": "1.131.27",
+ "version": "1.132.0-alpha.11",
"description": "Modern and scalable routing for React applications",
"author": "Tanner Linsley",
"license": "MIT",
@@ -36,60 +36,24 @@
"import": {
"types": "./dist/esm/client.d.ts",
"default": "./dist/esm/client.js"
- },
- "require": {
- "types": "./dist/cjs/client.d.cts",
- "default": "./dist/cjs/client.cjs"
}
},
"./client": {
"import": {
"types": "./dist/esm/client.d.ts",
"default": "./dist/esm/client.js"
- },
- "require": {
- "types": "./dist/cjs/client.d.cts",
- "default": "./dist/cjs/client.cjs"
}
},
"./server": {
"import": {
"types": "./dist/esm/server.d.ts",
"default": "./dist/esm/server.js"
- },
- "require": {
- "types": "./dist/cjs/server.d.cts",
- "default": "./dist/cjs/server.cjs"
}
},
"./plugin/vite": {
"import": {
- "types": "./dist/esm/plugin-vite.d.ts",
- "default": "./dist/esm/plugin-vite.js"
- },
- "require": {
- "types": "./dist/cjs/plugin-vite.d.cts",
- "default": "./dist/cjs/plugin-vite.cjs"
- }
- },
- "./server-functions-client": {
- "import": {
- "types": "./dist/esm/server-functions-client.d.ts",
- "default": "./dist/esm/server-functions-client.js"
- },
- "require": {
- "types": "./dist/cjs/server-functions-client.d.cts",
- "default": "./dist/cjs/server-functions-client.cjs"
- }
- },
- "./server-functions-server": {
- "import": {
- "types": "./dist/esm/server-functions-server.d.ts",
- "default": "./dist/esm/server-functions-server.js"
- },
- "require": {
- "types": "./dist/cjs/server-functions-server.d.cts",
- "default": "./dist/cjs/server-functions-server.cjs"
+ "types": "./dist/esm/plugin/vite.d.ts",
+ "default": "./dist/esm/plugin/vite.js"
}
},
"./package.json": "./package.json"
@@ -100,22 +64,18 @@
"src"
],
"engines": {
- "node": ">=12"
+ "node": ">=22.12.0"
},
"dependencies": {
"@tanstack/react-start-client": "workspace:*",
"@tanstack/react-start-server": "workspace:*",
- "@tanstack/react-start-plugin": "workspace:*",
- "@tanstack/start-server-functions-client": "workspace:*",
- "@tanstack/start-server-functions-server": "workspace:*"
+ "@tanstack/router-utils": "workspace:^",
+ "@tanstack/start-plugin-core": "workspace:*",
+ "pathe": "^2.0.3"
},
"peerDependencies": {
- "@vitejs/plugin-react": ">=4.3.4",
"react": ">=18.0.0 || >=19.0.0",
"react-dom": ">=18.0.0 || >=19.0.0",
- "vite": ">=6.0.0"
- },
- "devDependencies": {
- "esbuild": "^0.25.0"
+ "vite": ">=7.0.0"
}
}
diff --git a/packages/react-start/src/plugin-vite.ts b/packages/react-start/src/plugin-vite.ts
deleted file mode 100644
index d991c3b71c..0000000000
--- a/packages/react-start/src/plugin-vite.ts
+++ /dev/null
@@ -1 +0,0 @@
-export * from '@tanstack/react-start-plugin'
diff --git a/packages/react-start/src/plugin/default-entry/client.tsx b/packages/react-start/src/plugin/default-entry/client.tsx
new file mode 100644
index 0000000000..7f69650cb2
--- /dev/null
+++ b/packages/react-start/src/plugin/default-entry/client.tsx
@@ -0,0 +1,15 @@
+import { StrictMode, startTransition } from 'react'
+import { hydrateRoot } from 'react-dom/client'
+import { StartClient } from '@tanstack/react-start'
+import { createRouter } from '#tanstack-start-router-entry'
+
+const router = createRouter()
+
+startTransition(() => {
+ hydrateRoot(
+ document,
+
+
+ ,
+ )
+})
diff --git a/packages/react-start/src/plugin/default-entry/router-entry.d.ts b/packages/react-start/src/plugin/default-entry/router-entry.d.ts
new file mode 100644
index 0000000000..00b100e793
--- /dev/null
+++ b/packages/react-start/src/plugin/default-entry/router-entry.d.ts
@@ -0,0 +1,4 @@
+declare module '#tanstack-start-router-entry' {
+ // eslint-disable-next-line @typescript-eslint/consistent-type-imports
+ export const createRouter: () => import('@tanstack/router-core').AnyRouter
+}
diff --git a/packages/react-start/src/plugin/default-entry/server.ts b/packages/react-start/src/plugin/default-entry/server.ts
new file mode 100644
index 0000000000..fedb30d507
--- /dev/null
+++ b/packages/react-start/src/plugin/default-entry/server.ts
@@ -0,0 +1,14 @@
+import {
+ createStartHandler,
+ defaultStreamHandler,
+} from '@tanstack/react-start/server'
+
+import { createRouter } from '#tanstack-start-router-entry'
+
+const fetch = createStartHandler({
+ createRouter,
+})(defaultStreamHandler)
+
+export default {
+ fetch,
+}
diff --git a/packages/react-start/src/plugin/vite.ts b/packages/react-start/src/plugin/vite.ts
new file mode 100644
index 0000000000..2946c0b82f
--- /dev/null
+++ b/packages/react-start/src/plugin/vite.ts
@@ -0,0 +1,94 @@
+import { fileURLToPath } from 'node:url'
+import {
+ TanStackStartVitePluginCore,
+ VITE_ENVIRONMENT_NAMES,
+} from '@tanstack/start-plugin-core'
+import path from 'pathe'
+import type { TanStackStartInputConfig } from '@tanstack/start-plugin-core'
+import type { PluginOption } from 'vite'
+
+const currentDir = path.dirname(fileURLToPath(import.meta.url))
+const defaultEntryDir = path.resolve(
+ currentDir,
+ '..',
+ '..',
+ 'plugin',
+ 'default-entry',
+)
+const defaultEntryPaths = {
+ client: path.resolve(defaultEntryDir, 'client'),
+ server: path.resolve(defaultEntryDir, 'server'),
+}
+
+const isInsideRouterMonoRepo =
+ path.basename(path.resolve(currentDir, '../../../../')) === 'packages'
+
+function hasRootExport(
+ exportsField?: Record | string,
+): boolean {
+ if (!exportsField) return false
+
+ if (typeof exportsField === 'string') {
+ // shorthand form: "exports": "./index.js"
+ return true
+ }
+
+ if (typeof exportsField === 'object') {
+ return '.' in exportsField
+ }
+
+ return false
+}
+
+export function tanstackStart(
+ options?: TanStackStartInputConfig,
+): Array {
+ return [
+ {
+ name: 'tanstack-react-start:config',
+ configEnvironment(env, userConfig) {
+ return {
+ resolve: {
+ dedupe: ['react', 'react-dom', '@tanstack/react-router'],
+
+ external:
+ userConfig.resolve?.noExternal === true || !isInsideRouterMonoRepo
+ ? undefined
+ : ['@tanstack/react-router', '@tanstack/react-router-devtools'],
+ },
+
+ optimizeDeps: {
+ exclude: ['@tanstack/react-router-devtools'],
+ include: [
+ 'react',
+ 'react/jsx-runtime',
+ 'react/jsx-dev-runtime',
+ 'react-dom',
+ 'react-dom/client',
+ '@tanstack/react-router',
+ ...(env === VITE_ENVIRONMENT_NAMES.server
+ ? ['react-dom/server']
+ : []),
+ ],
+ },
+ }
+ },
+ },
+ TanStackStartVitePluginCore(
+ {
+ framework: 'react',
+ defaultEntryPaths,
+ crawlPackages(opts) {
+ if (opts.name === '@tanstack/react-router-devtools') {
+ return 'exclude'
+ }
+ if (hasRootExport(opts.exports) && 'react' in opts.peerDependencies) {
+ return 'include'
+ }
+ return undefined
+ },
+ },
+ options,
+ ),
+ ]
+}
diff --git a/packages/react-start/src/server-functions-client.tsx b/packages/react-start/src/server-functions-client.tsx
deleted file mode 100644
index 6fc38947aa..0000000000
--- a/packages/react-start/src/server-functions-client.tsx
+++ /dev/null
@@ -1 +0,0 @@
-export * from '@tanstack/start-server-functions-client'
diff --git a/packages/react-start/src/server-functions-server.tsx b/packages/react-start/src/server-functions-server.tsx
deleted file mode 100644
index cbbdd07a89..0000000000
--- a/packages/react-start/src/server-functions-server.tsx
+++ /dev/null
@@ -1 +0,0 @@
-export * from '@tanstack/start-server-functions-server'
diff --git a/packages/react-start/vite.config.ts b/packages/react-start/vite.config.ts
index 99fd4a8b00..c663b9cdf1 100644
--- a/packages/react-start/vite.config.ts
+++ b/packages/react-start/vite.config.ts
@@ -1,5 +1,6 @@
import { defineConfig, mergeConfig } from 'vitest/config'
import { tanstackViteConfig } from '@tanstack/config/vite'
+import { copyFilesPlugin } from '@tanstack/router-utils'
import packageJson from './package.json'
const config = defineConfig({
@@ -8,25 +9,25 @@ const config = defineConfig({
watch: false,
environment: 'jsdom',
},
+ plugins: [
+ copyFilesPlugin({
+ pattern: ['*.ts', '*.tsx', '!*.d.ts'],
+ fromDir: 'src/plugin/default-entry',
+ toDir: 'dist/plugin/default-entry',
+ }),
+ ],
})
export default mergeConfig(
config,
tanstackViteConfig({
srcDir: './src',
- entry: [
- './src/client.tsx',
- './src/server.tsx',
- './src/plugin-vite.ts',
- './src/server-functions-client.tsx',
- './src/server-functions-server.tsx',
- ],
+ entry: ['./src/client.tsx', './src/server.tsx', './src/plugin/vite.ts'],
externalDeps: [
'@tanstack/react-start-client',
'@tanstack/react-start-server',
- '@tanstack/react-start-plugin',
- '@tanstack/start-server-functions-client',
- '@tanstack/start-server-functions-server',
],
+ exclude: ['./src/plugin/default-entry'],
+ cjs: false,
}),
)
diff --git a/packages/router-cli/package.json b/packages/router-cli/package.json
index 0651388c19..8f5a51537c 100644
--- a/packages/router-cli/package.json
+++ b/packages/router-cli/package.json
@@ -1,6 +1,6 @@
{
"name": "@tanstack/router-cli",
- "version": "1.131.27",
+ "version": "1.132.0-alpha.9",
"description": "Modern and scalable routing for React applications",
"author": "Tanner Linsley",
"license": "MIT",
diff --git a/packages/router-core/package.json b/packages/router-core/package.json
index 65c2672d6b..83a9dce8f0 100644
--- a/packages/router-core/package.json
+++ b/packages/router-core/package.json
@@ -1,6 +1,6 @@
{
"name": "@tanstack/router-core",
- "version": "1.131.27",
+ "version": "1.132.0-alpha.8",
"description": "Modern and scalable routing for React applications",
"author": "Tanner Linsley",
"license": "MIT",
diff --git a/packages/router-core/src/Matches.ts b/packages/router-core/src/Matches.ts
index eafb530933..afa4428e10 100644
--- a/packages/router-core/src/Matches.ts
+++ b/packages/router-core/src/Matches.ts
@@ -8,7 +8,7 @@ import type {
RouteById,
RouteIds,
} from './routeInfo'
-import type { AnyRouter, RegisteredRouter } from './router'
+import type { AnyRouter, RegisteredRouter, SSROption } from './router'
import type { Constrain, ControlledPromise } from './utils'
export type AnyMatchAndValue = { match: any; value: any }
@@ -166,7 +166,7 @@ export interface RouteMatch<
globalNotFound?: boolean
staticData: StaticDataRouteOption
/** This attribute is not reactive */
- ssr?: boolean | 'data-only'
+ ssr?: SSROption
_forcePending?: boolean
_displayPending?: boolean
}
diff --git a/packages/router-core/src/config.ts b/packages/router-core/src/config.ts
new file mode 100644
index 0000000000..44a369b498
--- /dev/null
+++ b/packages/router-core/src/config.ts
@@ -0,0 +1,42 @@
+import type { SSROption } from './router'
+import type { AnySerializationAdapter } from './ssr/serializer/transformer'
+
+export interface RouterConfigOptions<
+ in out TSerializationAdapters,
+ in out TDefaultSsr,
+> {
+ serializationAdapters?: TSerializationAdapters
+ defaultSsr?: TDefaultSsr
+}
+
+export interface RouterConfig<
+ in out TSerializationAdapters,
+ in out TDefaultSsr,
+> {
+ '~types': RouterConfigTypes
+ serializationAdapters: TSerializationAdapters
+ defaultSsr: TDefaultSsr | undefined
+}
+
+export interface RouterConfigTypes<
+ in out TSerializationAdapters,
+ in out TDefaultSsr,
+> {
+ serializationAdapters: TSerializationAdapters
+ defaultSsr: TDefaultSsr
+}
+
+export const createRouterConfig = <
+ const TSerializationAdapters extends
+ ReadonlyArray = [],
+ TDefaultSsr extends SSROption = SSROption,
+>(
+ options: RouterConfigOptions,
+): RouterConfig => {
+ return {
+ serializationAdapters: options.serializationAdapters,
+ defaultSsr: options.defaultSsr,
+ } as RouterConfig
+}
+
+export type AnyRouterConfig = RouterConfig
diff --git a/packages/router-core/src/fileRoute.ts b/packages/router-core/src/fileRoute.ts
index 2c689c3929..f9298d55b5 100644
--- a/packages/router-core/src/fileRoute.ts
+++ b/packages/router-core/src/fileRoute.ts
@@ -8,6 +8,7 @@ import type {
RouteConstraints,
UpdatableRouteOptions,
} from './route'
+import type { Register } from './router'
import type { AnyValidator } from './validators'
export interface FileRouteTypes {
@@ -33,6 +34,7 @@ export interface FileRoutesByPath {
}
export interface FileRouteOptions<
+ TRegister extends Register,
TFilePath extends string,
TParentRoute extends AnyRoute,
TId extends RouteConstraints['TId'],
@@ -44,7 +46,9 @@ export interface FileRouteOptions<
TBeforeLoadFn = AnyContext,
TLoaderDeps extends Record = {},
TLoaderFn = undefined,
+ TSSR = unknown,
> extends FileBaseRouteOptions<
+ TRegister,
TParentRoute,
TId,
TPath,
@@ -54,7 +58,9 @@ export interface FileRouteOptions<
TLoaderFn,
AnyContext,
TRouteContextFn,
- TBeforeLoadFn
+ TBeforeLoadFn,
+ AnyContext,
+ TSSR
>,
UpdatableRouteOptions<
TParentRoute,
@@ -76,14 +82,17 @@ export type CreateFileRoute<
TPath extends RouteConstraints['TPath'],
TFullPath extends RouteConstraints['TFullPath'],
> = <
+ TRegister extends Register = Register,
TSearchValidator = undefined,
TParams = ResolveParams,
TRouteContextFn = AnyContext,
TBeforeLoadFn = AnyContext,
TLoaderDeps extends Record = {},
TLoaderFn = undefined,
+ TSSR = unknown,
>(
options?: FileRouteOptions<
+ TRegister,
TFilePath,
TParentRoute,
TId,
@@ -94,9 +103,11 @@ export type CreateFileRoute<
TRouteContextFn,
TBeforeLoadFn,
TLoaderDeps,
- TLoaderFn
+ TLoaderFn,
+ TSSR
>,
) => Route<
+ TRegister,
TParentRoute,
TPath,
TFullPath,
@@ -110,7 +121,8 @@ export type CreateFileRoute<
TLoaderDeps,
TLoaderFn,
unknown,
- unknown
+ unknown,
+ TSSR
>
export type LazyRouteOptions = Pick<
diff --git a/packages/router-core/src/index.ts b/packages/router-core/src/index.ts
index ca34da1722..d45b950c23 100644
--- a/packages/router-core/src/index.ts
+++ b/packages/router-core/src/index.ts
@@ -245,8 +245,12 @@ export type {
ClearCacheFn,
CreateRouterFn,
ProcessRouteTreeResult,
+ SSROption,
+ DefaultRegister,
} from './router'
+export * from './config'
+
export type {
MatchLocation,
CommitLocationOptions,
@@ -273,8 +277,6 @@ export {
isPlainObject,
isPlainArray,
deepEqual,
- escapeJSON,
- shallow,
createControlledPromise,
isModuleNotFoundError,
} from './utils'
@@ -412,3 +414,21 @@ export type {
ValidateUseSearchResult,
ValidateUseParamsResult,
} from './typePrimitives'
+
+export type {
+ AnySerializationAdapter,
+ SerializationAdapter,
+ ValidateSerializableInput,
+ ValidateSerializableInputResult,
+ SerializerExtensions,
+ ValidateSerializable,
+ RegisteredSerializableInput,
+} from './ssr/serializer/transformer'
+
+export {
+ createSerializationAdapter,
+ makeSerovalPlugin,
+ makeSsrSerovalPlugin,
+} from './ssr/serializer/transformer'
+
+export { defaultSerovalPlugins } from './ssr/serializer/seroval-plugins'
diff --git a/packages/router-core/src/load-matches.ts b/packages/router-core/src/load-matches.ts
index c1edd5648f..3e137476ba 100644
--- a/packages/router-core/src/load-matches.ts
+++ b/packages/router-core/src/load-matches.ts
@@ -13,7 +13,7 @@ import type {
SsrContextOptions,
} from './route'
import type { AnyRouteMatch, MakeRouteMatch } from './Matches'
-import type { AnyRouter, UpdateMatchFn } from './router'
+import type { AnyRouter, SSROption, UpdateMatchFn } from './router'
/**
* An object of this shape is created when calling `loadMatches`.
@@ -220,7 +220,7 @@ const isBeforeLoadSsr = (
return
}
- const parentOverride = (tempSsr: boolean | 'data-only') => {
+ const parentOverride = (tempSsr: SSROption) => {
if (tempSsr === true && parentMatch?.ssr === 'data-only') {
return 'data-only'
}
diff --git a/packages/router-core/src/route.ts b/packages/router-core/src/route.ts
index bdda040845..1028ce0bf3 100644
--- a/packages/router-core/src/route.ts
+++ b/packages/router-core/src/route.ts
@@ -15,7 +15,7 @@ import type {
} from './Matches'
import type { RootRouteId } from './root'
import type { ParseRoute, RouteById, RoutePaths } from './routeInfo'
-import type { AnyRouter, RegisteredRouter } from './router'
+import type { AnyRouter, Register, RegisteredRouter, SSROption } from './router'
import type { BuildLocationFn, NavigateFn } from './RouterProvider'
import type {
Assign,
@@ -41,6 +41,7 @@ import type {
ValidatorFn,
ValidatorObj,
} from './validators'
+import type { ValidateSerializableLifecycleResult } from './ssr/serializer/transformer'
export type AnyPathParams = {}
@@ -391,6 +392,7 @@ export interface RouteTypes<
in out TLoaderFn,
in out TChildren,
in out TFileRouteTypes,
+ in out TSSR,
> {
parentRoute: TParentRoute
path: TPath
@@ -422,8 +424,23 @@ export interface RouteTypes<
loaderData: ResolveLoaderData
loaderDeps: TLoaderDeps
fileRouteTypes: TFileRouteTypes
+ ssr: ResolveSSR
+ allSsr: ResolveAllSSR
}
+export type ResolveSSR = TSSR extends (...args: ReadonlyArray) => any
+ ? LooseReturnType
+ : TSSR
+
+export type ResolveAllSSR<
+ TParentRoute extends AnyRoute,
+ TSSR,
+> = unknown extends TParentRoute
+ ? ResolveSSR
+ : unknown extends TSSR
+ ? TParentRoute['types']['ssr']
+ : ResolveSSR
+
export type ResolveFullPath<
TParentRoute extends AnyRoute,
TPath extends string,
@@ -440,6 +457,7 @@ export type RouteLazyFn = (
) => TRoute
export type RouteAddChildrenFn<
+ in out TRegister extends Register,
in out TParentRoute extends AnyRoute,
in out TPath extends string,
in out TFullPath extends string,
@@ -453,12 +471,14 @@ export type RouteAddChildrenFn<
in out TLoaderDeps extends Record,
in out TLoaderFn,
in out TFileRouteTypes,
+ in out TSSR,
> = (
children: Constrain<
TNewChildren,
ReadonlyArray | Record
>,
) => Route<
+ TRegister,
TParentRoute,
TPath,
TFullPath,
@@ -472,10 +492,12 @@ export type RouteAddChildrenFn<
TLoaderDeps,
TLoaderFn,
TNewChildren,
- TFileRouteTypes
+ TFileRouteTypes,
+ TSSR
>
export type RouteAddFileChildrenFn<
+ in out TRegister extends Register,
in out TParentRoute extends AnyRoute,
in out TPath extends string,
in out TFullPath extends string,
@@ -489,9 +511,11 @@ export type RouteAddFileChildrenFn<
in out TLoaderDeps extends Record,
in out TLoaderFn,
in out TFileRouteTypes,
+ in out TSSR,
> = (
children: TNewChildren,
) => Route<
+ TRegister,
TParentRoute,
TPath,
TFullPath,
@@ -505,10 +529,12 @@ export type RouteAddFileChildrenFn<
TLoaderDeps,
TLoaderFn,
TNewChildren,
- TFileRouteTypes
+ TFileRouteTypes,
+ TSSR
>
export type RouteAddFileTypesFn<
+ TRegister extends Register,
TParentRoute extends AnyRoute,
TPath extends string,
TFullPath extends string,
@@ -522,7 +548,9 @@ export type RouteAddFileTypesFn<
TLoaderDeps extends Record,
TLoaderFn,
TChildren,
+ TSSR,
> = () => Route<
+ TRegister,
TParentRoute,
TPath,
TFullPath,
@@ -536,10 +564,12 @@ export type RouteAddFileTypesFn<
TLoaderDeps,
TLoaderFn,
TChildren,
- TNewFileRouteTypes
+ TNewFileRouteTypes,
+ TSSR
>
export interface Route<
+ in out TRegister extends Register,
in out TParentRoute extends AnyRoute,
in out TPath extends string,
in out TFullPath extends string,
@@ -554,6 +584,7 @@ export interface Route<
in out TLoaderFn,
in out TChildren,
in out TFileRouteTypes,
+ in out TSSR,
> extends RouteExtensions {
path: TPath
parentRoute: TParentRoute
@@ -572,9 +603,11 @@ export interface Route<
TLoaderDeps,
TLoaderFn,
TChildren,
- TFileRouteTypes
+ TFileRouteTypes,
+ TSSR
>
options: RouteOptions<
+ TRegister,
TParentRoute,
TId,
TCustomId,
@@ -586,7 +619,8 @@ export interface Route<
TLoaderFn,
TRouterContext,
TRouteContextFn,
- TBeforeLoadFn
+ TBeforeLoadFn,
+ TSSR
>
isRoot: TParentRoute extends AnyRoute ? true : false
/** @internal */
@@ -596,6 +630,7 @@ export interface Route<
lazyFn?: () => Promise<
LazyRoute<
Route<
+ TRegister,
TParentRoute,
TPath,
TFullPath,
@@ -609,7 +644,8 @@ export interface Route<
TLoaderDeps,
TLoaderFn,
TChildren,
- TFileRouteTypes
+ TFileRouteTypes,
+ TSSR
>
>
>
@@ -636,6 +672,7 @@ export interface Route<
) => this
lazy: RouteLazyFn<
Route<
+ TRegister,
TParentRoute,
TPath,
TFullPath,
@@ -649,10 +686,12 @@ export interface Route<
TLoaderDeps,
TLoaderFn,
TChildren,
- TFileRouteTypes
+ TFileRouteTypes,
+ TSSR
>
>
addChildren: RouteAddChildrenFn<
+ TRegister,
TParentRoute,
TPath,
TFullPath,
@@ -665,9 +704,11 @@ export interface Route<
TBeforeLoadFn,
TLoaderDeps,
TLoaderFn,
- TFileRouteTypes
+ TFileRouteTypes,
+ TSSR
>
_addFileChildren: RouteAddFileChildrenFn<
+ TRegister,
TParentRoute,
TPath,
TFullPath,
@@ -680,9 +721,11 @@ export interface Route<
TBeforeLoadFn,
TLoaderDeps,
TLoaderFn,
- TFileRouteTypes
+ TFileRouteTypes,
+ TSSR
>
_addFileTypes: RouteAddFileTypesFn<
+ TRegister,
TParentRoute,
TPath,
TFullPath,
@@ -695,7 +738,8 @@ export interface Route<
TBeforeLoadFn,
TLoaderDeps,
TLoaderFn,
- TChildren
+ TChildren,
+ TSSR
>
}
@@ -713,6 +757,8 @@ export type AnyRoute = Route<
any,
any,
any,
+ any,
+ any,
any
>
@@ -721,6 +767,7 @@ export type AnyRouteWithContext = AnyRoute & {
}
export type RouteOptions<
+ TRegister extends Register,
TParentRoute extends AnyRoute = AnyRoute,
TId extends string = string,
TCustomId extends string = string,
@@ -733,7 +780,9 @@ export type RouteOptions<
TRouterContext = {},
TRouteContextFn = AnyContext,
TBeforeLoadFn = AnyContext,
+ TSSR = unknown,
> = BaseRouteOptions<
+ TRegister,
TParentRoute,
TId,
TCustomId,
@@ -744,7 +793,8 @@ export type RouteOptions<
TLoaderFn,
TRouterContext,
TRouteContextFn,
- TBeforeLoadFn
+ TBeforeLoadFn,
+ TSSR
> &
UpdatableRouteOptions<
NoInfer,
@@ -790,6 +840,7 @@ export type BeforeLoadFn<
) => any
export type FileBaseRouteOptions<
+ TRegister extends Register,
TParentRoute extends AnyRoute = AnyRoute,
TId extends string = string,
TPath extends string = string,
@@ -801,6 +852,7 @@ export type FileBaseRouteOptions<
TRouteContextFn = AnyContext,
TBeforeLoadFn = AnyContext,
TRemountDepsFn = AnyContext,
+ TSSR = unknown,
> = ParamsOptions & {
validateSearch?: Constrain
@@ -830,13 +882,14 @@ export type FileBaseRouteOptions<
) => any
>
- ssr?:
+ ssr?: Constrain<
+ TSSR,
| undefined
- | boolean
- | 'data-only'
+ | SSROption
| ((
ctx: SsrContextOptions,
- ) => Awaitable)
+ ) => Awaitable)
+ >
// This async function is called before a route is loaded.
// If an error is thrown here, the route's loader will not be called.
@@ -852,7 +905,12 @@ export type FileBaseRouteOptions<
TRouterContext,
TRouteContextFn
>,
- ) => any
+ ) => ValidateSerializableLifecycleResult<
+ TRegister,
+ TParentRoute,
+ TSSR,
+ TBeforeLoadFn
+ >
>
loaderDeps?: (
@@ -883,11 +941,17 @@ export type FileBaseRouteOptions<
TRouteContextFn,
TBeforeLoadFn
>,
- ) => any
+ ) => ValidateSerializableLifecycleResult<
+ TRegister,
+ TParentRoute,
+ TSSR,
+ TLoaderFn
+ >
>
}
export type BaseRouteOptions<
+ TRegister extends Register,
TParentRoute extends AnyRoute = AnyRoute,
TId extends string = string,
TCustomId extends string = string,
@@ -899,8 +963,10 @@ export type BaseRouteOptions<
TRouterContext = {},
TRouteContextFn = AnyContext,
TBeforeLoadFn = AnyContext,
+ TSSR = unknown,
> = RoutePathOptions &
FileBaseRouteOptions<
+ TRegister,
TParentRoute,
TId,
TPath,
@@ -910,7 +976,9 @@ export type BaseRouteOptions<
TLoaderFn,
TRouterContext,
TRouteContextFn,
- TBeforeLoadFn
+ TBeforeLoadFn,
+ AnyContext,
+ TSSR
> & {
getParentRoute: () => TParentRoute
}
@@ -1249,14 +1317,17 @@ export interface RootRouteOptionsExtensions
extends DefaultRootRouteOptionsExtensions {}
export type RootRouteOptions<
+ TRegister extends Register = Register,
TSearchValidator = undefined,
TRouterContext = {},
TRouteContextFn = AnyContext,
TBeforeLoadFn = AnyContext,
TLoaderDeps extends Record = {},
TLoaderFn = undefined,
+ TSSR = unknown,
> = Omit<
RouteOptions<
+ TRegister,
any, // TParentRoute
RootRouteId, // TId
RootRouteId, // TCustomId
@@ -1268,7 +1339,8 @@ export type RootRouteOptions<
TLoaderFn,
TRouterContext,
TRouteContextFn,
- TBeforeLoadFn
+ TBeforeLoadFn,
+ TSSR
>,
| 'path'
| 'id'
@@ -1334,6 +1406,7 @@ export type NotFoundRouteProps = {
}
export class BaseRoute<
+ in out TRegister extends Register,
in out TParentRoute extends AnyRoute = AnyRoute,
in out TPath extends string = '/',
in out TFullPath extends string = ResolveFullPath,
@@ -1348,9 +1421,11 @@ export class BaseRoute<
in out TLoaderFn = undefined,
in out TChildren = unknown,
in out TFileRouteTypes = unknown,
+ in out TSSR = unknown,
> {
isRoot: TParentRoute extends AnyRoute ? true : false
options: RouteOptions<
+ TRegister,
TParentRoute,
TId,
TCustomId,
@@ -1362,7 +1437,8 @@ export class BaseRoute<
TLoaderFn,
TRouterContext,
TRouteContextFn,
- TBeforeLoadFn
+ TBeforeLoadFn,
+ TSSR
>
// The following properties are set up in this.init()
@@ -1395,6 +1471,7 @@ export class BaseRoute<
lazyFn?: () => Promise<
LazyRoute<
Route<
+ TRegister,
TParentRoute,
TPath,
TFullPath,
@@ -1408,7 +1485,8 @@ export class BaseRoute<
TLoaderDeps,
TLoaderFn,
TChildren,
- TFileRouteTypes
+ TFileRouteTypes,
+ TSSR
>
>
>
@@ -1419,6 +1497,7 @@ export class BaseRoute<
constructor(
options?: RouteOptions<
+ TRegister,
TParentRoute,
TId,
TCustomId,
@@ -1430,7 +1509,8 @@ export class BaseRoute<
TLoaderFn,
TRouterContext,
TRouteContextFn,
- TBeforeLoadFn
+ TBeforeLoadFn,
+ TSSR
>,
) {
this.options = (options as any) || {}
@@ -1455,7 +1535,8 @@ export class BaseRoute<
TLoaderDeps,
TLoaderFn,
TChildren,
- TFileRouteTypes
+ TFileRouteTypes,
+ TSSR
>
init = (opts: { originalIndex: number }): void => {
@@ -1463,6 +1544,7 @@ export class BaseRoute<
const options = this.options as
| (RouteOptions<
+ TRegister,
TParentRoute,
TId,
TCustomId,
@@ -1474,7 +1556,8 @@ export class BaseRoute<
TLoaderFn,
TRouterContext,
TRouteContextFn,
- TBeforeLoadFn
+ TBeforeLoadFn,
+ TSSR
> &
RoutePathOptionsIntersection)
| undefined
@@ -1536,6 +1619,7 @@ export class BaseRoute<
}
addChildren: RouteAddChildrenFn<
+ TRegister,
TParentRoute,
TPath,
TFullPath,
@@ -1548,12 +1632,14 @@ export class BaseRoute<
TBeforeLoadFn,
TLoaderDeps,
TLoaderFn,
- TFileRouteTypes
+ TFileRouteTypes,
+ TSSR
> = (children) => {
return this._addFileChildren(children) as any
}
_addFileChildren: RouteAddFileChildrenFn<
+ TRegister,
TParentRoute,
TPath,
TFullPath,
@@ -1566,7 +1652,8 @@ export class BaseRoute<
TBeforeLoadFn,
TLoaderDeps,
TLoaderFn,
- TFileRouteTypes
+ TFileRouteTypes,
+ TSSR
> = (children) => {
if (Array.isArray(children)) {
this.children = children as TChildren
@@ -1580,6 +1667,7 @@ export class BaseRoute<
}
_addFileTypes: RouteAddFileTypesFn<
+ TRegister,
TParentRoute,
TPath,
TFullPath,
@@ -1592,7 +1680,8 @@ export class BaseRoute<
TBeforeLoadFn,
TLoaderDeps,
TLoaderFn,
- TChildren
+ TChildren,
+ TSSR
> = () => {
return this as any
}
@@ -1613,6 +1702,7 @@ export class BaseRoute<
}) => {
Object.assign(this.options, options)
return this as unknown as BaseRoute<
+ TRegister,
TParentRoute,
TPath,
TFullPath,
@@ -1626,7 +1716,8 @@ export class BaseRoute<
TLoaderDeps,
TNewLoaderFn,
TChildren,
- TFileRouteTypes
+ TFileRouteTypes,
+ TSSR
>
}
@@ -1650,6 +1741,7 @@ export class BaseRoute<
lazy: RouteLazyFn<
Route<
+ TRegister,
TParentRoute,
TPath,
TFullPath,
@@ -1663,7 +1755,8 @@ export class BaseRoute<
TLoaderDeps,
TLoaderFn,
TChildren,
- TFileRouteTypes
+ TFileRouteTypes,
+ TSSR
>
> = (lazyFn) => {
this.lazyFn = lazyFn
@@ -1684,6 +1777,7 @@ export class BaseRouteApi {
}
export interface RootRoute<
+ in out TRegister extends Register,
in out TSearchValidator = undefined,
in out TRouterContext = {},
in out TRouteContextFn = AnyContext,
@@ -1692,7 +1786,9 @@ export interface RootRoute<
in out TLoaderFn = undefined,
in out TChildren = unknown,
in out TFileRouteTypes = unknown,
+ in out TSSR = unknown,
> extends Route<
+ TRegister,
any, // TParentRoute
'/', // TPath
'/', // TFullPath
@@ -1706,10 +1802,12 @@ export interface RootRoute<
TLoaderDeps,
TLoaderFn,
TChildren, // TChildren
- TFileRouteTypes
+ TFileRouteTypes,
+ TSSR
> {}
export class BaseRootRoute<
+ in out TRegister extends Register,
in out TSearchValidator = undefined,
in out TRouterContext = {},
in out TRouteContextFn = AnyContext,
@@ -1718,7 +1816,9 @@ export class BaseRootRoute<
in out TLoaderFn = undefined,
in out TChildren = unknown,
in out TFileRouteTypes = unknown,
+ in out TSSR = unknown,
> extends BaseRoute<
+ TRegister,
any, // TParentRoute
'/', // TPath
'/', // TFullPath
@@ -1732,16 +1832,19 @@ export class BaseRootRoute<
TLoaderDeps,
TLoaderFn,
TChildren, // TChildren
- TFileRouteTypes
+ TFileRouteTypes,
+ TSSR
> {
constructor(
options?: RootRouteOptions<
+ TRegister,
TSearchValidator,
TRouterContext,
TRouteContextFn,
TBeforeLoadFn,
TLoaderDeps,
- TLoaderFn
+ TLoaderFn,
+ TSSR
>,
) {
super(options as any)
diff --git a/packages/router-core/src/router.ts b/packages/router-core/src/router.ts
index 6a132b5783..3b6276d854 100644
--- a/packages/router-core/src/router.ts
+++ b/packages/router-core/src/router.ts
@@ -46,6 +46,7 @@ import type {
} from '@tanstack/history'
import type {
Awaitable,
+ Constrain,
ControlledPromise,
NoInfer,
NonNullableUpdater,
@@ -84,6 +85,8 @@ import type { Manifest } from './manifest'
import type { AnySchema, AnyValidator } from './validators'
import type { NavigateOptions, ResolveRelativePath, ToOptions } from './link'
import type { NotFoundError } from './not-found'
+import type { AnySerializationAdapter, ValidateSerializableInput } from './ssr/serializer/transformer'
+import type { AnyRouterConfig } from './config'
export type ControllablePromise = Promise & {
resolve: (value: T) => void
@@ -94,6 +97,8 @@ export type InjectedHtmlEntry = Promise
export interface DefaultRegister {
router: AnyRouter
+ config: AnyRouterConfig
+ ssr: SSROption
}
export interface Register extends DefaultRegister {
@@ -111,12 +116,14 @@ export interface DefaultRouterOptionsExtensions {}
export interface RouterOptionsExtensions
extends DefaultRouterOptionsExtensions {}
+export type SSROption = boolean | 'data-only'
+
export interface RouterOptions<
TRouteTree extends AnyRoute,
TTrailingSlashOption extends TrailingSlashOption,
TDefaultStructuralSharingOption extends boolean = false,
TRouterHistory extends RouterHistory = RouterHistory,
- TDehydrated extends Record = Record,
+ TDehydrated = undefined,
> extends RouterOptionsExtensions {
/**
* The history object that will be used to manage the browser history.
@@ -284,7 +291,7 @@ export interface RouterOptions<
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#dehydrate-method)
* @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/external-data-loading#critical-dehydrationhydration)
*/
- dehydrate?: () => Awaitable
+ dehydrate?: () => Constrain>
/**
* A function that will be called when the router is hydrated.
*
@@ -354,7 +361,7 @@ export interface RouterOptions<
*
* @default true
*/
- defaultSsr?: boolean | 'data-only'
+ defaultSsr?: SSROption
search?: {
/**
@@ -390,7 +397,9 @@ export interface RouterOptions<
*
* @default false
*/
- scrollRestoration?: boolean
+ scrollRestoration?:
+ | boolean
+ | ((opts: { location: ParsedLocation }) => boolean)
/**
* A function that will be called to get the key for the scroll restoration cache.
@@ -421,6 +430,8 @@ export interface RouterOptions<
* @default false
*/
disableGlobalCatchBoundary?: boolean
+
+ serializationAdapters?: ReadonlyArray
}
export interface RouterState<
@@ -703,6 +714,7 @@ export interface ViewTransitionOptions {
}) => Array)
}
+// TODO where is this used? can we remove this?
export function defaultSerializeError(err: unknown) {
if (err instanceof Error) {
const obj = {
@@ -933,7 +945,7 @@ export class RouterCore<
}
}
- get state() {
+ get state(): RouterState {
return this.__store.state
}
@@ -1414,50 +1426,44 @@ export class RouterCore<
_buildLocation: true,
})
+ // Now let's find the starting pathname
+ // This should default to the current location if no from is provided
const lastMatch = last(allCurrentLocationMatches)!
- // First let's find the starting pathname
- // By default, start with the current location
- let fromPath = this.resolvePathWithBase(lastMatch.fullPath, '.')
- const toPath = dest.to
- ? this.resolvePathWithBase(fromPath, `${dest.to}`)
- : this.resolvePathWithBase(fromPath, '.')
+ // check that from path exists in the current route tree
+ // do this check only on navigations during test or development
+ if (
+ dest.from &&
+ process.env.NODE_ENV !== 'production' &&
+ dest._isNavigate
+ ) {
+ const allFromMatches = this.getMatchedRoutes(
+ dest.from,
+ undefined,
+ ).matchedRoutes
- const routeIsChanging =
- !!dest.to &&
- !comparePaths(dest.to.toString(), fromPath) &&
- !comparePaths(toPath, fromPath)
+ const matchedFrom = findLast(allCurrentLocationMatches, (d) => {
+ return comparePaths(d.fullPath, dest.from!)
+ })
- // If the route is changing we need to find the relative fromPath
- if (dest.unsafeRelative === 'path') {
- fromPath = currentLocation.pathname
- } else if (routeIsChanging && dest.from) {
- fromPath = dest.from
+ const matchedCurrent = findLast(allFromMatches, (d) => {
+ return comparePaths(d.fullPath, lastMatch.fullPath)
+ })
- // do this check only on navigations during test or development
- if (process.env.NODE_ENV !== 'production' && dest._isNavigate) {
- const allFromMatches = this.getMatchedRoutes(
- dest.from,
- undefined,
- ).matchedRoutes
-
- const matchedFrom = findLast(allCurrentLocationMatches, (d) => {
- return comparePaths(d.fullPath, fromPath)
- })
-
- const matchedCurrent = findLast(allFromMatches, (d) => {
- return comparePaths(d.fullPath, currentLocation.pathname)
- })
-
- // for from to be invalid it shouldn't just be unmatched to currentLocation
- // but the currentLocation should also be unmatched to from
- if (!matchedFrom && !matchedCurrent) {
- console.warn(`Could not find match for from: ${fromPath}`)
- }
+ // for from to be invalid it shouldn't just be unmatched to currentLocation
+ // but the currentLocation should also be unmatched to from
+ if (!matchedFrom && !matchedCurrent) {
+ console.warn(`Could not find match for from: ${dest.from}`)
}
}
- fromPath = this.resolvePathWithBase(fromPath, '.')
+ const defaultedFromPath =
+ dest.unsafeRelative === 'path'
+ ? currentLocation.pathname
+ : (dest.from ?? lastMatch.fullPath)
+
+ // ensure this includes the basePath if set
+ const fromPath = this.resolvePathWithBase(defaultedFromPath, '.')
// From search should always use the current location
const fromSearch = lastMatch.search
@@ -1465,6 +1471,7 @@ export class RouterCore<
const fromParams = { ...lastMatch.params }
// Resolve the next to
+ // ensure this includes the basePath if set
const nextTo = dest.to
? this.resolvePathWithBase(fromPath, `${dest.to}`)
: this.resolvePathWithBase(fromPath, '.')
diff --git a/packages/router-core/src/scroll-restoration.ts b/packages/router-core/src/scroll-restoration.ts
index 9907878bfa..3da5bef5e5 100644
--- a/packages/router-core/src/scroll-restoration.ts
+++ b/packages/router-core/src/scroll-restoration.ts
@@ -47,10 +47,10 @@ const throttle = (fn: (...args: Array) => void, wait: number) => {
}
}
-function createScrollRestorationCache(): ScrollRestorationCache | undefined {
+function createScrollRestorationCache(): ScrollRestorationCache | null {
const safeSessionStorage = getSafeSessionStorage()
if (!safeSessionStorage) {
- return undefined
+ return null
}
const persistedState = safeSessionStorage.getItem(storageKey)
@@ -125,7 +125,7 @@ export function restoreScroll({
return
}
- const resolvedKey = key || window.history.state?.key
+ const resolvedKey = key || window.history.state?.__TSR_key
const elementEntries = byKey[resolvedKey]
//
@@ -201,7 +201,7 @@ export function restoreScroll({
}
export function setupScrollRestoration(router: AnyRouter, force?: boolean) {
- if (scrollRestorationCache === undefined) {
+ if (!scrollRestorationCache && !router.isServer) {
return
}
const shouldScrollRestoration =
@@ -211,7 +211,11 @@ export function setupScrollRestoration(router: AnyRouter, force?: boolean) {
router.isScrollRestoring = true
}
- if (typeof document === 'undefined' || router.isScrollRestorationSetup) {
+ if (
+ router.isServer ||
+ router.isScrollRestorationSetup ||
+ !scrollRestorationCache
+ ) {
return
}
@@ -324,6 +328,14 @@ export function setupScrollRestoration(router: AnyRouter, force?: boolean) {
router.resetNextScroll = true
return
}
+ if (typeof router.options.scrollRestoration === 'function') {
+ const shouldRestore = router.options.scrollRestoration({
+ location: router.latestLocation,
+ })
+ if (!shouldRestore) {
+ return
+ }
+ }
restoreScroll({
storageKey,
diff --git a/packages/router-core/src/ssr/constants.ts b/packages/router-core/src/ssr/constants.ts
new file mode 100644
index 0000000000..45cb85950a
--- /dev/null
+++ b/packages/router-core/src/ssr/constants.ts
@@ -0,0 +1 @@
+export const GLOBAL_TSR = '$_TSR'
diff --git a/packages/router-core/src/ssr/seroval-plugins.ts b/packages/router-core/src/ssr/serializer/ShallowErrorPlugin.ts
similarity index 93%
rename from packages/router-core/src/ssr/seroval-plugins.ts
rename to packages/router-core/src/ssr/serializer/ShallowErrorPlugin.ts
index f60b8a5657..f0f160335c 100644
--- a/packages/router-core/src/ssr/seroval-plugins.ts
+++ b/packages/router-core/src/ssr/serializer/ShallowErrorPlugin.ts
@@ -1,7 +1,7 @@
import { createPlugin } from 'seroval'
import type { SerovalNode } from 'seroval'
-interface ErrorNode {
+export interface ErrorNode {
message: SerovalNode
}
@@ -13,7 +13,7 @@ export const ShallowErrorPlugin = /* @__PURE__ */ createPlugin<
Error,
ErrorNode
>({
- tag: 'tanstack-start:seroval-plugins/Error',
+ tag: '$TSR/Error',
test(value) {
return value instanceof Error
},
diff --git a/packages/router-core/src/ssr/serializer/seroval-plugins.ts b/packages/router-core/src/ssr/serializer/seroval-plugins.ts
new file mode 100644
index 0000000000..669df5eb23
--- /dev/null
+++ b/packages/router-core/src/ssr/serializer/seroval-plugins.ts
@@ -0,0 +1,9 @@
+import { ReadableStreamPlugin } from 'seroval-plugins/web'
+import { ShallowErrorPlugin } from './ShallowErrorPlugin'
+import type { Plugin } from 'seroval'
+
+export const defaultSerovalPlugins = [
+ ShallowErrorPlugin as Plugin,
+ // ReadableStreamNode is not exported by seroval
+ ReadableStreamPlugin as Plugin,
+]
diff --git a/packages/router-core/src/ssr/serializer/transformer.ts b/packages/router-core/src/ssr/serializer/transformer.ts
new file mode 100644
index 0000000000..a3b9559e2c
--- /dev/null
+++ b/packages/router-core/src/ssr/serializer/transformer.ts
@@ -0,0 +1,215 @@
+import { createPlugin } from 'seroval'
+import { GLOBAL_TSR } from '../constants'
+import type { Plugin, SerovalNode } from 'seroval'
+import type { Register, SSROption } from '../../router'
+import type { LooseReturnType } from '../../utils'
+import type { AnyRoute, ResolveAllSSR } from '../../route'
+
+export type Serializable =
+ | number
+ | string
+ | boolean
+ | null
+ | undefined
+ | bigint
+ | Date
+
+export function createSerializationAdapter<
+ TInput = unknown,
+ TOutput = unknown /* we need to check that this type is actually serializable taking into account all seroval native types and any custom plugin WE=router/start add!!! */,
+>(
+ opts: CreateSerializationAdapterOptions,
+): SerializationAdapter {
+ return opts as unknown as SerializationAdapter
+}
+
+export interface CreateSerializationAdapterOptions {
+ key: string
+ test: (value: unknown) => value is TInput
+ toSerializable: (value: TInput) => ValidateSerializable
+ fromSerializable: (value: TOutput) => TInput
+}
+
+export type ValidateSerializable = T extends TSerializable
+ ? T
+ : T extends (...args: Array) => any
+ ? 'Function is not serializable'
+ : T extends Promise
+ ? ValidateSerializablePromise
+ : T extends ReadableStream
+ ? ValidateReadableStream
+ : T extends Set
+ ? ValidateSerializableSet
+ : T extends Map
+ ? ValidateSerializableMap
+ : {
+ [K in keyof T]: ValidateSerializable
+ }
+
+export type ValidateSerializablePromise =
+ T extends Promise
+ ? Promise>
+ : never
+
+export type ValidateReadableStream =
+ T extends ReadableStream
+ ? ReadableStream>
+ : never
+
+export type ValidateSerializableSet =
+ T extends Set
+ ? Set>
+ : never
+
+export type ValidateSerializableMap =
+ T extends Map
+ ? Map<
+ ValidateSerializable,
+ ValidateSerializable
+ >
+ : never
+
+export type RegisteredReadableStream =
+ unknown extends SerializerExtensions['ReadableStream']
+ ? never
+ : SerializerExtensions['ReadableStream']
+
+export interface DefaultSerializerExtensions {
+ ReadableStream: unknown
+}
+
+export interface SerializerExtensions extends DefaultSerializerExtensions {}
+
+export interface SerializationAdapter {
+ '~types': SerializationAdapterTypes
+ key: string
+ test: (value: unknown) => value is TInput
+ toSerializable: (value: TInput) => TOutput
+ fromSerializable: (value: TOutput) => TInput
+ makePlugin: (options: { didRun: boolean }) => Plugin
+}
+
+export interface SerializationAdapterTypes {
+ input: TInput
+ output: TOutput
+}
+
+export type AnySerializationAdapter = SerializationAdapter
+
+export function makeSsrSerovalPlugin(
+ serializationAdapter: SerializationAdapter,
+ options: { didRun: boolean },
+) {
+ return createPlugin({
+ tag: '$TSR/t/' + serializationAdapter.key,
+ test: serializationAdapter.test,
+ parse: {
+ stream(value, ctx) {
+ return ctx.parse(serializationAdapter.toSerializable(value))
+ },
+ },
+ serialize(node, ctx) {
+ options.didRun = true
+ return (
+ GLOBAL_TSR +
+ '.t.get("' +
+ serializationAdapter.key +
+ '")(' +
+ ctx.serialize(node) +
+ ')'
+ )
+ },
+ // we never deserialize on the server during SSR
+ deserialize: undefined as never,
+ })
+}
+
+export function makeSerovalPlugin(
+ serializationAdapter: SerializationAdapter,
+) {
+ return createPlugin({
+ tag: '$TSR/t/' + serializationAdapter.key,
+ test: serializationAdapter.test,
+ parse: {
+ sync(value, ctx) {
+ return ctx.parse(serializationAdapter.toSerializable(value))
+ },
+ async async(value, ctx) {
+ return await ctx.parse(serializationAdapter.toSerializable(value))
+ },
+ stream(value, ctx) {
+ return ctx.parse(serializationAdapter.toSerializable(value))
+ },
+ },
+ // we don't generate JS code outside of SSR (for now)
+ serialize: undefined as never,
+ deserialize(node, ctx) {
+ return serializationAdapter.fromSerializable(
+ ctx.deserialize(node) as TOutput,
+ )
+ },
+ })
+}
+
+export type ValidateSerializableInput<
+ TRegister extends Register,
+ T,
+> = ValidateSerializable>
+
+export type RegisteredSerializableInput =
+ | (unknown extends RegisteredSerializationAdapters
+ ? never
+ : RegisteredSerializationAdapters extends ReadonlyArray
+ ? RegisteredSerializationAdapters[number]['~types']['input']
+ : never)
+ | Serializable
+
+export type RegisteredSerializationAdapters =
+ TRegister['config']['~types']['serializationAdapters']
+
+export type ValidateSerializableInputResult<
+ TRegister extends Register,
+ T,
+> = ValidateSerializableResult>
+
+export type ValidateSerializableResult =
+ T extends TSerializable
+ ? T
+ : unknown extends SerializerExtensions['ReadableStream']
+ ? { [K in keyof T]: ValidateSerializableResult }
+ : T extends SerializerExtensions['ReadableStream']
+ ? ReadableStream
+ : { [K in keyof T]: ValidateSerializableResult }
+
+export type RegisteredSSROption =
+ unknown extends TRegister['config']['~types']['defaultSsr']
+ ? SSROption
+ : TRegister['config']['~types']['defaultSsr']
+
+export type ValidateSerializableLifecycleResult<
+ TRegister extends Register,
+ TParentRoute extends AnyRoute,
+ TSSR,
+ TFn,
+> = false extends TRegister['ssr']
+ ? any
+ : ValidateSerializableLifecycleResultSSR<
+ TRegister,
+ TParentRoute,
+ TSSR,
+ TFn
+ > extends infer TInput
+ ? TInput
+ : never
+
+export type ValidateSerializableLifecycleResultSSR<
+ TRegister extends Register,
+ TParentRoute extends AnyRoute,
+ TSSR,
+ TFn,
+> =
+ ResolveAllSSR extends false
+ ? any
+ : RegisteredSSROption extends false
+ ? any
+ : ValidateSerializableInput>
diff --git a/packages/router-core/src/ssr/server.ts b/packages/router-core/src/ssr/server.ts
index 7b7fac61ba..82340c84c2 100644
--- a/packages/router-core/src/ssr/server.ts
+++ b/packages/router-core/src/ssr/server.ts
@@ -8,3 +8,9 @@ export {
transformReadableStreamWithRouter,
} from './transformStreamWithRouter'
export { attachRouterServerSsrUtils } from './ssr-server'
+
+declare module '../router' {
+ export interface Register {
+ ssr: true
+ }
+}
diff --git a/packages/router-core/src/ssr/ssr-client.ts b/packages/router-core/src/ssr/ssr-client.ts
index 75af28a76d..cff2dc61be 100644
--- a/packages/router-core/src/ssr/ssr-client.ts
+++ b/packages/router-core/src/ssr/ssr-client.ts
@@ -5,7 +5,8 @@ import type { AnyRouteMatch, MakeRouteMatch } from '../Matches'
import type { AnyRouter } from '../router'
import type { Manifest } from '../manifest'
import type { RouteContextOptions } from '../route'
-import type { GLOBAL_TSR } from './ssr-server'
+import type { AnySerializationAdapter } from './serializer/transformer'
+import type { GLOBAL_TSR } from './constants'
declare global {
interface Window {
@@ -15,8 +16,15 @@ declare global {
export interface TsrSsrGlobal {
router?: DehydratedRouter
- // clean scripts, shortened since this is sent for each streamed script
+ // clean scripts; shortened since this is sent for each streamed script
c: () => void
+ // push script into buffer; shortened since this is sent for each streamed script as soon as the first custom transformer was invoked
+ p: (script: () => void) => void
+ buffer: Array<() => void>
+ // custom transformers, shortened since this is sent for each streamed value that needs a custom transformer
+ t?: Map any>
+ // this flag indicates whether the transformers were initialized
+ initialized?: boolean
}
function hydrateMatch(
@@ -50,7 +58,26 @@ export interface DehydratedRouter {
export async function hydrate(router: AnyRouter): Promise {
invariant(
- window.$_TSR?.router,
+ window.$_TSR,
+ 'Expected to find bootstrap data on window.$_TSR, but we did not. Please file an issue!',
+ )
+
+ const serializationAdapters = router.options.serializationAdapters as
+ | Array
+ | undefined
+
+ if (serializationAdapters?.length) {
+ const fromSerializableMap = new Map()
+ serializationAdapters.forEach((adapter) => {
+ fromSerializableMap.set(adapter.key, adapter.fromSerializable)
+ })
+ window.$_TSR.t = fromSerializableMap
+ window.$_TSR.buffer.forEach((script) => script())
+ }
+ window.$_TSR.initialized = true
+
+ invariant(
+ window.$_TSR.router,
'Expected to find a dehydrated data on window.$_TSR.router, but we did not. Please file an issue!',
)
diff --git a/packages/router-core/src/ssr/ssr-server.ts b/packages/router-core/src/ssr/ssr-server.ts
index 186cb2c4e2..1d1df9c2e0 100644
--- a/packages/router-core/src/ssr/ssr-server.ts
+++ b/packages/router-core/src/ssr/ssr-server.ts
@@ -1,14 +1,16 @@
import { crossSerializeStream, getCrossReferenceHeader } from 'seroval'
-import { ReadableStreamPlugin } from 'seroval-plugins/web'
import invariant from 'tiny-invariant'
import { createControlledPromise } from '../utils'
import minifiedTsrBootStrapScript from './tsrScript?script-string'
-import { ShallowErrorPlugin } from './seroval-plugins'
+import { GLOBAL_TSR } from './constants'
+import { defaultSerovalPlugins } from './serializer/seroval-plugins'
+import { makeSsrSerovalPlugin } from './serializer/transformer'
import type { AnyRouter } from '../router'
import type { DehydratedMatch } from './ssr-client'
import type { DehydratedRouter } from './client'
import type { AnyRouteMatch } from '../Matches'
import type { Manifest } from '../manifest'
+import type { AnySerializationAdapter } from './serializer/transformer'
declare module '../router' {
interface ServerSsr {
@@ -22,7 +24,6 @@ declare module '../router' {
}
}
-export const GLOBAL_TSR = '$_TSR'
const SCOPE_ID = 'tsr'
export function dehydrateMatch(match: AnyRouteMatch): DehydratedMatch {
@@ -54,8 +55,6 @@ export function attachRouterServerSsrUtils(
router.ssr = {
manifest,
}
- const serializationRefs = new Map()
-
let initialScriptSent = false
const getInitialScript = () => {
if (initialScriptSent) {
@@ -82,7 +81,7 @@ export function attachRouterServerSsrUtils(
injectScript: (getScript) => {
return router.serverSsr!.injectHtml(async () => {
const script = await getScript()
- return ``
+ return ``
})
},
dehydrate: async () => {
@@ -106,12 +105,21 @@ export function attachRouterServerSsrUtils(
_dehydrated = true
const p = createControlledPromise()
+ const trackPlugins = { didRun: false }
+ const plugins =
+ (
+ router.options.serializationAdapters as
+ | Array
+ | undefined
+ )?.map((t) => makeSsrSerovalPlugin(t, trackPlugins)) ?? []
crossSerializeStream(dehydratedRouter, {
- refs: serializationRefs,
- // TODO make plugins configurable
- plugins: [ReadableStreamPlugin, ShallowErrorPlugin],
+ refs: new Map(),
+ plugins: [...plugins, ...defaultSerovalPlugins],
onSerialize: (data, initial) => {
- const serialized = initial ? `${GLOBAL_TSR}["router"]=` + data : data
+ let serialized = initial ? GLOBAL_TSR + '.router=' + data : data
+ if (trackPlugins.didRun) {
+ serialized = GLOBAL_TSR + '.p(()=>' + serialized + ')'
+ }
router.serverSsr!.injectScript(() => serialized)
},
scopeId: SCOPE_ID,
diff --git a/packages/router-core/src/ssr/tsrScript.ts b/packages/router-core/src/ssr/tsrScript.ts
index bd8c2a0e0f..c399733fd8 100644
--- a/packages/router-core/src/ssr/tsrScript.ts
+++ b/packages/router-core/src/ssr/tsrScript.ts
@@ -1,7 +1,11 @@
self.$_TSR = {
- c: () => {
+ c() {
document.querySelectorAll('.\\$tsr').forEach((o) => {
o.remove()
})
},
+ p(script) {
+ !this.initialized ? this.buffer.push(script) : script()
+ },
+ buffer: [],
}
diff --git a/packages/router-core/src/utils.ts b/packages/router-core/src/utils.ts
index d446509498..67a30649ae 100644
--- a/packages/router-core/src/utils.ts
+++ b/packages/router-core/src/utils.ts
@@ -411,47 +411,6 @@ export function createControlledPromise(onResolve?: (value: T) => void) {
return controlledPromise
}
-/**
- *
- * @deprecated use `jsesc` instead
- */
-export function escapeJSON(jsonString: string) {
- return jsonString
- .replace(/\\/g, '\\\\') // Escape backslashes
- .replace(/'/g, "\\'") // Escape single quotes
- .replace(/"/g, '\\"') // Escape double quotes
-}
-
-export function shallow(objA: T, objB: T) {
- if (Object.is(objA, objB)) {
- return true
- }
-
- if (
- typeof objA !== 'object' ||
- objA === null ||
- typeof objB !== 'object' ||
- objB === null
- ) {
- return false
- }
-
- const keysA = Object.keys(objA)
- if (keysA.length !== Object.keys(objB).length) {
- return false
- }
-
- for (const item of keysA) {
- if (
- !Object.prototype.hasOwnProperty.call(objB, item) ||
- !Object.is(objA[item as keyof T], objB[item as keyof T])
- ) {
- return false
- }
- }
- return true
-}
-
export function isModuleNotFoundError(error: any): boolean {
// chrome: "Failed to fetch dynamically imported module: http://localhost:5173/src/routes/posts.index.tsx?tsr-split"
// firefox: "error loading dynamically imported module: http://localhost:5173/src/routes/posts.index.tsx?tsr-split"
diff --git a/packages/router-devtools-core/package.json b/packages/router-devtools-core/package.json
index fc91c7e609..75810af17e 100644
--- a/packages/router-devtools-core/package.json
+++ b/packages/router-devtools-core/package.json
@@ -1,6 +1,6 @@
{
"name": "@tanstack/router-devtools-core",
- "version": "1.131.27",
+ "version": "1.132.0-alpha.8",
"description": "Modern and scalable routing for Web applications",
"author": "Tanner Linsley",
"license": "MIT",
@@ -67,7 +67,7 @@
"solid-js": "^1.9.5"
},
"devDependencies": {
- "vite-plugin-solid": "^2.11.6"
+ "vite-plugin-solid": "^2.11.8"
},
"peerDependencies": {
"tiny-invariant": "^1.3.3",
diff --git a/packages/router-devtools-core/src/BaseTanStackRouterDevtoolsPanel.tsx b/packages/router-devtools-core/src/BaseTanStackRouterDevtoolsPanel.tsx
index a84f318bc6..830e5eda3e 100644
--- a/packages/router-devtools-core/src/BaseTanStackRouterDevtoolsPanel.tsx
+++ b/packages/router-devtools-core/src/BaseTanStackRouterDevtoolsPanel.tsx
@@ -98,6 +98,8 @@ function RouteComp({
routerState: Accessor<
RouterState<
Route<
+ any,
+ any,
any,
'/',
'/',
diff --git a/packages/router-devtools/package.json b/packages/router-devtools/package.json
index 6f12d1c94b..38a8ff6c22 100644
--- a/packages/router-devtools/package.json
+++ b/packages/router-devtools/package.json
@@ -1,6 +1,6 @@
{
"name": "@tanstack/router-devtools",
- "version": "1.131.27",
+ "version": "1.132.0-alpha.8",
"description": "Modern and scalable routing for React applications",
"author": "Tanner Linsley",
"license": "MIT",
diff --git a/packages/router-generator/package.json b/packages/router-generator/package.json
index 39c4c335a0..587284b229 100644
--- a/packages/router-generator/package.json
+++ b/packages/router-generator/package.json
@@ -1,6 +1,6 @@
{
"name": "@tanstack/router-generator",
- "version": "1.131.27",
+ "version": "1.132.0-alpha.9",
"description": "Modern and scalable routing for React applications",
"author": "Tanner Linsley",
"license": "MIT",
diff --git a/packages/router-generator/src/generator.ts b/packages/router-generator/src/generator.ts
index 122976d417..1880d0adf3 100644
--- a/packages/router-generator/src/generator.ts
+++ b/packages/router-generator/src/generator.ts
@@ -1,6 +1,6 @@
import path from 'node:path'
import * as fsp from 'node:fs/promises'
-import { mkdirSync } from 'node:fs'
+import { existsSync, mkdirSync } from 'node:fs'
import crypto from 'node:crypto'
import { deepEqual, rootRouteId } from '@tanstack/router-core'
import { logging } from './logger'
@@ -194,7 +194,7 @@ export class Generator {
this.logger = logging({ disabled: this.config.disableLogging })
this.root = opts.root
this.fs = opts.fs || DefaultFileSystem
- this.generatedRouteTreePath = path.resolve(this.config.generatedRouteTree)
+ this.generatedRouteTreePath = this.getGeneratedRouteTreePath()
this.targetTemplate = getTargetTemplate(this.config)
this.routesDirectoryPath = this.getRoutesDirectoryPath()
@@ -212,6 +212,22 @@ export class Generator {
})
}
+ private getGeneratedRouteTreePath() {
+ const generatedRouteTreePath = path.isAbsolute(
+ this.config.generatedRouteTree,
+ )
+ ? this.config.generatedRouteTree
+ : path.resolve(this.root, this.config.generatedRouteTree)
+
+ const generatedRouteTreeDir = path.dirname(generatedRouteTreePath)
+
+ if (!existsSync(generatedRouteTreeDir)) {
+ mkdirSync(generatedRouteTreeDir, { recursive: true })
+ }
+
+ return generatedRouteTreePath
+ }
+
private getRoutesDirectoryPath() {
return path.isAbsolute(this.config.routesDirectory)
? this.config.routesDirectory
diff --git a/packages/router-generator/tests/generator.test.ts b/packages/router-generator/tests/generator.test.ts
index dbd5e49540..1c4d921f14 100644
--- a/packages/router-generator/tests/generator.test.ts
+++ b/packages/router-generator/tests/generator.test.ts
@@ -270,4 +270,56 @@ describe('generator works', async () => {
await postprocess(folderName)
},
)
+
+ it('should create directory for routeTree if it does not exist', async () => {
+ const folderName = 'only-root'
+ const folderRoot = makeFolderDir(folderName)
+ let pathCreated = false
+
+ const config = await setupConfig(folderName)
+
+ rewriteConfigByFolderName(folderName, config)
+
+ await preprocess(folderName)
+ config.generatedRouteTree = join(
+ folderRoot,
+ 'generated',
+ '/routeTree.gen.ts',
+ )
+ const generator = new Generator({ config, root: folderRoot })
+ const error = shouldThrow(folderName)
+ if (error) {
+ try {
+ await generator.run()
+ } catch (e) {
+ expect(e).toBeInstanceOf(Error)
+ expect((e as Error).message.startsWith(error)).toBeTruthy()
+ }
+ } else {
+ await generator.run()
+
+ const generatedRouteTree = await getRouteTreeFileText(config)
+
+ await expect(generatedRouteTree).toMatchFileSnapshot(
+ join(
+ 'generator',
+ folderName,
+ `routeTree.generated.snapshot.${config.disableTypes ? 'js' : 'ts'}`,
+ ),
+ )
+
+ pathCreated = await fs.access(dirname(config.generatedRouteTree)).then(
+ () => true,
+ () => false,
+ )
+
+ await expect(pathCreated).toBe(true)
+ }
+
+ await postprocess(folderName)
+
+ if (pathCreated) {
+ await fs.rm(dirname(config.generatedRouteTree), { recursive: true })
+ }
+ })
})
diff --git a/packages/router-generator/tests/generator/only-root/routeTree.generated.snapshot.ts b/packages/router-generator/tests/generator/only-root/routeTree.generated.snapshot.ts
new file mode 100644
index 0000000000..7766df9832
--- /dev/null
+++ b/packages/router-generator/tests/generator/only-root/routeTree.generated.snapshot.ts
@@ -0,0 +1,35 @@
+/* eslint-disable */
+
+// @ts-nocheck
+
+// noinspection JSUnusedGlobalSymbols
+
+// This file was automatically generated by TanStack Router.
+// You should NOT make any changes in this file as it will be overwritten.
+// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified.
+
+import { Route as rootRouteImport } from './../routes/__root'
+
+export interface FileRoutesByFullPath {}
+export interface FileRoutesByTo {}
+export interface FileRoutesById {
+ __root__: typeof rootRouteImport
+}
+export interface FileRouteTypes {
+ fileRoutesByFullPath: FileRoutesByFullPath
+ fullPaths: never
+ fileRoutesByTo: FileRoutesByTo
+ to: never
+ id: '__root__'
+ fileRoutesById: FileRoutesById
+}
+export interface RootRouteChildren {}
+
+declare module '@tanstack/react-router' {
+ interface FileRoutesByPath {}
+}
+
+const rootRouteChildren: RootRouteChildren = {}
+export const routeTree = rootRouteImport
+ ._addFileChildren(rootRouteChildren)
+ ._addFileTypes()
diff --git a/packages/router-plugin/package.json b/packages/router-plugin/package.json
index 33290cb717..37019b6dea 100644
--- a/packages/router-plugin/package.json
+++ b/packages/router-plugin/package.json
@@ -1,6 +1,6 @@
{
"name": "@tanstack/router-plugin",
- "version": "1.131.27",
+ "version": "1.132.0-alpha.9",
"description": "Modern and scalable routing for React applications",
"author": "Tanner Linsley",
"license": "MIT",
@@ -127,8 +127,8 @@
"peerDependencies": {
"@rsbuild/core": ">=1.0.2",
"@tanstack/react-router": "workspace:^",
- "vite": ">=5.0.0 || >=6.0.0",
- "vite-plugin-solid": "^2.11.2",
+ "vite": ">=5.0.0 || >=6.0.0 || >=7.0.0",
+ "vite-plugin-solid": "^2.11.8",
"webpack": ">=5.92.0"
},
"peerDependenciesMeta": {
diff --git a/packages/router-ssr-query-core/package.json b/packages/router-ssr-query-core/package.json
index 03b14ee5a3..54b6ebcab6 100644
--- a/packages/router-ssr-query-core/package.json
+++ b/packages/router-ssr-query-core/package.json
@@ -1,6 +1,6 @@
{
"name": "@tanstack/router-ssr-query-core",
- "version": "1.131.27",
+ "version": "1.132.0-alpha.8",
"description": "Modern and scalable routing for React applications",
"author": "Tanner Linsley",
"license": "MIT",
diff --git a/packages/router-utils/package.json b/packages/router-utils/package.json
index f1e872dc4e..f874a9ea44 100644
--- a/packages/router-utils/package.json
+++ b/packages/router-utils/package.json
@@ -1,6 +1,6 @@
{
"name": "@tanstack/router-utils",
- "version": "1.131.2",
+ "version": "1.132.0-alpha.9",
"description": "Modern and scalable routing for React applications",
"author": "Tanner Linsley",
"license": "MIT",
@@ -68,7 +68,9 @@
"@babel/parser": "^7.27.5",
"@babel/preset-typescript": "^7.27.1",
"ansis": "^4.1.0",
- "diff": "^8.0.2"
+ "diff": "^8.0.2",
+ "fast-glob": "^3.3.3",
+ "pathe": "^2.0.3"
},
"devDependencies": {
"@babel/types": "^7.27.6",
diff --git a/packages/router-utils/src/ast.ts b/packages/router-utils/src/ast.ts
index 829471ad97..812824a121 100644
--- a/packages/router-utils/src/ast.ts
+++ b/packages/router-utils/src/ast.ts
@@ -8,10 +8,8 @@ export type ParseAstOptions = ParserOptions & {
code: string
}
-export function parseAst({
- code,
- ...opts
-}: ParseAstOptions): ParseResult<_babel_types.File> {
+export type ParseAstResult = ParseResult<_babel_types.File>
+export function parseAst({ code, ...opts }: ParseAstOptions): ParseAstResult {
return parse(code, {
plugins: ['jsx', 'typescript', 'explicitResourceManagement'],
sourceType: 'module',
diff --git a/packages/router-utils/src/copy-files-plugin.ts b/packages/router-utils/src/copy-files-plugin.ts
new file mode 100644
index 0000000000..13cfd31ec4
--- /dev/null
+++ b/packages/router-utils/src/copy-files-plugin.ts
@@ -0,0 +1,34 @@
+import { copyFile, mkdir } from 'node:fs/promises'
+import { dirname, join } from 'pathe'
+import fg from 'fast-glob'
+import type { Plugin } from 'vite'
+
+export function copyFilesPlugin({
+ fromDir,
+ toDir,
+ pattern = '**',
+}: {
+ pattern?: string | Array
+ fromDir: string
+ toDir: string
+}): Plugin {
+ return {
+ name: 'copy-files',
+ async writeBundle() {
+ const entries = await fg(pattern, { cwd: fromDir })
+ if (entries.length === 0) {
+ throw new Error(
+ `No files found matching pattern "${pattern}" in directory "${fromDir}"`,
+ )
+ }
+
+ for (const entry of entries) {
+ const srcPath = join(fromDir, entry)
+ const destPath = join(toDir, entry)
+ // Ensure the destination directory exists
+ await mkdir(dirname(destPath), { recursive: true })
+ await copyFile(srcPath, destPath)
+ }
+ },
+ }
+}
diff --git a/packages/router-utils/src/index.ts b/packages/router-utils/src/index.ts
index f238e8c695..85c3f38590 100644
--- a/packages/router-utils/src/index.ts
+++ b/packages/router-utils/src/index.ts
@@ -1,3 +1,5 @@
export { parseAst, generateFromAst } from './ast'
-export type { ParseAstOptions, GeneratorResult } from './ast'
+export type { ParseAstOptions, ParseAstResult, GeneratorResult } from './ast'
export { logDiff } from './logger'
+
+export { copyFilesPlugin } from './copy-files-plugin'
diff --git a/packages/router-vite-plugin/package.json b/packages/router-vite-plugin/package.json
index 2827558b43..3f9bd0a855 100644
--- a/packages/router-vite-plugin/package.json
+++ b/packages/router-vite-plugin/package.json
@@ -1,6 +1,6 @@
{
"name": "@tanstack/router-vite-plugin",
- "version": "1.131.27",
+ "version": "1.132.0-alpha.9",
"description": "Modern and scalable routing for React applications",
"author": "Tanner Linsley",
"license": "MIT",
diff --git a/packages/server-functions-plugin/package.json b/packages/server-functions-plugin/package.json
index dc5876d26f..9502c6d66c 100644
--- a/packages/server-functions-plugin/package.json
+++ b/packages/server-functions-plugin/package.json
@@ -1,6 +1,6 @@
{
"name": "@tanstack/server-functions-plugin",
- "version": "1.131.2",
+ "version": "1.132.0-alpha.9",
"description": "Modern and scalable routing for React applications",
"author": "Tanner Linsley",
"license": "MIT",
diff --git a/packages/server-functions-plugin/src/index.ts b/packages/server-functions-plugin/src/index.ts
index 8a396252ed..710fe0b2ba 100644
--- a/packages/server-functions-plugin/src/index.ts
+++ b/packages/server-functions-plugin/src/index.ts
@@ -8,11 +8,7 @@ import type {
ReplacerFn,
} from '@tanstack/directive-functions-plugin'
-export type CreateRpcFn = (
- functionId: string,
- serverBase: string,
- splitImportFn?: string,
-) => any
+export type CreateRpcFn = (functionId: string, splitImportFn?: string) => any
export type ServerFnPluginOpts = {
/**
diff --git a/packages/solid-router-devtools/package.json b/packages/solid-router-devtools/package.json
index 4cb71c7e53..422c5560c7 100644
--- a/packages/solid-router-devtools/package.json
+++ b/packages/solid-router-devtools/package.json
@@ -1,6 +1,6 @@
{
"name": "@tanstack/solid-router-devtools",
- "version": "1.131.27",
+ "version": "1.132.0-alpha.8",
"description": "Modern and scalable routing for Solid applications",
"author": "Tanner Linsley",
"license": "MIT",
@@ -70,7 +70,7 @@
},
"devDependencies": {
"solid-js": "^1.9.5",
- "vite-plugin-solid": "^2.11.6"
+ "vite-plugin-solid": "^2.11.8"
},
"peerDependencies": {
"solid-js": "^1.9.5",
diff --git a/packages/solid-router/package.json b/packages/solid-router/package.json
index b8664d1cb5..82c169a60c 100644
--- a/packages/solid-router/package.json
+++ b/packages/solid-router/package.json
@@ -1,6 +1,6 @@
{
"name": "@tanstack/solid-router",
- "version": "1.131.27",
+ "version": "1.132.0-alpha.8",
"description": "Modern and scalable routing for Solid applications",
"author": "Tanner Linsley",
"license": "MIT",
@@ -114,7 +114,7 @@
"combinate": "^1.1.11",
"eslint-plugin-solid": "^0.14.5",
"solid-js": "^1.9.5",
- "vite-plugin-solid": "^2.11.2",
+ "vite-plugin-solid": "^2.11.8",
"zod": "^3.23.8"
},
"peerDependencies": {
diff --git a/packages/solid-router/src/ScriptOnce.tsx b/packages/solid-router/src/ScriptOnce.tsx
index 7799f56a8c..681f5fd3cb 100644
--- a/packages/solid-router/src/ScriptOnce.tsx
+++ b/packages/solid-router/src/ScriptOnce.tsx
@@ -11,8 +11,8 @@ export function ScriptOnce({
return (
)
}
diff --git a/packages/solid-router/src/fileRoute.ts b/packages/solid-router/src/fileRoute.ts
index 427416d193..8c869d9cf5 100644
--- a/packages/solid-router/src/fileRoute.ts
+++ b/packages/solid-router/src/fileRoute.ts
@@ -20,6 +20,7 @@ import type {
FileBaseRouteOptions,
FileRoutesByPath,
LazyRouteOptions,
+ Register,
RegisteredRouter,
ResolveParams,
Route,
@@ -76,6 +77,7 @@ export class FileRoute<
}
createRoute = <
+ TRegister extends Register = Register,
TSearchValidator = undefined,
TParams = ResolveParams,
TRouteContextFn = AnyContext,
@@ -83,8 +85,10 @@ export class FileRoute<
TLoaderDeps extends Record = {},
TLoaderFn = undefined,
TChildren = unknown,
+ TSSR = unknown,
>(
options?: FileBaseRouteOptions<
+ TRegister,
TParentRoute,
TId,
TPath,
@@ -94,7 +98,9 @@ export class FileRoute<
TLoaderFn,
AnyContext,
TRouteContextFn,
- TBeforeLoadFn
+ TBeforeLoadFn,
+ AnyContext,
+ TSSR
> &
UpdatableRouteOptions<
TParentRoute,
@@ -109,6 +115,7 @@ export class FileRoute<
TBeforeLoadFn
>,
): Route<
+ TRegister,
TParentRoute,
TPath,
TFullPath,
@@ -122,7 +129,8 @@ export class FileRoute<
TLoaderDeps,
TLoaderFn,
TChildren,
- unknown
+ unknown,
+ TSSR
> => {
warning(
this.silent,
diff --git a/packages/solid-router/src/index.tsx b/packages/solid-router/src/index.tsx
index 2aecb0504d..91d92623c7 100644
--- a/packages/solid-router/src/index.tsx
+++ b/packages/solid-router/src/index.tsx
@@ -1,6 +1,3 @@
-export { default as invariant } from 'tiny-invariant'
-export { default as warning } from 'tiny-warning'
-
export {
defer,
TSR_DEFERRED_PROMISE,
@@ -22,16 +19,15 @@ export {
defaultStringifySearch,
parseSearchWith,
stringifySearchWith,
- escapeJSON, // SSR
functionalUpdate,
replaceEqualDeep,
isPlainObject,
isPlainArray,
deepEqual,
- shallow,
createControlledPromise,
retainSearchParams,
stripSearchParams,
+ createSerializationAdapter,
} from '@tanstack/router-core'
export type {
@@ -194,6 +190,8 @@ export type {
InjectedHtmlEntry,
CreateFileRoute,
CreateLazyFileRoute,
+ AnySerializationAdapter,
+ SerializationAdapter,
} from '@tanstack/router-core'
export {
diff --git a/packages/solid-router/src/link.tsx b/packages/solid-router/src/link.tsx
index 008483ac0d..00c0c10997 100644
--- a/packages/solid-router/src/link.tsx
+++ b/packages/solid-router/src/link.tsx
@@ -15,7 +15,7 @@ import { useRouter } from './useRouter'
import { useIntersectionObserver } from './utils'
-import { useMatch } from './useMatch'
+import { useActiveLocation } from './useActiveLocation'
import type {
AnyRouter,
Constrain,
@@ -133,20 +133,20 @@ export function useLinkProps<
select: (s) => s.location.searchStr,
})
- // when `from` is not supplied, use the route of the current match as the `from` location
- // so relative routing works as expected
- const from = useMatch({
- strict: false,
- select: (match) => options.from ?? match.fullPath,
- })
+ const { getFromPath, activeLocation } = useActiveLocation()
- const _options = () => ({
- ...options,
- from: from(),
- })
+ const from = getFromPath(options.from)
+
+ const _options = () => {
+ return {
+ ...options,
+ from: from(),
+ }
+ }
const next = Solid.createMemo(() => {
currentSearch()
+ activeLocation()
return router.buildLocation(_options() as any)
})
diff --git a/packages/solid-router/src/route.tsx b/packages/solid-router/src/route.tsx
index bab412bea6..6863056a68 100644
--- a/packages/solid-router/src/route.tsx
+++ b/packages/solid-router/src/route.tsx
@@ -20,6 +20,7 @@ import type {
ErrorComponentProps,
NotFoundError,
NotFoundRouteProps,
+ Register,
RegisteredRouter,
ResolveFullPath,
ResolveId,
@@ -152,6 +153,7 @@ export class RouteApi<
}
export class Route<
+ in out TRegister extends Register = Register,
in out TParentRoute extends RouteConstraints['TParentRoute'] = AnyRoute,
in out TPath extends RouteConstraints['TPath'] = '/',
in out TFullPath extends RouteConstraints['TFullPath'] = ResolveFullPath<
@@ -173,8 +175,10 @@ export class Route<
in out TLoaderFn = undefined,
in out TChildren = unknown,
in out TFileRouteTypes = unknown,
+ in out TSSR = unknown,
>
extends BaseRoute<
+ TRegister,
TParentRoute,
TPath,
TFullPath,
@@ -188,10 +192,12 @@ export class Route<
TLoaderDeps,
TLoaderFn,
TChildren,
- TFileRouteTypes
+ TFileRouteTypes,
+ TSSR
>
implements
RouteCore<
+ TRegister,
TParentRoute,
TPath,
TFullPath,
@@ -205,7 +211,8 @@ export class Route<
TLoaderDeps,
TLoaderFn,
TChildren,
- TFileRouteTypes
+ TFileRouteTypes,
+ TSSR
>
{
/**
@@ -213,6 +220,7 @@ export class Route<
*/
constructor(
options?: RouteOptions<
+ TRegister,
TParentRoute,
TId,
TCustomId,
@@ -224,7 +232,8 @@ export class Route<
TLoaderFn,
TRouterContext,
TRouteContextFn,
- TBeforeLoadFn
+ TBeforeLoadFn,
+ TSSR
>,
) {
super(options)
@@ -277,6 +286,7 @@ export class Route<
}
export function createRoute<
+ TRegister extends Register = Register,
TParentRoute extends RouteConstraints['TParentRoute'] = AnyRoute,
TPath extends RouteConstraints['TPath'] = '/',
TFullPath extends RouteConstraints['TFullPath'] = ResolveFullPath<
@@ -296,8 +306,10 @@ export function createRoute<
TLoaderDeps extends Record = {},
TLoaderFn = undefined,
TChildren = unknown,
+ TSSR = unknown,
>(
options: RouteOptions<
+ TRegister,
TParentRoute,
TId,
TCustomId,
@@ -309,9 +321,11 @@ export function createRoute<
TLoaderFn,
AnyContext,
TRouteContextFn,
- TBeforeLoadFn
+ TBeforeLoadFn,
+ TSSR
>,
): Route<
+ TRegister,
TParentRoute,
TPath,
TFullPath,
@@ -325,9 +339,11 @@ export function createRoute<
TLoaderDeps,
TLoaderFn,
TChildren,
- unknown
+ unknown,
+ TSSR
> {
return new Route<
+ TRegister,
TParentRoute,
TPath,
TFullPath,
@@ -341,36 +357,54 @@ export function createRoute<
TLoaderDeps,
TLoaderFn,
TChildren,
- unknown
+ unknown,
+ TSSR
>(options)
}
-export type AnyRootRoute = RootRoute
+export type AnyRootRoute = RootRoute<
+ any,
+ any,
+ any,
+ any,
+ any,
+ any,
+ any,
+ any,
+ any,
+ any
+>
export function createRootRouteWithContext() {
return <
+ TRegister extends Register = Register,
TRouteContextFn = AnyContext,
TBeforeLoadFn = AnyContext,
TSearchValidator = undefined,
TLoaderDeps extends Record = {},
TLoaderFn = undefined,
+ TSSR = unknown,
>(
options?: RootRouteOptions<
+ TRegister,
TSearchValidator,
TRouterContext,
TRouteContextFn,
TBeforeLoadFn,
TLoaderDeps,
- TLoaderFn
+ TLoaderFn,
+ TSSR
>,
) => {
return createRootRoute<
+ TRegister,
TSearchValidator,
TRouterContext,
TRouteContextFn,
TBeforeLoadFn,
TLoaderDeps,
- TLoaderFn
+ TLoaderFn,
+ TSSR
>(options as any)
}
}
@@ -381,6 +415,7 @@ export function createRootRouteWithContext() {
export const rootRouteWithContext = createRootRouteWithContext
export class RootRoute<
+ in out TRegister extends Register = Register,
in out TSearchValidator = undefined,
in out TRouterContext = {},
in out TRouteContextFn = AnyContext,
@@ -389,8 +424,10 @@ export class RootRoute<
in out TLoaderFn = undefined,
in out TChildren = unknown,
in out TFileRouteTypes = unknown,
+ in out TSSR = unknown,
>
extends BaseRootRoute<
+ TRegister,
TSearchValidator,
TRouterContext,
TRouteContextFn,
@@ -398,10 +435,12 @@ export class RootRoute<
TLoaderDeps,
TLoaderFn,
TChildren,
- TFileRouteTypes
+ TFileRouteTypes,
+ TSSR
>
implements
RootRouteCore<
+ TRegister,
TSearchValidator,
TRouterContext,
TRouteContextFn,
@@ -409,7 +448,8 @@ export class RootRoute<
TLoaderDeps,
TLoaderFn,
TChildren,
- TFileRouteTypes
+ TFileRouteTypes,
+ TSSR
>
{
/**
@@ -417,12 +457,14 @@ export class RootRoute<
*/
constructor(
options?: RootRouteOptions<
+ TRegister,
TSearchValidator,
TRouterContext,
TRouteContextFn,
TBeforeLoadFn,
TLoaderDeps,
- TLoaderFn
+ TLoaderFn,
+ TSSR
>,
) {
super(options)
@@ -504,6 +546,7 @@ export type ErrorRouteComponent = AsyncRouteComponent
export type NotFoundRouteComponent = RouteTypes['component']
export class NotFoundRoute<
+ TRegister extends Register,
TParentRoute extends AnyRootRoute,
TRouterContext = AnyContext,
TRouteContextFn = AnyContext,
@@ -512,7 +555,9 @@ export class NotFoundRoute<
TLoaderDeps extends Record = {},
TLoaderFn = undefined,
TChildren = unknown,
+ TSSR = unknown,
> extends Route<
+ TRegister,
TParentRoute,
'/404',
'/404',
@@ -525,11 +570,13 @@ export class NotFoundRoute<
TBeforeLoadFn,
TLoaderDeps,
TLoaderFn,
- TChildren
+ TChildren,
+ TSSR
> {
constructor(
options: Omit<
RouteOptions<
+ TRegister,
TParentRoute,
string,
string,
@@ -541,7 +588,8 @@ export class NotFoundRoute<
TLoaderFn,
TRouterContext,
TRouteContextFn,
- TBeforeLoadFn
+ TBeforeLoadFn,
+ TSSR
>,
| 'caseSensitive'
| 'parseParams'
@@ -559,22 +607,27 @@ export class NotFoundRoute<
}
export function createRootRoute<
+ TRegister extends Register = Register,
TSearchValidator = undefined,
TRouterContext = {},
TRouteContextFn = AnyContext,
TBeforeLoadFn = AnyContext,
TLoaderDeps extends Record = {},
TLoaderFn = undefined,
+ TSSR = unknown,
>(
options?: RootRouteOptions<
+ TRegister,
TSearchValidator,
TRouterContext,
TRouteContextFn,
TBeforeLoadFn,
TLoaderDeps,
- TLoaderFn
+ TLoaderFn,
+ TSSR
>,
): RootRoute<
+ TRegister,
TSearchValidator,
TRouterContext,
TRouteContextFn,
@@ -582,14 +635,19 @@ export function createRootRoute<
TLoaderDeps,
TLoaderFn,
unknown,
- unknown
+ unknown,
+ TSSR
> {
return new RootRoute<
+ TRegister,
TSearchValidator,
TRouterContext,
TRouteContextFn,
TBeforeLoadFn,
TLoaderDeps,
- TLoaderFn
+ TLoaderFn,
+ unknown,
+ unknown,
+ TSSR
>(options)
}
diff --git a/packages/solid-router/src/scroll-restoration.tsx b/packages/solid-router/src/scroll-restoration.tsx
index 1a8bdd9f7a..3527a2db37 100644
--- a/packages/solid-router/src/scroll-restoration.tsx
+++ b/packages/solid-router/src/scroll-restoration.tsx
@@ -8,6 +8,17 @@ import { ScriptOnce } from './ScriptOnce'
export function ScrollRestoration() {
const router = useRouter()
+ if (!router.isScrollRestoring || !router.isServer) {
+ return null
+ }
+ if (typeof router.options.scrollRestoration === 'function') {
+ const shouldRestore = router.options.scrollRestoration({
+ location: router.latestLocation,
+ })
+ if (!shouldRestore) {
+ return null
+ }
+ }
const getKey =
router.options.getScrollRestorationKey || defaultGetScrollRestorationKey
const userKey = getKey(router.latestLocation)
@@ -16,10 +27,6 @@ export function ScrollRestoration() {
? userKey
: undefined
- if (!router.isScrollRestoring || !router.isServer) {
- return null
- }
-
const restoreScrollOptions: Parameters[0] = {
storageKey,
shouldScrollRestoration: true,
diff --git a/packages/solid-router/src/useActiveLocation.ts b/packages/solid-router/src/useActiveLocation.ts
new file mode 100644
index 0000000000..268af7296d
--- /dev/null
+++ b/packages/solid-router/src/useActiveLocation.ts
@@ -0,0 +1,61 @@
+import { last } from '@tanstack/router-core'
+import { createEffect, createMemo, createSignal } from 'solid-js'
+import { useMatch } from './useMatch'
+import { useRouter } from './useRouter'
+import { useRouterState } from './useRouterState'
+import type { Accessor } from 'solid-js'
+import type { ParsedLocation } from '@tanstack/router-core'
+
+export type UseLocationResult = {
+ activeLocation: Accessor
+ getFromPath: (from?: string) => Accessor
+ setActiveLocation: (location?: ParsedLocation) => void
+}
+
+export function useActiveLocation(
+ location?: ParsedLocation,
+): UseLocationResult {
+ const router = useRouter()
+ // we are not using a variable here for router state location since we need to only calculate that if the location is not passed in. It can result in unnecessary history actions if we do that.
+ const [activeLocation, setActiveLocation] = createSignal(
+ location ?? useRouterState({ select: (s) => s.location })(),
+ )
+ const [customActiveLocation, setCustomActiveLocation] = createSignal<
+ ParsedLocation | undefined
+ >(location)
+
+ createEffect(() => {
+ setActiveLocation(
+ customActiveLocation() ?? useRouterState({ select: (s) => s.location })(),
+ )
+ })
+
+ const matchIndex = useMatch({
+ strict: false,
+ select: (match) => match.index,
+ })
+
+ const getFromPath = (from?: string) =>
+ createMemo(() => {
+ const activeLocationMatches = router.matchRoutes(
+ customActiveLocation() ?? activeLocation(),
+ {
+ _buildLocation: false,
+ },
+ )
+
+ const activeLocationMatch = last(activeLocationMatches)
+
+ return (
+ from ??
+ activeLocationMatch?.fullPath ??
+ router.state.matches[matchIndex()]!.fullPath
+ )
+ })
+
+ return {
+ activeLocation,
+ getFromPath,
+ setActiveLocation: setCustomActiveLocation,
+ }
+}
diff --git a/packages/solid-router/src/useNavigate.tsx b/packages/solid-router/src/useNavigate.tsx
index 96d1207533..0a7f743753 100644
--- a/packages/solid-router/src/useNavigate.tsx
+++ b/packages/solid-router/src/useNavigate.tsx
@@ -1,6 +1,6 @@
import * as Solid from 'solid-js'
import { useRouter } from './useRouter'
-import { useMatch } from './useMatch'
+import { useActiveLocation } from './useActiveLocation'
import type {
AnyRouter,
FromPathOption,
@@ -15,20 +15,19 @@ export function useNavigate<
>(_defaultOpts?: {
from?: FromPathOption
}): UseNavigateResult {
- const { navigate, state } = useRouter()
+ const router = useRouter()
- const matchIndex = useMatch({
- strict: false,
- select: (match) => match.index,
- })
+ const { getFromPath, setActiveLocation } = useActiveLocation(
+ router.latestLocation,
+ )
return ((options: NavigateOptions) => {
- return navigate({
+ setActiveLocation(router.latestLocation)
+ const from = getFromPath(options.from ?? _defaultOpts?.from)
+
+ return router.navigate({
...options,
- from:
- options.from ??
- _defaultOpts?.from ??
- state.matches[matchIndex()]!.fullPath,
+ from: from(),
})
}) as UseNavigateResult
}
diff --git a/packages/solid-router/tests/link.test.tsx b/packages/solid-router/tests/link.test.tsx
index 9eba08fd09..f12dd5b416 100644
--- a/packages/solid-router/tests/link.test.tsx
+++ b/packages/solid-router/tests/link.test.tsx
@@ -3935,6 +3935,7 @@ describe('Link', () => {
})
const postRoute = createRoute({
+ ssr: false,
getParentRoute: () => rootRoute,
path: '/posts',
loader: () => sleep(WAIT_TIME),
@@ -4636,7 +4637,9 @@ describe.each([{ basepath: '' }, { basepath: '/basepath' }])(
return (
<>
Param Route
- Link to ./a
+
+ Link to ./a
+
Link to c
@@ -4656,7 +4659,12 @@ describe.each([{ basepath: '' }, { basepath: '/basepath' }])(
return (
<>
Param A Route
- Link to .. from /param/foo/a
+
+ Link to .. from /param/foo/a
+
+
+ Link to .. from current active route
+
>
)
@@ -4833,6 +4841,25 @@ describe.each([{ basepath: '' }, { basepath: '/basepath' }])(
)
})
+ test('should navigate to a parent link based on active location', async () => {
+ const router = setupRouter()
+
+ render(() => )
+
+ window.history.replaceState(null, 'root', `${basepath}/param/foo/a/b`)
+
+ const relativeLink = await screen.findByTestId('link-to-previous')
+
+ expect(relativeLink.getAttribute('href')).toBe(`${basepath}/param/foo/a`)
+
+ // Click the link and ensure the new location
+ fireEvent.click(relativeLink)
+
+ await waitFor(() =>
+ expect(window.location.pathname).toBe(`${basepath}/param/foo/a`),
+ )
+ })
+
test('should navigate to a child link based on pathname', async () => {
const router = setupRouter()
@@ -4937,9 +4964,600 @@ describe.each([{ basepath: '' }, { basepath: '/basepath' }])(
fireEvent.click(parentLink)
- waitFor(() =>
+ await waitFor(() =>
expect(window.location.pathname).toBe(`${basepath}/param/bar/a/b`),
)
})
},
)
+
+describe('relative links to current route', () => {
+ test.each([true, false])(
+ 'should navigate to current route when using "." in nested route structure from Index Route with trailingSlash: %s',
+ async (trailingSlash: boolean) => {
+ const tail = trailingSlash ? '/' : ''
+
+ const rootRoute = createRootRoute()
+
+ const IndexComponent = () => {
+ return (
+ <>
+
+ Post
+
+
+ Search
+
+
+ Search2
+
+
+ >
+ )
+ }
+
+ const indexRoute = createRoute({
+ getParentRoute: () => rootRoute,
+ path: '/',
+ component: IndexComponent,
+ validateSearch: z.object({
+ param1: z.string().optional(),
+ }),
+ })
+
+ const postRoute = createRoute({
+ getParentRoute: () => indexRoute,
+ path: 'post',
+ component: () => (
+ <>
+ Post
+ >
+ ),
+ })
+
+ const router = createRouter({
+ routeTree: rootRoute.addChildren([indexRoute, postRoute]),
+ history,
+ trailingSlash: trailingSlash ? 'always' : 'never',
+ })
+
+ render(() => )
+
+ const postButton = await screen.findByTestId('posts-link')
+ const searchButton = await screen.findByTestId('search-link')
+ const searchButton2 = await screen.findByTestId('search2-link')
+
+ fireEvent.click(postButton)
+
+ await waitFor(() => {
+ expect(window.location.pathname).toBe(`/post${tail}`)
+ })
+
+ fireEvent.click(searchButton)
+
+ await waitFor(() => {
+ expect(router.state.location.pathname).toBe(`/post${tail}`)
+ expect(router.state.location.search).toEqual({ param1: 'value1' })
+ })
+
+ fireEvent.click(searchButton2)
+
+ await waitFor(() => {
+ expect(router.state.location.pathname).toBe(`/post${tail}`)
+ expect(router.state.location.search).toEqual({ param1: 'value2' })
+ })
+ },
+ )
+
+ test.each([true, false])(
+ 'should navigate to current route with search params when using "." in nested route structure from Index Route with trailingSlash: %s',
+ async (trailingSlash: boolean) => {
+ const tail = trailingSlash ? '/' : ''
+
+ const rootRoute = createRootRoute()
+
+ const IndexComponent = () => {
+ return (
+ <>
+
+ Post
+
+
+ Search
+
+
+ Search2
+
+
+ >
+ )
+ }
+
+ const indexRoute = createRoute({
+ getParentRoute: () => rootRoute,
+ path: '/',
+ component: IndexComponent,
+ validateSearch: z.object({
+ param1: z.string().optional(),
+ }),
+ })
+
+ const postRoute = createRoute({
+ getParentRoute: () => indexRoute,
+ path: 'post',
+ component: () => Post
,
+ })
+
+ const router = createRouter({
+ routeTree: rootRoute.addChildren([indexRoute, postRoute]),
+ history,
+ trailingSlash: trailingSlash ? 'always' : 'never',
+ })
+
+ render(() => )
+
+ const postButton = await screen.findByTestId('posts-link')
+
+ fireEvent.click(postButton)
+
+ await waitFor(() => {
+ expect(window.location.pathname).toBe(`/post${tail}`)
+ })
+
+ const searchButton = await screen.findByTestId('search-link')
+
+ fireEvent.click(searchButton)
+
+ await waitFor(() => {
+ expect(router.state.location.pathname).toBe(`/post${tail}`)
+ expect(router.state.location.search).toEqual({ param1: 'value1' })
+ })
+
+ const searchButton2 = await screen.findByTestId('search2-link')
+
+ fireEvent.click(searchButton2)
+
+ await waitFor(() => {
+ expect(router.state.location.pathname).toBe(`/post${tail}`)
+ expect(router.state.location.search).toEqual({ param1: 'value2' })
+ })
+ },
+ )
+
+ test.each([true, false])(
+ 'should navigate to current route with changing path params when using "." in nested route structure with trailingSlash: %s',
+ async (trailingSlash) => {
+ const tail = trailingSlash ? '/' : ''
+ const rootRoute = createRootRoute()
+
+ const IndexComponent = () => {
+ return (
+ <>
+ Index
+
+ Posts
+
+ >
+ )
+ }
+
+ const indexRoute = createRoute({
+ getParentRoute: () => rootRoute,
+ path: '/',
+ component: IndexComponent,
+ })
+
+ const layoutRoute = createRoute({
+ getParentRoute: () => rootRoute,
+ id: '_layout',
+ component: () => {
+ return (
+ <>
+ Layout
+
+ >
+ )
+ },
+ })
+
+ const PostsComponent = () => {
+ return (
+ <>
+ Posts
+
+ To first post
+
+
+ To second post
+
+
+ >
+ )
+ }
+
+ const postsRoute = createRoute({
+ getParentRoute: () => layoutRoute,
+ path: 'posts',
+ component: PostsComponent,
+ })
+
+ const PostComponent = () => {
+ const params = useParams({ strict: false })
+ return (
+ <>
+
+ Params: {params().postId}
+
+ >
+ )
+ }
+
+ const postRoute = createRoute({
+ getParentRoute: () => postsRoute,
+ path: '$postId',
+ component: PostComponent,
+ })
+
+ const router = createRouter({
+ routeTree: rootRoute.addChildren([
+ indexRoute,
+ layoutRoute.addChildren([postsRoute.addChildren([postRoute])]),
+ ]),
+ trailingSlash: trailingSlash ? 'always' : 'never',
+ })
+
+ render(() => )
+
+ const postsButton = await screen.findByTestId('posts-link')
+
+ fireEvent.click(postsButton)
+
+ await waitFor(() => {
+ expect(window.location.pathname).toEqual(`/posts${tail}`)
+ })
+
+ const firstPostButton = await screen.findByTestId('first-post-link')
+
+ fireEvent.click(firstPostButton)
+
+ await waitFor(() => {
+ expect(window.location.pathname).toEqual(`/posts/id1${tail}`)
+ })
+
+ const secondPostButton = await screen.findByTestId('second-post-link')
+
+ fireEvent.click(secondPostButton)
+
+ await waitFor(() => {
+ expect(window.location.pathname).toEqual(`/posts/id2${tail}`)
+ })
+ },
+ )
+})
+
+describe('relative links to from route', () => {
+ test.each([true, false])(
+ 'should navigate to from route when using "." in nested route structure from Index Route with trailingSlash: %s',
+ async (trailingSlash: boolean) => {
+ const tail = trailingSlash ? '/' : ''
+
+ const rootRoute = createRootRoute()
+
+ const IndexComponent = () => {
+ return (
+ <>
+
+ Post
+
+
+ Search
+
+
+ Go To Home
+
+
+ >
+ )
+ }
+
+ const indexRoute = createRoute({
+ getParentRoute: () => rootRoute,
+ path: '/',
+ component: IndexComponent,
+ validateSearch: z.object({
+ param1: z.string().optional(),
+ }),
+ })
+
+ const postRoute = createRoute({
+ getParentRoute: () => indexRoute,
+ path: 'post',
+ component: () => Post
,
+ })
+
+ const router = createRouter({
+ routeTree: rootRoute.addChildren([indexRoute, postRoute]),
+ history,
+ trailingSlash: trailingSlash ? 'always' : 'never',
+ })
+
+ render(() => )
+
+ const postButton = await screen.findByTestId('posts-link')
+
+ fireEvent.click(postButton)
+
+ await waitFor(() => {
+ expect(router.state.location.pathname).toBe(`/post${tail}`)
+ })
+
+ const searchButton = await screen.findByTestId('search-link')
+
+ fireEvent.click(searchButton)
+
+ await waitFor(() => {
+ expect(router.state.location.pathname).toBe(`/post${tail}`)
+ expect(router.state.location.search).toEqual({ param1: 'value1' })
+ })
+
+ const homeBtn = await screen.findByTestId('home-link')
+
+ fireEvent.click(homeBtn)
+
+ await waitFor(() => {
+ expect(router.state.location.pathname).toBe(`/`)
+ expect(router.state.location.search).toEqual({})
+ })
+ },
+ )
+
+ test.each([true, false])(
+ 'should navigate to from route with path params when using "." in nested route structure with trailingSlash: %s',
+ async (trailingSlash) => {
+ const tail = trailingSlash ? '/' : ''
+ const rootRoute = createRootRoute()
+
+ const IndexComponent = () => {
+ return (
+ <>
+ Index
+
+ Posts
+
+ >
+ )
+ }
+
+ const indexRoute = createRoute({
+ getParentRoute: () => rootRoute,
+ path: '/',
+ component: IndexComponent,
+ })
+
+ const layoutRoute = createRoute({
+ getParentRoute: () => rootRoute,
+ id: '_layout',
+ component: () => {
+ return (
+ <>
+ Layout
+
+ >
+ )
+ },
+ })
+
+ const PostsComponent = () => {
+ return (
+ <>
+ Posts
+
+ To first post
+
+
+ To second post
+
+
+ To posts list
+
+
+ >
+ )
+ }
+
+ const PostDetailComponent = () => {
+ return (
+ <>
+ Post Detail
+
+ To post info
+
+
+ To post notes
+
+
+ To index detail options
+
+
+ >
+ )
+ }
+
+ const PostInfoComponent = () => {
+ return (
+ <>
+ Post Info
+ >
+ )
+ }
+
+ const PostNotesComponent = () => {
+ return (
+ <>
+ Post Notes
+ >
+ )
+ }
+
+ const postsRoute = createRoute({
+ getParentRoute: () => layoutRoute,
+ path: 'posts',
+ component: PostsComponent,
+ })
+
+ const postDetailRoute = createRoute({
+ getParentRoute: () => postsRoute,
+ path: '$postId',
+ component: PostDetailComponent,
+ })
+
+ const postInfoRoute = createRoute({
+ getParentRoute: () => postDetailRoute,
+ path: 'info',
+ component: PostInfoComponent,
+ })
+
+ const postNotesRoute = createRoute({
+ getParentRoute: () => postDetailRoute,
+ path: 'notes',
+ component: PostNotesComponent,
+ })
+
+ const router = createRouter({
+ routeTree: rootRoute.addChildren([
+ indexRoute,
+ layoutRoute.addChildren([
+ postsRoute.addChildren([
+ postDetailRoute.addChildren([postInfoRoute, postNotesRoute]),
+ ]),
+ ]),
+ ]),
+ trailingSlash: trailingSlash ? 'always' : 'never',
+ })
+
+ render(() => )
+
+ const postsButton = await screen.findByTestId('posts-link')
+
+ fireEvent.click(postsButton)
+
+ await waitFor(() => {
+ expect(screen.queryByTestId('posts-index-heading')).toBeInTheDocument()
+ expect(window.location.pathname).toEqual(`/posts${tail}`)
+ })
+
+ const firstPostButton = await screen.findByTestId('first-post-link')
+
+ fireEvent.click(firstPostButton)
+
+ await waitFor(() => {
+ expect(
+ screen.queryByTestId('post-detail-index-heading'),
+ ).toBeInTheDocument()
+ expect(window.location.pathname).toEqual(`/posts/1${tail}`)
+ })
+
+ const postInfoButton = await screen.findByTestId('post-info-link')
+
+ fireEvent.click(postInfoButton)
+
+ await waitFor(() => {
+ expect(screen.queryByTestId('post-info-heading')).toBeInTheDocument()
+ expect(window.location.pathname).toEqual(`/posts/1/info${tail}`)
+ })
+
+ const toPostDetailIndexButton = await screen.findByTestId(
+ 'to-post-detail-index-link',
+ )
+
+ fireEvent.click(toPostDetailIndexButton)
+
+ await waitFor(() => {
+ expect(
+ screen.queryByTestId('post-detail-index-heading'),
+ ).toBeInTheDocument()
+ expect(
+ screen.queryByTestId('post-info-heading'),
+ ).not.toBeInTheDocument()
+ expect(window.location.pathname).toEqual(`/posts/1${tail}`)
+ })
+
+ const postNotesButton = await screen.findByTestId('post-notes-link')
+
+ fireEvent.click(postNotesButton)
+
+ await waitFor(() => {
+ expect(screen.queryByTestId('post-notes-heading')).toBeInTheDocument()
+ expect(window.location.pathname).toEqual(`/posts/1/notes${tail}`)
+ })
+
+ const toPostsIndexButton = await screen.findByTestId(
+ 'to-posts-index-link',
+ )
+
+ fireEvent.click(toPostsIndexButton)
+
+ await waitFor(() => {
+ expect(screen.queryByTestId('posts-index-heading')).toBeInTheDocument()
+ expect(
+ screen.queryByTestId('post-notes-heading'),
+ ).not.toBeInTheDocument()
+ expect(
+ screen.queryByTestId('post-detail-index-heading'),
+ ).not.toBeInTheDocument()
+ expect(window.location.pathname).toEqual(`/posts${tail}`)
+ })
+
+ const secondPostButton = await screen.findByTestId('second-post-link')
+
+ fireEvent.click(secondPostButton)
+
+ await waitFor(() => {
+ expect(
+ screen.queryByTestId('post-detail-index-heading'),
+ ).toBeInTheDocument()
+ expect(window.location.pathname).toEqual(`/posts/2${tail}`)
+ })
+ },
+ )
+})
diff --git a/packages/solid-router/tests/redirect.test.tsx b/packages/solid-router/tests/redirect.test.tsx
index 5301ed6a5f..d30265d70a 100644
--- a/packages/solid-router/tests/redirect.test.tsx
+++ b/packages/solid-router/tests/redirect.test.tsx
@@ -2,6 +2,7 @@ import { cleanup, fireEvent, render, screen } from '@solidjs/testing-library'
import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest'
+import invariant from 'tiny-invariant'
import {
Link,
RouterProvider,
@@ -10,7 +11,6 @@ import {
createRootRoute,
createRoute,
createRouter,
- invariant,
redirect,
useRouter,
} from '../src'
diff --git a/packages/solid-router/tests/routeContext.test.tsx b/packages/solid-router/tests/routeContext.test.tsx
index 5c5d3c9bb5..b83022f7dc 100644
--- a/packages/solid-router/tests/routeContext.test.tsx
+++ b/packages/solid-router/tests/routeContext.test.tsx
@@ -1590,6 +1590,7 @@ describe('loader in the route definition', () => {
path: '/',
})
const aboutRoute = createRoute({
+ ssr: false,
getParentRoute: () => rootRoute,
path: '/about',
beforeLoad: async () => {
@@ -1641,6 +1642,7 @@ describe('loader in the route definition', () => {
},
})
const aboutRoute = createRoute({
+ ssr: false,
getParentRoute: () => rootRoute,
path: '/about',
beforeLoad: async () => {
diff --git a/packages/solid-router/tests/router.test.tsx b/packages/solid-router/tests/router.test.tsx
index 5e89292bb3..eca4576e69 100644
--- a/packages/solid-router/tests/router.test.tsx
+++ b/packages/solid-router/tests/router.test.tsx
@@ -47,7 +47,9 @@ export function validateSearchParams<
expect(router.state.location.search).toEqual(expected)
}
-function createTestRouter(options?: RouterOptions) {
+function createTestRouter(
+ options?: RouterOptions,
+) {
const rootRoute = createRootRoute({
validateSearch: z.object({ root: z.string().optional() }),
component: () => {
diff --git a/packages/solid-router/tests/useNavigate.test.tsx b/packages/solid-router/tests/useNavigate.test.tsx
index cf9ef4831d..d3eb186cb2 100644
--- a/packages/solid-router/tests/useNavigate.test.tsx
+++ b/packages/solid-router/tests/useNavigate.test.tsx
@@ -1,6 +1,6 @@
import * as Solid from 'solid-js'
import '@testing-library/jest-dom/vitest'
-import { afterEach, describe, expect, test } from 'vitest'
+import { afterEach, beforeEach, describe, expect, test } from 'vitest'
import {
cleanup,
fireEvent,
@@ -13,6 +13,7 @@ import { z } from 'zod'
import {
Outlet,
RouterProvider,
+ createBrowserHistory,
createRootRoute,
createRoute,
createRouteMask,
@@ -21,8 +22,17 @@ import {
useNavigate,
useParams,
} from '../src'
+import type { RouterHistory } from '../src'
+
+let history: RouterHistory
+
+beforeEach(() => {
+ history = createBrowserHistory()
+ expect(window.location.pathname).toBe('/')
+})
afterEach(() => {
+ history.destroy()
window.history.replaceState(null, 'root', '/')
cleanup()
})
@@ -1509,7 +1519,11 @@ describe.each([{ basepath: '' }, { basepath: '/basepath' }])(
return (
<>
Param Route
- navigate({ to: './a' })}>
+
+ navigate({ from: paramRoute.fullPath, to: './a' })
+ }
+ >
Link to ./a
Param A Route
- navigate({ to: '..' })}>
+
+ navigate({ from: paramARoute.fullPath, to: '..' })
+ }
+ >
Link to .. from /param/foo/a
+ navigate({ to: '..' })}
+ data-testid={'link-to-previous'}
+ >
+ Link to .. from current active route
+
>
)
@@ -1668,6 +1692,23 @@ describe.each([{ basepath: '' }, { basepath: '/basepath' }])(
)
})
+ test('should navigate to a parent link based on active location', async () => {
+ const router = setupRouter()
+
+ render(() => )
+
+ window.history.replaceState(null, 'root', `${basepath}/param/foo/a/b`)
+
+ const relativeLink = await screen.findByTestId('link-to-previous')
+
+ // Click the link and ensure the new location
+ fireEvent.click(relativeLink)
+
+ await waitFor(() =>
+ expect(window.location.pathname).toBe(`${basepath}/param/foo/a`),
+ )
+ })
+
test('should navigate to same route with different params', async () => {
const router = setupRouter()
@@ -1686,3 +1727,799 @@ describe.each([{ basepath: '' }, { basepath: '/basepath' }])(
})
},
)
+
+describe('relative navigate to current route', () => {
+ test.each([true, false])(
+ 'should navigate to current route with search params when using "." in nested route structure from Index Route with trailingSlash: %s',
+ async (trailingSlash: boolean) => {
+ const tail = trailingSlash ? '/' : ''
+
+ const rootRoute = createRootRoute()
+
+ const IndexComponent = () => {
+ const navigate = useNavigate()
+ return (
+ <>
+ {
+ navigate({
+ to: '/post',
+ })
+ }}
+ >
+ Post
+
+
+ navigate({
+ to: '.',
+ search: {
+ param1: 'value1',
+ },
+ })
+ }
+ >
+ Search
+
+
+ navigate({
+ to: '/post',
+ search: {
+ param1: 'value2',
+ },
+ })
+ }
+ >
+ Search2
+
+
+ >
+ )
+ }
+
+ const indexRoute = createRoute({
+ getParentRoute: () => rootRoute,
+ path: '/',
+ component: IndexComponent,
+ validateSearch: z.object({
+ param1: z.string().optional(),
+ }),
+ })
+
+ const postRoute = createRoute({
+ getParentRoute: () => indexRoute,
+ path: 'post',
+ component: () => Post
,
+ })
+
+ const router = createRouter({
+ routeTree: rootRoute.addChildren([indexRoute, postRoute]),
+ history,
+ trailingSlash: trailingSlash ? 'always' : 'never',
+ })
+
+ render(() => )
+
+ const postButton = await screen.findByTestId('posts-btn')
+
+ fireEvent.click(postButton)
+
+ await waitFor(() => {
+ expect(router.state.location.pathname).toBe(`/post${tail}`)
+ })
+
+ const searchButton = await screen.findByTestId('search-btn')
+
+ fireEvent.click(searchButton)
+
+ await waitFor(() => {
+ expect(router.state.location.pathname).toBe(`/post${tail}`)
+ expect(router.state.location.search).toEqual({ param1: 'value1' })
+ })
+
+ const searchButton2 = await screen.findByTestId('search2-btn')
+
+ fireEvent.click(searchButton2)
+
+ await waitFor(() => {
+ expect(router.state.location.pathname).toBe(`/post${tail}`)
+ expect(router.state.location.search).toEqual({ param1: 'value2' })
+ })
+ },
+ )
+
+ test.each([true, false])(
+ 'should navigate to current route with changing path params when using "." in nested route structure with trailingSlash: %s',
+ async (trailingSlash) => {
+ const tail = trailingSlash ? '/' : ''
+ const rootRoute = createRootRoute()
+
+ const IndexComponent = () => {
+ const navigate = useNavigate()
+ return (
+ <>
+ Index
+ navigate({ to: '/posts' })}
+ >
+ Posts
+
+ >
+ )
+ }
+
+ const indexRoute = createRoute({
+ getParentRoute: () => rootRoute,
+ path: '/',
+ component: IndexComponent,
+ })
+
+ const layoutRoute = createRoute({
+ getParentRoute: () => rootRoute,
+ id: '_layout',
+ component: () => {
+ return (
+ <>
+ Layout
+
+ >
+ )
+ },
+ })
+
+ const PostsComponent = () => {
+ const navigate = useNavigate()
+
+ return (
+ <>
+ Posts
+
+ navigate({
+ to: '$postId',
+ params: { postId: 'id1' },
+ })
+ }
+ >
+ To first post
+
+
+ navigate({
+ to: '.',
+ params: { postId: 'id2' },
+ })
+ }
+ >
+ To second post
+
+
+ >
+ )
+ }
+
+ const postsRoute = createRoute({
+ getParentRoute: () => layoutRoute,
+ path: 'posts',
+ component: PostsComponent,
+ })
+
+ const PostComponent = () => {
+ const params = useParams({ strict: false })
+ return (
+ <>
+
+ Params: {params().postId}
+
+ >
+ )
+ }
+
+ const postRoute = createRoute({
+ getParentRoute: () => postsRoute,
+ path: '$postId',
+ component: PostComponent,
+ })
+
+ const router = createRouter({
+ routeTree: rootRoute.addChildren([
+ indexRoute,
+ layoutRoute.addChildren([postsRoute.addChildren([postRoute])]),
+ ]),
+ trailingSlash: trailingSlash ? 'always' : 'never',
+ })
+
+ render(() => )
+
+ const postsButton = await screen.findByTestId('posts-btn')
+
+ fireEvent.click(postsButton)
+
+ await waitFor(() => {
+ expect(screen.queryByTestId('posts-index-heading')).toBeInTheDocument()
+ expect(window.location.pathname).toEqual(`/posts${tail}`)
+ })
+
+ const firstPostButton = await screen.findByTestId('first-post-btn')
+
+ fireEvent.click(firstPostButton)
+
+ await waitFor(() => {
+ expect(screen.queryByTestId('post-id1')).toBeInTheDocument()
+ expect(window.location.pathname).toEqual(`/posts/id1${tail}`)
+ })
+
+ const secondPostButton = await screen.findByTestId('second-post-btn')
+
+ fireEvent.click(secondPostButton)
+
+ await waitFor(() => {
+ expect(screen.queryByTestId('post-id2')).toBeInTheDocument()
+ expect(window.location.pathname).toEqual(`/posts/id2${tail}`)
+ })
+ },
+ )
+
+ test.each([true, false])(
+ 'should navigate to current route with search params when using "." in nested route structure from non-Index Route with trailingSlash: %s',
+ async (trailingSlash) => {
+ const tail = trailingSlash ? '/' : ''
+ const rootRoute = createRootRoute()
+
+ const IndexComponent = () => {
+ const navigate = useNavigate()
+ return (
+ <>
+ Index
+ navigate({ to: '/posts', params: { lang: '1' } })}
+ >
+ Posts
+
+ >
+ )
+ }
+
+ const indexRoute = createRoute({
+ getParentRoute: () => rootRoute,
+ path: '/',
+ component: IndexComponent,
+ })
+
+ const PostsComponent = () => {
+ const navigate = postsRoute.useNavigate()
+ return (
+ <>
+ Posts
+
+ navigate({
+ to: '$postId/detail',
+ params: { postId: 'id1' },
+ })
+ }
+ >
+ To first post
+
+
+ >
+ )
+ }
+
+ const postsRoute = createRoute({
+ getParentRoute: () => rootRoute,
+ path: 'posts',
+ component: PostsComponent,
+ })
+
+ const useModal = (name: string) => {
+ const currentOpen = postRoute.useSearch({
+ select: (search) => search[`_${name}`],
+ })
+
+ const navigate = useNavigate()
+
+ const setModal = (open: boolean) => {
+ navigate({
+ to: '.',
+ search: (prev: {}) => ({
+ ...prev,
+ [`_${name}`]: open ? true : undefined,
+ }),
+ resetScroll: false,
+ })
+ }
+
+ return [currentOpen, setModal] as const
+ }
+
+ function DetailComponent(props: { id: string }) {
+ const params = useParams({ strict: false })
+ const [currentTest, setTest] = useModal('test')
+
+ return (
+ <>
+
+ Post Path "/{params().postId}/detail-{props.id}"!
+
+ {currentTest() ? (
+ setTest(false)}
+ >
+ Remove test
+
+ ) : (
+ setTest(true)}
+ >
+ Add test
+
+ )}
+ >
+ )
+ }
+
+ const PostComponent = () => {
+ const params = useParams({ strict: false })
+
+ return (
+
+
Post "{params().postId}"!
+
+
+
+ )
+ }
+
+ const postRoute = createRoute({
+ getParentRoute: () => postsRoute,
+ path: '$postId',
+ component: PostComponent,
+ validateSearch: z.object({
+ _test: z.boolean().optional(),
+ }),
+ })
+
+ const detailRoute = createRoute({
+ getParentRoute: () => postRoute,
+ path: 'detail',
+ component: () => ,
+ })
+
+ const router = createRouter({
+ routeTree: rootRoute.addChildren([
+ indexRoute,
+ postsRoute.addChildren([postRoute.addChildren([detailRoute])]),
+ ]),
+ trailingSlash: trailingSlash ? 'always' : 'never',
+ })
+
+ render(() => )
+
+ const postsButton = await screen.findByTestId('posts-btn')
+
+ fireEvent.click(postsButton)
+
+ await waitFor(() => {
+ expect(screen.queryByTestId('posts-index-heading')).toBeInTheDocument()
+ })
+
+ const post1Button = await screen.findByTestId('first-post-btn')
+
+ fireEvent.click(post1Button)
+
+ await waitFor(() => {
+ expect(screen.queryByTestId('post-heading')).toBeInTheDocument()
+ expect(screen.queryByTestId('detail-heading-1')).toBeInTheDocument()
+ expect(screen.queryByTestId('detail-heading-2')).toBeInTheDocument()
+ expect(screen.queryByTestId('detail-heading-1')).toHaveTextContent(
+ 'Post Path "/id1/detail-1',
+ )
+ expect(screen.queryByTestId('detail-heading-2')).toHaveTextContent(
+ 'Post Path "/id1/detail-2',
+ )
+ })
+
+ const detail1AddBtn = await screen.findByTestId('detail-btn-add-1')
+
+ fireEvent.click(detail1AddBtn)
+
+ await waitFor(() => {
+ expect(router.state.location.pathname).toBe(`/posts/id1/detail${tail}`)
+ expect(router.state.location.search).toEqual({ _test: true })
+ })
+
+ const detail1RemoveBtn = await screen.findByTestId('detail-btn-remove-1')
+
+ fireEvent.click(detail1RemoveBtn)
+
+ await waitFor(() => {
+ expect(router.state.location.pathname).toBe(`/posts/id1/detail${tail}`)
+ expect(router.state.location.search).toEqual({})
+ })
+
+ const detail2AddBtn = await screen.findByTestId('detail-btn-add-2')
+
+ fireEvent.click(detail2AddBtn)
+
+ await waitFor(() => {
+ expect(router.state.location.pathname).toBe(`/posts/id1/detail${tail}`)
+ expect(router.state.location.search).toEqual({ _test: true })
+ })
+ },
+ )
+})
+
+describe('relative navigate to from route', () => {
+ test.each([true, false])(
+ 'should navigate to from route when using "." in nested route structure from Index Route with trailingSlash: %s',
+ async (trailingSlash: boolean) => {
+ const tail = trailingSlash ? '/' : ''
+
+ const rootRoute = createRootRoute()
+
+ const IndexComponent = () => {
+ const navigate = useNavigate()
+ return (
+ <>
+ {
+ navigate({
+ to: '/post',
+ })
+ }}
+ >
+ Post
+
+
+ navigate({
+ to: '.',
+ search: {
+ param1: 'value1',
+ },
+ })
+ }
+ >
+ Search
+
+
+ navigate({
+ from: '/',
+ to: '.',
+ })
+ }
+ >
+ Go To Home
+
+
+ >
+ )
+ }
+
+ const indexRoute = createRoute({
+ getParentRoute: () => rootRoute,
+ path: '/',
+ component: IndexComponent,
+ validateSearch: z.object({
+ param1: z.string().optional(),
+ }),
+ })
+
+ const postRoute = createRoute({
+ getParentRoute: () => indexRoute,
+ path: 'post',
+ component: () => Post
,
+ })
+
+ const router = createRouter({
+ routeTree: rootRoute.addChildren([indexRoute, postRoute]),
+ history,
+ trailingSlash: trailingSlash ? 'always' : 'never',
+ })
+
+ render(() => )
+
+ const postButton = await screen.findByTestId('posts-btn')
+
+ fireEvent.click(postButton)
+
+ await waitFor(() => {
+ expect(router.state.location.pathname).toBe(`/post${tail}`)
+ })
+
+ const searchButton = await screen.findByTestId('search-btn')
+
+ fireEvent.click(searchButton)
+
+ await waitFor(() => {
+ expect(router.state.location.pathname).toBe(`/post${tail}`)
+ expect(router.state.location.search).toEqual({ param1: 'value1' })
+ })
+
+ const homeBtn = await screen.findByTestId('home-btn')
+
+ fireEvent.click(homeBtn)
+
+ await waitFor(() => {
+ expect(router.state.location.pathname).toBe(`/`)
+ expect(router.state.location.search).toEqual({})
+ })
+ },
+ )
+
+ test.each([true, false])(
+ 'should navigate to from route with path params when using "." in nested route structure with trailingSlash: %s',
+ async (trailingSlash) => {
+ const tail = trailingSlash ? '/' : ''
+ const rootRoute = createRootRoute()
+
+ const IndexComponent = () => {
+ const navigate = useNavigate()
+ return (
+ <>
+ Index
+ navigate({ to: '/posts' })}
+ >
+ Posts
+
+ >
+ )
+ }
+
+ const indexRoute = createRoute({
+ getParentRoute: () => rootRoute,
+ path: '/',
+ component: IndexComponent,
+ })
+
+ const layoutRoute = createRoute({
+ getParentRoute: () => rootRoute,
+ id: '_layout',
+ component: () => {
+ return (
+ <>
+ Layout
+
+ >
+ )
+ },
+ })
+
+ const PostsComponent = () => {
+ const navigate = postsRoute.useNavigate()
+ return (
+ <>
+ Posts
+
+ navigate({
+ to: '$postId',
+ params: { postId: '1' },
+ })
+ }
+ >
+ To first post
+
+
+ navigate({
+ to: '$postId',
+ params: { postId: '2' },
+ })
+ }
+ >
+ To second post
+
+
+ navigate({
+ from: '/posts',
+ to: '.',
+ })
+ }
+ >
+ To posts list
+
+
+ >
+ )
+ }
+
+ const PostDetailComponent = () => {
+ const navigate = postDetailRoute.useNavigate()
+ return (
+ <>
+ Post Detail
+
+ navigate({
+ to: 'info',
+ })
+ }
+ >
+ To post info
+
+
+ navigate({
+ to: 'notes',
+ })
+ }
+ >
+ To post notes
+
+
+ navigate({
+ from: '/posts/$postId',
+ to: '.',
+ })
+ }
+ >
+ To index detail options
+
+
+ >
+ )
+ }
+
+ const PostInfoComponent = () => {
+ return (
+ <>
+ Post Info
+ >
+ )
+ }
+
+ const PostNotesComponent = () => {
+ return (
+ <>
+ Post Notes
+ >
+ )
+ }
+
+ const postsRoute = createRoute({
+ getParentRoute: () => layoutRoute,
+ path: 'posts',
+ component: PostsComponent,
+ })
+
+ const postDetailRoute = createRoute({
+ getParentRoute: () => postsRoute,
+ path: '$postId',
+ component: PostDetailComponent,
+ })
+
+ const postInfoRoute = createRoute({
+ getParentRoute: () => postDetailRoute,
+ path: 'info',
+ component: PostInfoComponent,
+ })
+
+ const postNotesRoute = createRoute({
+ getParentRoute: () => postDetailRoute,
+ path: 'notes',
+ component: PostNotesComponent,
+ })
+
+ const router = createRouter({
+ routeTree: rootRoute.addChildren([
+ indexRoute,
+ layoutRoute.addChildren([
+ postsRoute.addChildren([
+ postDetailRoute.addChildren([postInfoRoute, postNotesRoute]),
+ ]),
+ ]),
+ ]),
+ trailingSlash: trailingSlash ? 'always' : 'never',
+ })
+
+ render(() => )
+
+ const postsButton = await screen.findByTestId('posts-btn')
+
+ fireEvent.click(postsButton)
+
+ await waitFor(() => {
+ expect(screen.queryByTestId('posts-index-heading')).toBeInTheDocument()
+ expect(window.location.pathname).toEqual(`/posts${tail}`)
+ })
+
+ const firstPostButton = await screen.findByTestId('first-post-btn')
+
+ fireEvent.click(firstPostButton)
+
+ await waitFor(() => {
+ expect(
+ screen.queryByTestId('post-detail-index-heading'),
+ ).toBeInTheDocument()
+ expect(window.location.pathname).toEqual(`/posts/1${tail}`)
+ })
+
+ const postInfoButton = await screen.findByTestId('post-info-btn')
+
+ fireEvent.click(postInfoButton)
+
+ await waitFor(() => {
+ expect(screen.queryByTestId('post-info-heading')).toBeInTheDocument()
+ expect(window.location.pathname).toEqual(`/posts/1/info${tail}`)
+ })
+
+ const toPostDetailIndexButton = await screen.findByTestId(
+ 'to-post-detail-index-btn',
+ )
+
+ fireEvent.click(toPostDetailIndexButton)
+
+ await waitFor(() => {
+ expect(
+ screen.queryByTestId('post-detail-index-heading'),
+ ).toBeInTheDocument()
+ expect(
+ screen.queryByTestId('post-info-heading'),
+ ).not.toBeInTheDocument()
+ expect(window.location.pathname).toEqual(`/posts/1${tail}`)
+ })
+
+ const postNotesButton = await screen.findByTestId('post-notes-btn')
+
+ fireEvent.click(postNotesButton)
+
+ await waitFor(() => {
+ expect(screen.queryByTestId('post-notes-heading')).toBeInTheDocument()
+ expect(window.location.pathname).toEqual(`/posts/1/notes${tail}`)
+ })
+
+ const toPostsIndexButton = await screen.findByTestId('to-posts-index-btn')
+
+ fireEvent.click(toPostsIndexButton)
+
+ await waitFor(() => {
+ expect(screen.queryByTestId('posts-index-heading')).toBeInTheDocument()
+ expect(
+ screen.queryByTestId('post-notes-heading'),
+ ).not.toBeInTheDocument()
+ expect(
+ screen.queryByTestId('post-detail-index-heading'),
+ ).not.toBeInTheDocument()
+ expect(window.location.pathname).toEqual(`/posts${tail}`)
+ })
+
+ const secondPostButton = await screen.findByTestId('second-post-btn')
+
+ fireEvent.click(secondPostButton)
+
+ await waitFor(() => {
+ expect(
+ screen.queryByTestId('post-detail-index-heading'),
+ ).toBeInTheDocument()
+ expect(window.location.pathname).toEqual(`/posts/2${tail}`)
+ })
+ },
+ )
+})
diff --git a/packages/solid-start-client/package.json b/packages/solid-start-client/package.json
index 8790d5586f..91e7823690 100644
--- a/packages/solid-start-client/package.json
+++ b/packages/solid-start-client/package.json
@@ -1,6 +1,6 @@
{
"name": "@tanstack/solid-start-client",
- "version": "1.131.27",
+ "version": "1.132.0-alpha.11",
"description": "Modern and scalable routing for Solid applications",
"author": "Tanner Linsley",
"license": "MIT",
@@ -46,10 +46,6 @@
"import": {
"types": "./dist/esm/index.d.ts",
"default": "./dist/esm/index.js"
- },
- "require": {
- "types": "./dist/cjs/index.d.cts",
- "default": "./dist/cjs/index.cjs"
}
},
"./package.json": "./package.json"
@@ -60,7 +56,7 @@
"src"
],
"engines": {
- "node": ">=12"
+ "node": ">=22.12.0"
},
"dependencies": {
"@tanstack/router-core": "workspace:*",
@@ -73,7 +69,7 @@
"devDependencies": {
"@solidjs/testing-library": "^0.8.10",
"@testing-library/jest-dom": "^6.6.3",
- "vite-plugin-solid": "^2.11.2"
+ "vite-plugin-solid": "^2.11.8"
},
"peerDependencies": {
"solid-js": ">=1.0.0"
diff --git a/packages/solid-start-client/src/Meta.tsx b/packages/solid-start-client/src/Meta.tsx
deleted file mode 100644
index 5da9f9268b..0000000000
--- a/packages/solid-start-client/src/Meta.tsx
+++ /dev/null
@@ -1,10 +0,0 @@
-import { HeadContent } from '@tanstack/solid-router'
-
-export const Meta = () => {
- if (process.env.NODE_ENV === 'development') {
- console.warn(
- 'The Meta component is deprecated. Use `HeadContent` from `@tanstack/solid-router` instead.',
- )
- }
- return
-}
diff --git a/packages/solid-start-client/src/Scripts.tsx b/packages/solid-start-client/src/Scripts.tsx
deleted file mode 100644
index 3f782d7d54..0000000000
--- a/packages/solid-start-client/src/Scripts.tsx
+++ /dev/null
@@ -1,8 +0,0 @@
-import { Scripts as RouterScripts } from '@tanstack/solid-router'
-
-export const Scripts = () => {
- if (process.env.NODE_ENV === 'development') {
- console.warn('The Scripts component was moved to `@tanstack/solid-router`')
- }
- return
-}
diff --git a/packages/solid-start-client/src/index.tsx b/packages/solid-start-client/src/index.tsx
index c2a1ca6365..c67846172c 100644
--- a/packages/solid-start-client/src/index.tsx
+++ b/packages/solid-start-client/src/index.tsx
@@ -1,14 +1,14 @@
export {
mergeHeaders,
- startSerializer,
createIsomorphicFn,
createServerFn,
createMiddleware,
registerGlobalMiddleware,
globalMiddleware,
- serverOnly,
- clientOnly,
+ createServerOnlyFn,
+ createClientOnlyFn,
json,
+ createClientRpc,
} from '@tanstack/start-client-core'
export {
type DehydratedRouter,
@@ -26,7 +26,6 @@ export {
type FetcherBaseOptions,
type ServerFn,
type ServerFnCtx,
- type ServerFnResponseType,
type JsonResponse,
type IntersectAllValidatorInputs,
type IntersectAllValidatorOutputs,
@@ -54,8 +53,5 @@ export {
type FunctionMiddlewareServerNextFn,
type FunctionServerResultWithContext,
} from '@tanstack/start-client-core'
-export { Meta } from './Meta'
-export { Scripts } from './Scripts'
export { StartClient } from './StartClient'
-export { renderRsc } from './renderRSC'
export { useServerFn } from './useServerFn'
diff --git a/packages/solid-start-client/src/renderRSC.tsx b/packages/solid-start-client/src/renderRSC.tsx
deleted file mode 100644
index 83735d882a..0000000000
--- a/packages/solid-start-client/src/renderRSC.tsx
+++ /dev/null
@@ -1,92 +0,0 @@
-// TODO: RSCs
-// // @ts-expect-error
-// import * as reactDom from 'react-server-dom/client'
-// import { isValidElement } from 'solid-js'
-import invariant from 'tiny-invariant'
-import type * as Solid from 'solid-js'
-
-export function renderRsc(input: any): Solid.JSX.Element {
- // TODO: isValidElement
- // if (isValidElement(input)) {
- // return input
- // }
-
- if (typeof input === 'object' && !input.state) {
- input.state = {
- status: 'pending',
- promise: Promise.resolve()
- .then(() => {
- let element
-
- // We're in node
- // TODO: RSCs
- // if (reactDom.createFromNodeStream) {
- // const stream = await import('node:stream')
-
- // let body: any = input
-
- // // Unwrap the response
- // if (input instanceof Response) {
- // body = input.body
- // }
-
- // // Convert ReadableStream to NodeJS stream.Readable
- // if (body instanceof ReadableStream) {
- // body = stream.Readable.fromWeb(body as any)
- // }
-
- // if (stream.Readable.isReadable(body)) {
- // // body = copyStreamToRaw(body)
- // } else if (input.text) {
- // // create a readable stream by awaiting the text method
- // body = new stream.Readable({
- // async read() {
- // input.text().then((value: any) => {
- // this.push(value)
- // this.push(null)
- // })
- // },
- // })
- // } else {
- // console.error('input', input)
- // throw new Error('Unexpected rsc input type 👆')
- // }
-
- // element = await reactDom.createFromNodeStream(body)
- // } else {
- // // We're in the browser
- // if (input.body instanceof ReadableStream) {
- // input = input.body
- // }
-
- // if (input instanceof ReadableStream) {
- // element = await reactDom.createFromReadableStream(input)
- // }
-
- // if (input instanceof Response) {
- // // copy to the response body to cache the raw data
- // element = await reactDom.createFromFetch(input)
- // }
- // }
-
- // return element
-
- invariant(false, 'renderRSC() is coming soon!')
- })
- .then((element) => {
- input.state.value = element
- input.state.status = 'success'
- })
- .catch((err) => {
- input.state.status = 'error'
- input.state.error = err
- }),
- }
- }
-
- if (input.state.status === 'pending') {
- throw input.state.promise
- }
-
- return input.state.value
-}
diff --git a/packages/solid-start-client/tsconfig.json b/packages/solid-start-client/tsconfig.json
index fdda84d59f..0a0fe1f18a 100644
--- a/packages/solid-start-client/tsconfig.json
+++ b/packages/solid-start-client/tsconfig.json
@@ -5,5 +5,5 @@
"jsxImportSource": "solid-js",
"module": "esnext"
},
- "include": ["src", "vite.config.ts", "src/tsrScript.ts"]
+ "include": ["src", "vite.config.ts"]
}
diff --git a/packages/solid-start-client/vite.config.ts b/packages/solid-start-client/vite.config.ts
index 38e78635ea..ca6fef541d 100644
--- a/packages/solid-start-client/vite.config.ts
+++ b/packages/solid-start-client/vite.config.ts
@@ -20,5 +20,6 @@ export default mergeConfig(
tanstackViteConfig({
srcDir: './src',
entry: './src/index.tsx',
+ cjs: false,
}),
)
diff --git a/packages/solid-start-plugin/README.md b/packages/solid-start-plugin/README.md
deleted file mode 100644
index f1f10693be..0000000000
--- a/packages/solid-start-plugin/README.md
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-# TanStack Solid Start - Plugin
-
-This package is not meant to be used directly. It is a dependency of [`@tanstack/solid-start`](https://www.npmjs.com/package/@tanstack/solid-start).
-
-TanStack Solid Start is a fullstack-framework made for SSR, Streaming, Server Functions, API Routes, bundling and more powered by [TanStack Router](https://tanstack.com/router).
-
-Head over to [tanstack.com/start](https://tanstack.com/start) for more information about getting started.
diff --git a/packages/solid-start-plugin/eslint.config.js b/packages/solid-start-plugin/eslint.config.js
deleted file mode 100644
index 8ce6ad05fc..0000000000
--- a/packages/solid-start-plugin/eslint.config.js
+++ /dev/null
@@ -1,5 +0,0 @@
-// @ts-check
-
-import rootConfig from '../../eslint.config.js'
-
-export default [...rootConfig]
diff --git a/packages/solid-start-plugin/package.json b/packages/solid-start-plugin/package.json
deleted file mode 100644
index 67962c65db..0000000000
--- a/packages/solid-start-plugin/package.json
+++ /dev/null
@@ -1,79 +0,0 @@
-{
- "name": "@tanstack/solid-start-plugin",
- "version": "1.131.27",
- "description": "Modern and scalable routing for Solid applications",
- "author": "Tanner Linsley",
- "license": "MIT",
- "repository": {
- "type": "git",
- "url": "https://github.com/TanStack/router.git",
- "directory": "packages/solid-start-plugin"
- },
- "homepage": "https://tanstack.com/start",
- "funding": {
- "type": "github",
- "url": "https://github.com/sponsors/tannerlinsley"
- },
- "keywords": [
- "solid",
- "location",
- "router",
- "routing",
- "async",
- "async router",
- "typescript"
- ],
- "scripts": {
- "clean": "rimraf ./dist && rimraf ./coverage",
- "clean:snapshots": "rimraf **/*snapshot* --glob",
- "test": "pnpm test:eslint && pnpm test:types && pnpm test:build && pnpm test:unit",
- "test:unit": "exit 0; vitest",
- "test:eslint": "eslint ./src",
- "test:types": "pnpm run \"/^test:types:ts[0-9]{2}$/\"",
- "test:types:ts54": "node ../../node_modules/typescript54/lib/tsc.js",
- "test:types:ts55": "node ../../node_modules/typescript55/lib/tsc.js",
- "test:types:ts56": "node ../../node_modules/typescript56/lib/tsc.js",
- "test:types:ts57": "node ../../node_modules/typescript57/lib/tsc.js",
- "test:types:ts58": "node ../../node_modules/typescript58/lib/tsc.js",
- "test:types:ts59": "tsc",
- "test:build": "publint --strict && attw --ignore-rules no-resolution --pack .",
- "build": "vite build"
- },
- "type": "module",
- "types": "dist/esm/index.d.ts",
- "main": "dist/cjs/index.cjs",
- "module": "dist/esm/index.js",
- "exports": {
- ".": {
- "import": {
- "types": "./dist/esm/index.d.ts",
- "default": "./dist/esm/index.js"
- },
- "require": {
- "types": "./dist/cjs/index.d.cts",
- "default": "./dist/cjs/index.cjs"
- }
- },
- "./package.json": "./package.json"
- },
- "sideEffects": false,
- "files": [
- "dist",
- "src"
- ],
- "engines": {
- "node": ">=12"
- },
- "dependencies": {
- "@tanstack/start-plugin-core": "workspace:*",
- "zod": "^3.24.2"
- },
- "devDependencies": {
- "vite": "^6.0.0",
- "vite-plugin-solid": "^2.11.6"
- },
- "peerDependencies": {
- "vite": ">=6.0.0",
- "vite-plugin-solid": ">=2.11.6"
- }
-}
diff --git a/packages/solid-start-plugin/src/index.ts b/packages/solid-start-plugin/src/index.ts
deleted file mode 100644
index 0daf41ac1e..0000000000
--- a/packages/solid-start-plugin/src/index.ts
+++ /dev/null
@@ -1,69 +0,0 @@
-import viteSolid from 'vite-plugin-solid'
-import { TanStackStartVitePluginCore } from '@tanstack/start-plugin-core'
-import { getTanStackStartOptions } from './schema'
-import type { PluginOption } from 'vite'
-import type { TanStackStartInputConfig, WithSolidPlugin } from './schema'
-
-export type {
- TanStackStartInputConfig,
- TanStackStartOutputConfig,
- WithSolidPlugin,
-} from './schema'
-
-export function TanStackStartVitePlugin(
- opts?: TanStackStartInputConfig & WithSolidPlugin,
-): Array {
- type OptionsWithSolid = ReturnType &
- WithSolidPlugin
- const options: OptionsWithSolid = getTanStackStartOptions(opts)
-
- if (opts?.customViteSolidPlugin !== true) {
- console.warn(
- `please add the vite-solid plugin to your Vite config and set 'customViteSolidPlugin: true'`,
- )
- console.warn(
- `TanStack Start will not configure the vite-solid plugin in future anymore.`,
- )
- }
-
- return [
- TanStackStartVitePluginCore(
- {
- framework: 'solid',
- getVirtualServerRootHandler(ctx) {
- return `
-import { toWebRequest, defineEventHandler } from '@tanstack/solid-start/server';
-import serverEntry from '${ctx.serverEntryFilepath}';
-
-export default defineEventHandler(function(event) {
- const request = toWebRequest(event);
- return serverEntry({ request });
-});`
- },
- getVirtualClientEntry(ctx) {
- return `
-import { hydrate } from 'solid-js/web';
-import { StartClient } from '@tanstack/solid-start';
-import { createRouter } from '${ctx.routerFilepath}';
-
-const router = createRouter();
-
-hydrate(() => , document.body);`
- },
- getVirtualServerEntry(ctx) {
- return `
-import { createStartHandler, defaultStreamHandler } from '@tanstack/solid-start/server';
-import { createRouter } from '${ctx.routerFilepath}';
-
-export default createStartHandler({
- createRouter,
-})(defaultStreamHandler);`
- },
- },
- options,
- ),
- !opts?.customViteSolidPlugin && viteSolid({ ...options.solid, ssr: true }),
- ]
-}
-
-export { TanStackStartVitePlugin as tanstackStart }
diff --git a/packages/solid-start-plugin/src/schema.ts b/packages/solid-start-plugin/src/schema.ts
deleted file mode 100644
index 4b8887f662..0000000000
--- a/packages/solid-start-plugin/src/schema.ts
+++ /dev/null
@@ -1,33 +0,0 @@
-import { z } from 'zod'
-import {
- createTanStackConfig,
- createTanStackStartOptionsSchema,
-} from '@tanstack/start-plugin-core'
-import type { Options as ViteSolidOptions } from 'vite-plugin-solid'
-
-export type WithSolidPlugin = {
- solid?: ViteSolidOptions
- customViteSolidPlugin?: boolean
-}
-
-const frameworkPlugin = {
- solid: z.custom().optional(),
- customViteSolidPlugin: z.boolean().optional().default(false),
-}
-
-// eslint-disable-next-line unused-imports/no-unused-vars
-const TanStackStartOptionsSchema =
- createTanStackStartOptionsSchema(frameworkPlugin)
-
-const defaultConfig = createTanStackConfig(frameworkPlugin)
-
-export function getTanStackStartOptions(opts?: TanStackStartInputConfig) {
- return defaultConfig.parse(opts)
-}
-
-export type TanStackStartInputConfig = z.input<
- typeof TanStackStartOptionsSchema
->
-export type TanStackStartOutputConfig = ReturnType<
- typeof getTanStackStartOptions
->
diff --git a/packages/solid-start-plugin/tsconfig.json b/packages/solid-start-plugin/tsconfig.json
deleted file mode 100644
index 090ec3917d..0000000000
--- a/packages/solid-start-plugin/tsconfig.json
+++ /dev/null
@@ -1,10 +0,0 @@
-{
- "extends": "../../tsconfig.json",
- "include": ["src", "vite.config.ts", "tests"],
- "exclude": ["tests/**/test-files/**", "tests/**/snapshots/**"],
- "compilerOptions": {
- "outDir": "dist/esm",
- "target": "esnext",
- "noEmit": true
- }
-}
diff --git a/packages/solid-start-plugin/vite.config.ts b/packages/solid-start-plugin/vite.config.ts
deleted file mode 100644
index 2c711fd181..0000000000
--- a/packages/solid-start-plugin/vite.config.ts
+++ /dev/null
@@ -1,21 +0,0 @@
-import { defineConfig, mergeConfig } from 'vitest/config'
-import { tanstackViteConfig } from '@tanstack/config/vite'
-import packageJson from './package.json'
-
-const config = defineConfig({
- test: {
- name: packageJson.name,
- dir: './tests',
- watch: false,
- typecheck: { enabled: true },
- },
-})
-
-export default mergeConfig(
- config,
- tanstackViteConfig({
- entry: './src/index.ts',
- srcDir: './src',
- outDir: './dist',
- }),
-)
diff --git a/packages/solid-start-server/package.json b/packages/solid-start-server/package.json
index 45877c4f39..fabc37ee3c 100644
--- a/packages/solid-start-server/package.json
+++ b/packages/solid-start-server/package.json
@@ -1,6 +1,6 @@
{
"name": "@tanstack/solid-start-server",
- "version": "1.131.27",
+ "version": "1.132.0-alpha.11",
"description": "Modern and scalable routing for Solid applications",
"author": "Tanner Linsley",
"license": "MIT",
@@ -45,10 +45,6 @@
"import": {
"types": "./dist/esm/index.d.ts",
"default": "./dist/esm/index.js"
- },
- "require": {
- "types": "./dist/cjs/index.d.cts",
- "default": "./dist/cjs/index.cjs"
}
},
"./package.json": "./package.json"
@@ -59,7 +55,7 @@
"src"
],
"engines": {
- "node": ">=12"
+ "node": ">=22.12.0"
},
"dependencies": {
"@solidjs/meta": "^0.29.4",
@@ -67,14 +63,12 @@
"@tanstack/router-core": "workspace:*",
"@tanstack/solid-router": "workspace:*",
"@tanstack/start-client-core": "workspace:*",
- "@tanstack/start-server-core": "workspace:*",
- "isbot": "^5.1.22"
+ "@tanstack/start-server-core": "workspace:*"
},
"devDependencies": {
- "esbuild": "^0.25.0",
"solid-js": "^1.9.5",
"typescript": "^5.7.2",
- "vite-plugin-solid": "^2.11.2"
+ "vite-plugin-solid": "^2.11.8"
},
"peerDependencies": {
"solid-js": "^1.0.0"
diff --git a/packages/solid-start-server/tsconfig.json b/packages/solid-start-server/tsconfig.json
index 4d747d628f..4d7edc09ba 100644
--- a/packages/solid-start-server/tsconfig.json
+++ b/packages/solid-start-server/tsconfig.json
@@ -5,10 +5,5 @@
"jsxImportSource": "solid-js",
"module": "esnext"
},
- "include": [
- "src",
- "tests",
- "vite.config.ts",
- "../start-client/src/tsrScript.ts"
- ]
+ "include": ["src", "tests", "vite.config.ts"]
}
diff --git a/packages/solid-start-server/vite-minify-plugin.ts b/packages/solid-start-server/vite-minify-plugin.ts
deleted file mode 100644
index d8da290266..0000000000
--- a/packages/solid-start-server/vite-minify-plugin.ts
+++ /dev/null
@@ -1,25 +0,0 @@
-import { transform as esbuildTransform } from 'esbuild'
-import type { Plugin } from 'vite'
-
-export default function minifyScriptPlugin(): Plugin {
- return {
- name: 'vite-plugin-minify-script',
- enforce: 'pre',
- async transform(code, id) {
- if (!id.endsWith('?script-string')) {
- return null
- }
-
- const result = await esbuildTransform(code, {
- loader: 'ts',
- minify: true,
- target: 'esnext',
- })
-
- return {
- code: `export default ${JSON.stringify(result.code)};`,
- map: null,
- }
- },
- }
-}
diff --git a/packages/solid-start-server/vite.config.ts b/packages/solid-start-server/vite.config.ts
index c0a7454291..93d05451e8 100644
--- a/packages/solid-start-server/vite.config.ts
+++ b/packages/solid-start-server/vite.config.ts
@@ -2,14 +2,9 @@ import { defineConfig, mergeConfig } from 'vitest/config'
import { tanstackViteConfig } from '@tanstack/config/vite'
import solid from 'vite-plugin-solid'
import packageJson from './package.json'
-import minifyScriptPlugin from './vite-minify-plugin'
-import type { ViteUserConfig } from 'vitest/config'
const config = defineConfig({
- plugins: [
- minifyScriptPlugin(),
- solid({ solid: { generate: 'ssr' } }),
- ] as ViteUserConfig['plugins'],
+ plugins: [solid({ solid: { generate: 'ssr' } })],
test: {
name: packageJson.name,
watch: false,
@@ -22,5 +17,6 @@ export default mergeConfig(
tanstackViteConfig({
srcDir: './src',
entry: './src/index.tsx',
+ cjs: false,
}),
)
diff --git a/packages/solid-start/package.json b/packages/solid-start/package.json
index 1a02e9a7d4..c6684c9f96 100644
--- a/packages/solid-start/package.json
+++ b/packages/solid-start/package.json
@@ -1,6 +1,6 @@
{
"name": "@tanstack/solid-start",
- "version": "1.131.27",
+ "version": "1.132.0-alpha.11",
"description": "Modern and scalable routing for Solid applications",
"author": "Tanner Linsley",
"license": "MIT",
@@ -36,60 +36,24 @@
"import": {
"types": "./dist/esm/client.d.ts",
"default": "./dist/esm/client.js"
- },
- "require": {
- "types": "./dist/cjs/client.d.cts",
- "default": "./dist/cjs/client.cjs"
}
},
"./client": {
"import": {
"types": "./dist/esm/client.d.ts",
"default": "./dist/esm/client.js"
- },
- "require": {
- "types": "./dist/cjs/client.d.cts",
- "default": "./dist/cjs/client.cjs"
}
},
"./server": {
"import": {
"types": "./dist/esm/server.d.ts",
"default": "./dist/esm/server.js"
- },
- "require": {
- "types": "./dist/cjs/server.d.cts",
- "default": "./dist/cjs/server.cjs"
}
},
"./plugin/vite": {
"import": {
- "types": "./dist/esm/plugin-vite.d.ts",
- "default": "./dist/esm/plugin-vite.js"
- },
- "require": {
- "types": "./dist/cjs/plugin-vite.d.cts",
- "default": "./dist/cjs/plugin-vite.cjs"
- }
- },
- "./server-functions-client": {
- "import": {
- "types": "./dist/esm/server-functions-client.d.ts",
- "default": "./dist/esm/server-functions-client.js"
- },
- "require": {
- "types": "./dist/cjs/server-functions-client.d.cts",
- "default": "./dist/cjs/server-functions-client.cjs"
- }
- },
- "./server-functions-server": {
- "import": {
- "types": "./dist/esm/server-functions-server.d.ts",
- "default": "./dist/esm/server-functions-server.js"
- },
- "require": {
- "types": "./dist/cjs/server-functions-server.d.cts",
- "default": "./dist/cjs/server-functions-server.cjs"
+ "types": "./dist/esm/plugin/vite.d.ts",
+ "default": "./dist/esm/plugin/vite.js"
}
},
"./package.json": "./package.json"
@@ -100,21 +64,20 @@
"src"
],
"engines": {
- "node": ">=12"
+ "node": ">=22.12.0"
},
"dependencies": {
"@tanstack/solid-start-client": "workspace:*",
"@tanstack/solid-start-server": "workspace:*",
- "@tanstack/solid-start-plugin": "workspace:*",
- "@tanstack/start-server-functions-client": "workspace:*",
- "@tanstack/start-server-functions-server": "workspace:*"
+ "@tanstack/start-plugin-core": "workspace:*",
+ "pathe": "^2.0.3"
+ },
+ "devDependencies": {
+ "@tanstack/router-utils": "workspace:*",
+ "vite": "^7.1.1"
},
"peerDependencies": {
"solid-js": ">=1.0.0",
- "vite": ">=6.0.0",
- "vite-plugin-solid": ">=2.11.6"
- },
- "devDependencies": {
- "esbuild": "^0.25.0"
+ "vite": ">=7.0.0"
}
}
diff --git a/packages/solid-start/src/plugin-vite.ts b/packages/solid-start/src/plugin-vite.ts
deleted file mode 100644
index 24c76d5516..0000000000
--- a/packages/solid-start/src/plugin-vite.ts
+++ /dev/null
@@ -1 +0,0 @@
-export * from '@tanstack/solid-start-plugin'
diff --git a/packages/solid-start/src/plugin/default-entry/client.tsx b/packages/solid-start/src/plugin/default-entry/client.tsx
new file mode 100644
index 0000000000..b39ab07df4
--- /dev/null
+++ b/packages/solid-start/src/plugin/default-entry/client.tsx
@@ -0,0 +1,7 @@
+import { hydrate } from 'solid-js/web'
+import { StartClient } from '@tanstack/solid-start'
+import { createRouter } from '#tanstack-start-router-entry'
+
+const router = createRouter()
+
+hydrate(() => , document.body)
diff --git a/packages/solid-start/src/plugin/default-entry/router-entry.d.ts b/packages/solid-start/src/plugin/default-entry/router-entry.d.ts
new file mode 100644
index 0000000000..00b100e793
--- /dev/null
+++ b/packages/solid-start/src/plugin/default-entry/router-entry.d.ts
@@ -0,0 +1,4 @@
+declare module '#tanstack-start-router-entry' {
+ // eslint-disable-next-line @typescript-eslint/consistent-type-imports
+ export const createRouter: () => import('@tanstack/router-core').AnyRouter
+}
diff --git a/packages/solid-start/src/plugin/default-entry/server.ts b/packages/solid-start/src/plugin/default-entry/server.ts
new file mode 100644
index 0000000000..cbfb788e4f
--- /dev/null
+++ b/packages/solid-start/src/plugin/default-entry/server.ts
@@ -0,0 +1,14 @@
+import {
+ createStartHandler,
+ defaultStreamHandler,
+} from '@tanstack/solid-start/server'
+
+import { createRouter } from '#tanstack-start-router-entry'
+
+const fetch = createStartHandler({
+ createRouter,
+})(defaultStreamHandler)
+
+export default {
+ fetch,
+}
diff --git a/packages/solid-start/src/plugin/vite.ts b/packages/solid-start/src/plugin/vite.ts
new file mode 100644
index 0000000000..8963d4550d
--- /dev/null
+++ b/packages/solid-start/src/plugin/vite.ts
@@ -0,0 +1,32 @@
+import { fileURLToPath } from 'node:url'
+import { TanStackStartVitePluginCore } from '@tanstack/start-plugin-core'
+import path from 'pathe'
+import type { TanStackStartInputConfig } from '@tanstack/start-plugin-core'
+import type { PluginOption } from 'vite'
+
+const currentDir = path.dirname(fileURLToPath(import.meta.url))
+const defaultEntryDir = path.resolve(
+ currentDir,
+ '..',
+ '..',
+ 'plugin',
+ 'default-entry',
+)
+const defaultEntryPaths = {
+ client: path.resolve(defaultEntryDir, 'client'),
+ server: path.resolve(defaultEntryDir, 'server'),
+}
+
+export function tanstackStart(
+ options?: TanStackStartInputConfig,
+): Array {
+ return [
+ TanStackStartVitePluginCore(
+ {
+ framework: 'solid',
+ defaultEntryPaths,
+ },
+ options,
+ ),
+ ]
+}
diff --git a/packages/solid-start/src/server-functions-client.tsx b/packages/solid-start/src/server-functions-client.tsx
deleted file mode 100644
index 6fc38947aa..0000000000
--- a/packages/solid-start/src/server-functions-client.tsx
+++ /dev/null
@@ -1 +0,0 @@
-export * from '@tanstack/start-server-functions-client'
diff --git a/packages/solid-start/src/server-functions-server.tsx b/packages/solid-start/src/server-functions-server.tsx
deleted file mode 100644
index cbbdd07a89..0000000000
--- a/packages/solid-start/src/server-functions-server.tsx
+++ /dev/null
@@ -1 +0,0 @@
-export * from '@tanstack/start-server-functions-server'
diff --git a/packages/solid-start/tsconfig.json b/packages/solid-start/tsconfig.json
index 51dda9abf2..0a0fe1f18a 100644
--- a/packages/solid-start/tsconfig.json
+++ b/packages/solid-start/tsconfig.json
@@ -1,7 +1,8 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
- "jsx": "react-jsx",
+ "jsx": "preserve",
+ "jsxImportSource": "solid-js",
"module": "esnext"
},
"include": ["src", "vite.config.ts"]
diff --git a/packages/solid-start/vite.config.ts b/packages/solid-start/vite.config.ts
index 8557385ded..738a67f72b 100644
--- a/packages/solid-start/vite.config.ts
+++ b/packages/solid-start/vite.config.ts
@@ -1,5 +1,6 @@
import { defineConfig, mergeConfig } from 'vitest/config'
import { tanstackViteConfig } from '@tanstack/config/vite'
+import { copyFilesPlugin } from '@tanstack/router-utils'
import packageJson from './package.json'
const config = defineConfig({
@@ -8,25 +9,25 @@ const config = defineConfig({
watch: false,
environment: 'jsdom',
},
+ plugins: [
+ copyFilesPlugin({
+ pattern: ['*.ts', '*.tsx', '!*.d.ts'],
+ fromDir: 'src/plugin/default-entry',
+ toDir: 'dist/plugin/default-entry',
+ }),
+ ],
})
export default mergeConfig(
config,
tanstackViteConfig({
srcDir: './src',
- entry: [
- './src/client.tsx',
- './src/server.tsx',
- './src/plugin-vite.ts',
- './src/server-functions-client.tsx',
- './src/server-functions-server.tsx',
- ],
+ entry: ['./src/client.tsx', './src/server.tsx', './src/plugin/vite.ts'],
externalDeps: [
'@tanstack/solid-start-client',
'@tanstack/solid-start-server',
- '@tanstack/solid-start-plugin',
- '@tanstack/start-server-functions-client',
- '@tanstack/start-server-functions-server',
],
+ cjs: false,
+ exclude: ['./src/plugin/default-entry'],
}),
)
diff --git a/packages/start-client-core/package.json b/packages/start-client-core/package.json
index 50ae4b2bc1..73dd43a729 100644
--- a/packages/start-client-core/package.json
+++ b/packages/start-client-core/package.json
@@ -1,6 +1,6 @@
{
"name": "@tanstack/start-client-core",
- "version": "1.131.27",
+ "version": "1.132.0-alpha.11",
"description": "Modern and scalable routing for React applications",
"author": "Tanner Linsley",
"license": "MIT",
@@ -46,10 +46,6 @@
"import": {
"types": "./dist/esm/index.d.ts",
"default": "./dist/esm/index.js"
- },
- "require": {
- "types": "./dist/cjs/index.d.cts",
- "default": "./dist/cjs/index.cjs"
}
},
"./package.json": "./package.json"
@@ -60,12 +56,13 @@
"src"
],
"engines": {
- "node": ">=12"
+ "node": ">=22.12.0"
},
"dependencies": {
"@tanstack/router-core": "workspace:*",
"@tanstack/start-storage-context": "workspace:*",
"cookie-es": "^1.2.2",
+ "seroval": "^1.3.2",
"tiny-invariant": "^1.3.3",
"tiny-warning": "^1.0.3"
}
diff --git a/packages/start-client-core/src/constants.ts b/packages/start-client-core/src/constants.ts
new file mode 100644
index 0000000000..0a39ffaeed
--- /dev/null
+++ b/packages/start-client-core/src/constants.ts
@@ -0,0 +1,8 @@
+export const TSS_FORMDATA_CONTEXT = '__TSS_CONTEXT'
+export const TSS_SERVER_FUNCTION = Symbol.for('TSS_SERVER_FUNCTION')
+export const TSS_SERVER_FUNCTION_FACTORY = Symbol.for(
+ 'TSS_SERVER_FUNCTION_FACTORY',
+)
+
+export const X_TSS_SERIALIZED = 'x-tss-serialized'
+export {}
diff --git a/packages/start-client-core/src/createClientRpc.ts b/packages/start-client-core/src/createClientRpc.ts
new file mode 100644
index 0000000000..62c7e7dd12
--- /dev/null
+++ b/packages/start-client-core/src/createClientRpc.ts
@@ -0,0 +1,26 @@
+import { TSS_SERVER_FUNCTION } from './constants'
+import { serverFnFetcher } from './serverFnFetcher'
+
+let baseUrl: string
+function sanitizeBase(base: string) {
+ return base.replace(/^\/|\/$/g, '')
+}
+
+export const createClientRpc = (functionId: string) => {
+ if (!baseUrl) {
+ const sanitizedAppBase = sanitizeBase(process.env.TSS_APP_BASE || '/')
+ const sanitizedServerBase = sanitizeBase(process.env.TSS_SERVER_FN_BASE!)
+ baseUrl = `${sanitizedAppBase ? `/${sanitizedAppBase}` : ''}/${sanitizedServerBase}/`
+ }
+ const url = baseUrl + functionId
+
+ const clientFn = (...args: Array) => {
+ return serverFnFetcher(url, args, fetch)
+ }
+
+ return Object.assign(clientFn, {
+ url,
+ functionId,
+ [TSS_SERVER_FUNCTION]: true,
+ })
+}
diff --git a/packages/start-client-core/src/createMiddleware.ts b/packages/start-client-core/src/createMiddleware.ts
index 6ad5d2ea7c..69d46c36ae 100644
--- a/packages/start-client-core/src/createMiddleware.ts
+++ b/packages/start-client-core/src/createMiddleware.ts
@@ -1,44 +1,42 @@
-import type {
- ConstrainValidator,
- Method,
- ServerFnResponseType,
- ServerFnTypeOrTypeFn,
-} from './createServerFn'
+import type { ConstrainValidator, Method } from './createServerFn'
import type {
AnyRouter,
Assign,
Constrain,
Expand,
IntersectAssign,
+ Register,
RegisteredRouter,
ResolveValidatorInput,
ResolveValidatorOutput,
+ ValidateSerializableInput,
} from '@tanstack/router-core'
-import type { SerializerStringify } from './serializer'
-export function createMiddleware(
+export function createMiddleware<
+ TRegister extends Register,
+ TType extends MiddlewareType,
+>(
options: {
type: TType
- validateClient?: boolean
},
__opts?: FunctionMiddlewareOptions<
+ TRegister,
unknown,
undefined,
undefined,
- undefined,
- ServerFnResponseType
+ undefined
>,
-): CreateMiddlewareResult {
+): CreateMiddlewareResult {
// const resolvedOptions = (__opts || options) as MiddlewareOptions<
const resolvedOptions = {
type: 'function',
...(__opts ||
(options as FunctionMiddlewareOptions<
+ TRegister,
unknown,
undefined,
undefined,
- undefined,
- ServerFnResponseType
+ undefined
>)),
}
@@ -68,57 +66,56 @@ export function createMiddleware(
Object.assign(resolvedOptions, { server }),
) as any
},
- } as unknown as CreateMiddlewareResult
+ } as unknown as CreateMiddlewareResult
}
export type MiddlewareType = 'request' | 'function'
-export type CreateMiddlewareResult =
- 'function' extends TType
- ? FunctionMiddleware
- : RequestMiddleware
+export type CreateMiddlewareResult<
+ TRegister extends Register,
+ TType extends MiddlewareType,
+> = 'function' extends TType ? FunctionMiddleware : RequestMiddleware
-export interface FunctionMiddleware<
- TServerFnResponseType extends ServerFnResponseType,
-> extends FunctionMiddlewareAfterMiddleware {
+export interface FunctionMiddleware
+ extends FunctionMiddlewareAfterMiddleware {
middleware: (
middlewares: Constrain<
TNewMiddlewares,
ReadonlyArray
>,
- ) => FunctionMiddlewareAfterMiddleware
+ ) => FunctionMiddlewareAfterMiddleware
}
export interface FunctionMiddlewareAfterMiddleware<
+ TRegister extends Register,
TMiddlewares,
- TServerFnResponseType extends ServerFnResponseType,
> extends FunctionMiddlewareWithTypes<
+ TRegister,
TMiddlewares,
undefined,
undefined,
undefined,
undefined,
- undefined,
- TServerFnResponseType
+ undefined
>,
FunctionMiddlewareServer<
+ TRegister,
TMiddlewares,
undefined,
undefined,
- undefined,
- TServerFnResponseType
+ undefined
>,
- FunctionMiddlewareClient,
- FunctionMiddlewareValidator {}
+ FunctionMiddlewareClient,
+ FunctionMiddlewareValidator {}
export interface FunctionMiddlewareWithTypes<
+ TRegister extends Register,
TMiddlewares,
TValidator,
TServerContext,
TServerSendContext,
TClientContext,
TClientSendContext,
- TServerFnResponseType extends ServerFnResponseType,
> {
_types: FunctionMiddlewareTypes<
TMiddlewares,
@@ -129,11 +126,11 @@ export interface FunctionMiddlewareWithTypes<
TClientSendContext
>
options: FunctionMiddlewareOptions<
+ TRegister,
TMiddlewares,
TValidator,
TServerContext,
- TClientContext,
- TServerFnResponseType
+ TClientContext
>
}
@@ -310,82 +307,82 @@ export type AssignAllClientSendContext<
>
export interface FunctionMiddlewareOptions<
+ in out TRegister extends Register,
in out TMiddlewares,
in out TValidator,
in out TServerContext,
in out TClientContext,
- in out TServerFnResponseType extends ServerFnResponseType,
> {
- validateClient?: boolean
middleware?: TMiddlewares
- validator?: ConstrainValidator
+ validator?: ConstrainValidator
client?: FunctionMiddlewareClientFn<
+ TRegister,
TMiddlewares,
TValidator,
TServerContext,
- TClientContext,
- TServerFnResponseType
+ TClientContext
>
server?: FunctionMiddlewareServerFn<
+ TRegister,
TMiddlewares,
TValidator,
TServerContext,
unknown,
- unknown,
- TServerFnResponseType
+ unknown
>
}
-export type FunctionMiddlewareClientNextFn = <
- TSendContext = undefined,
- TNewClientContext = undefined,
->(ctx?: {
+export type FunctionMiddlewareClientNextFn<
+ TRegister extends Register,
+ TMiddlewares,
+> = (ctx?: {
context?: TNewClientContext
- sendContext?: SerializerStringify
+ sendContext?: ValidateSerializableInput
headers?: HeadersInit
}) => Promise<
FunctionClientResultWithContext
>
export interface FunctionMiddlewareServer<
+ TRegister extends Register,
TMiddlewares,
TValidator,
TServerSendContext,
TClientContext,
- TServerFnResponseType extends ServerFnResponseType,
> {
server: (
server: FunctionMiddlewareServerFn<
+ TRegister,
TMiddlewares,
TValidator,
TServerSendContext,
TNewServerContext,
- TSendContext,
- TServerFnResponseType
+ TSendContext
>,
) => FunctionMiddlewareAfterServer<
+ TRegister,
TMiddlewares,
TValidator,
TNewServerContext,
TServerSendContext,
TClientContext,
- TSendContext,
- ServerFnResponseType
+ TSendContext
>
}
+
export type FunctionMiddlewareServerFn<
+ TRegister extends Register,
TMiddlewares,
TValidator,
TServerSendContext,
TNewServerContext,
TSendContext,
- TServerFnResponseType extends ServerFnResponseType,
> = (
options: FunctionMiddlewareServerFnOptions<
+ TRegister,
TMiddlewares,
TValidator,
- TServerSendContext,
- TServerFnResponseType
+ TServerSendContext
>,
) => FunctionMiddlewareServerFnResult<
TMiddlewares,
@@ -395,23 +392,29 @@ export type FunctionMiddlewareServerFn<
>
export interface RequestMiddlewareServerFnOptions<
+ in out TRegister extends Register,
in out TMiddlewares,
in out TServerSendContext,
> {
request: Request
context: Expand>
- next: FunctionMiddlewareServerNextFn
+ next: FunctionMiddlewareServerNextFn<
+ TRegister,
+ TMiddlewares,
+ TServerSendContext
+ >
response: Response
method: Method
signal: AbortSignal
}
-export type FunctionMiddlewareServerNextFn = <
- TNewServerContext = undefined,
- TSendContext = undefined,
->(ctx?: {
+export type FunctionMiddlewareServerNextFn<
+ TRegister extends Register,
+ TMiddlewares,
+ TServerSendContext,
+> = (ctx?: {
context?: TNewServerContext
- sendContext?: SerializerStringify
+ sendContext?: ValidateSerializableInput
}) => Promise<
FunctionServerResultWithContext<
TMiddlewares,
@@ -439,15 +442,18 @@ export type FunctionServerResultWithContext<
}
export interface FunctionMiddlewareServerFnOptions<
+ in out TRegister extends Register,
in out TMiddlewares,
in out TValidator,
in out TServerSendContext,
- in out TServerFnResponseType,
> {
data: Expand>
context: Expand>
- next: FunctionMiddlewareServerNextFn