diff --git a/AGENTS.md b/AGENTS.md
new file mode 100644
index 0000000000..8f4e24c72a
--- /dev/null
+++ b/AGENTS.md
@@ -0,0 +1,171 @@
+# AGENTS.md
+
+## Project overview
+
+TanStack Router is a type-safe router with built-in caching and URL state management for React and Solid applications. This monorepo contains two main products:
+
+- **TanStack Router** - Core routing library with type-safe navigation, search params, and path params
+- **TanStack Start** - Full-stack framework built on top of TanStack Router
+
+## Setup commands
+
+- Install deps: `pnpm install`
+- Setup e2e testing: `pnpm exec playwright install`
+- Build packages: `pnpm build` (affected) or `pnpm build:all` (force all)
+- Start dev server: `pnpm dev`
+- Run tests: `pnpm test`
+
+## Code style
+
+- TypeScript strict mode with extensive type safety
+- Framework-agnostic core logic separated from React/Solid bindings
+- Type-safe routing with search params and path params
+- Use workspace protocol for internal dependencies (`workspace:*`)
+
+## Dev environment tips
+
+- This is a pnpm workspace monorepo with packages organized by functionality
+- Nx provides caching, affected testing, targeting, and parallel execution for efficiency
+- Use `npx nx show projects` to list all available packages
+- Target specific packages: `npx nx run @tanstack/react-router:test:unit`
+- Target multiple packages: `npx nx run-many --target=test:eslint --projects=@tanstack/history,@tanstack/router-core`
+- Run affected tests only: `npx nx affected --target=test:unit`
+- Exclude patterns: `npx nx run-many --target=test:unit --exclude="examples/**,e2e/**"`
+- Navigate to examples and run `pnpm dev` to test changes: `cd examples/react/basic && pnpm dev`
+- **Granular Vitest testing within packages:**
+ - Navigate first: `cd packages/react-router`
+ - Specific files: `npx vitest run tests/link.test.tsx tests/Scripts.test.tsx`
+ - Test patterns: `npx vitest run tests/ClientOnly.test.tsx -t "should render fallback"`
+ - Name patterns: `npx vitest run -t "navigation"` (all tests with "navigation" in name)
+ - Exclude patterns: `npx vitest run --exclude="**/*link*" tests/`
+ - List tests: `npx vitest list tests/link.test.tsx` or `npx vitest list` (all)
+ - Through nx: `npx nx run @tanstack/react-router:test:unit -- tests/ClientOnly.test.tsx`
+- **Available test targets per package:** `test:unit`, `test:types`, `test:eslint`, `test:build`, `test:perf`, `build`
+- **Testing strategy:** Package level (nx) → File level (vitest) → Test level (-t flag) → Pattern level (exclude)
+
+## Testing instructions
+
+- **Critical**: Always run unit and type tests during development - do not proceed if they fail
+- **Test types:** `pnpm test:unit`, `pnpm test:types`, `pnpm test:eslint`, `pnpm test:e2e`, `pnpm test:build`
+- **Full CI suite:** `pnpm test:ci`
+- **Fix formatting:** `pnpm prettier:write`
+- **Efficient targeted testing workflow:**
+ 1. **Affected only:** `npx nx affected --target=test:unit` (compares to main branch)
+ 2. **Specific packages:** `npx nx run @tanstack/react-router:test:unit`
+ 3. **Specific files:** `cd packages/react-router && npx vitest run tests/link.test.tsx`
+ 4. **Specific patterns:** `npx vitest run tests/link.test.tsx -t "preloading"`
+- **Pro tips:**
+ - Use `npx vitest list` to explore available tests before running
+ - Use `-t "pattern"` to focus on specific functionality during development
+ - Use `--exclude` patterns to skip unrelated tests
+ - Combine nx package targeting with vitest file targeting for maximum precision
+- **Example workflow:** `npx nx run @tanstack/react-router:test:unit` → `cd packages/react-router && npx vitest run tests/link.test.tsx` → `npx vitest run tests/link.test.tsx -t "preloading"`
+
+## PR instructions
+
+- Always run `pnpm test:eslint`, `pnpm test:types`, and `pnpm test:unit` before committing
+- Test changes in relevant example apps: `cd examples/react/basic && pnpm dev`
+- Update corresponding documentation in `docs/` directory when adding features
+- Add or update tests for any code changes
+- Use internal docs links relative to `docs/` folder (e.g., `./guide/data-loading`)
+
+## Package structure
+
+**Core packages:**
+
+- `packages/router-core/` - Framework-agnostic core router logic
+- `packages/react-router/`, `packages/solid-router/` - React/Solid bindings and components
+- `packages/history/` - Browser history management
+
+**Tooling:**
+
+- `packages/router-cli/` - CLI tools for code generation
+- `packages/router-generator/` - Route generation utilities
+- `packages/router-plugin/` - Universal bundler plugins (Vite, Webpack, ESBuild, Rspack)
+- `packages/virtual-file-routes/` - Virtual file routing system
+
+**Developer experience:**
+
+- `packages/router-devtools/`, `packages/*-router-devtools/` - Development tools
+- `packages/eslint-plugin-router/` - ESLint rules for router
+
+**Validation adapters:**
+
+- `packages/zod-adapter/`, `packages/valibot-adapter/`, `packages/arktype-adapter/`
+
+**Start framework:**
+
+- `packages/*-start/`, `packages/start-*/` - Full-stack framework packages
+
+**Examples & testing:**
+
+- `examples/react/`, `examples/solid/` - Example applications (test changes here)
+- `e2e/` - End-to-end tests (requires Playwright)
+- `docs/router/`, `docs/start/` - Documentation with React/Solid subdirectories
+
+**Dependencies:** Uses workspace protocol (`workspace:*`) - core → framework → start packages
+
+## Common development tasks
+
+**Adding new routes:**
+
+- Use file-based routing in `src/routes/` directories
+- Or use code-based routing with route definitions
+- Run route generation with CLI tools
+
+**Testing changes:**
+
+- Build packages: `pnpm build` or `pnpm dev` (watch mode)
+- Run example apps to test functionality
+- Use devtools for debugging router state
+
+**Documentation updates:**
+
+- Update relevant docs in `docs/` directory
+- Ensure examples reflect documentation changes
+- Test documentation links and references
+- Use relative links to `docs/` folder format
+
+## Framework-specific notes
+
+**React:**
+
+- Uses React Router components and hooks
+- Supports React Server Components (RSC)
+- Examples include React Query integration
+- Package: `@tanstack/react-router`
+
+**Solid:**
+
+- Uses Solid Router components and primitives
+- Supports Solid Start for full-stack applications
+- Examples include Solid Query integration
+- Package: `@tanstack/solid-router`
+
+## Environment requirements
+
+- **Node.js** - Required for development
+- **pnpm** - Package manager (required for workspace features)
+- **Playwright** - Required for e2e tests (`pnpm exec playwright install`)
+
+## Key architecture patterns
+
+- **Type Safety**: Extensive TypeScript for type-safe routing
+- **Framework Agnostic**: Core logic separated from framework bindings
+- **Plugin Architecture**: Universal bundler plugins using unplugin
+- **File-based Routing**: Support for both code-based and file-based routing
+- **Search Params**: First-class support for type-safe search parameters
+
+## Development workflow
+
+1. **Setup**: `pnpm install` and `pnpm exec playwright install`
+2. **Build**: `pnpm build:all` or `pnpm dev` for watch mode
+3. **Test**: Make changes and run relevant tests (use nx for targeted testing)
+4. **Examples**: Navigate to examples and run `pnpm dev` to test changes
+5. **Quality**: Run `pnpm test:eslint`, `pnpm test:types`, `pnpm test:unit` before committing
+
+## References
+
+- **Documentation**: https://tanstack.com/router
+- **GitHub**: https://github.com/TanStack/router
+- **Discord Community**: https://discord.com/invite/WrRKjPJ
diff --git a/AI.md b/AI.md
deleted file mode 100644
index 5860ac0188..0000000000
--- a/AI.md
+++ /dev/null
@@ -1,348 +0,0 @@
-# AI.md
-
-This file provides guidance to AI assistants when working with the TanStack Router codebase.
-
-## Project Overview
-
-TanStack Router is a type-safe router with built-in caching and URL state management for React and Solid applications. This monorepo contains two main products:
-
-- **TanStack Router** - Core routing library with type-safe navigation, search params, and path params
-- **TanStack Start** - Full-stack framework built on top of TanStack Router
-
-## Repository Structure
-
-### Core Packages
-
-**Router Core:**
-
-- `router-core/` - Framework-agnostic core router logic
-- `react-router/` - React bindings and components
-- `solid-router/` - Solid bindings and components
-- `history/` - Browser history management
-
-**Tooling:**
-
-- `router-cli/` - CLI tools for code generation
-- `router-generator/` - Route generation utilities
-- `router-plugin/` - Universal bundler plugins (Vite, Webpack, ESBuild, Rspack)
-- `router-vite-plugin/` - Vite-specific plugin wrapper
-- `virtual-file-routes/` - Virtual file routing system
-
-**Developer Experience:**
-
-- `router-devtools/` - Router development tools
-- `router-devtools-core/` - Core devtools functionality
-- `react-router-devtools/` - React-specific devtools
-- `solid-router-devtools/` - Solid-specific devtools
-- `eslint-plugin-router/` - ESLint rules for router
-
-**Adapters:**
-
-- `zod-adapter/` - Zod validation adapter
-- `valibot-adapter/` - Valibot validation adapter
-- `arktype-adapter/` - ArkType validation adapter
-
-**Start Framework:**
-
-- `start/` - Core start framework
-- `react-start/` - React Start framework
-- `solid-start/` - Solid Start framework
-- `start-*` packages - Various start framework utilities
-
-### Documentation
-
-Documentation is organized in `docs/`:
-
-- `docs/router/` - Router-specific documentation
-- `docs/start/` - Start framework documentation
-- Each has `framework/react/` and `framework/solid/` subdirectories
-
-### Examples
-
-Extensive examples in `examples/`:
-
-- `examples/react/` - React router examples
-- `examples/solid/` - Solid router examples
-- Examples range from basic usage to complex applications
-
-### Testing
-
-- `e2e/` - End-to-end tests organized by framework
-- Individual packages have `tests/` directories
-- Uses Playwright for e2e testing
-
-## Essential Commands
-
-### Development
-
-```bash
-# Install dependencies
-pnpm install
-
-# Build all packages (affected only)
-pnpm build
-
-# Build all packages (force all)
-pnpm build:all
-
-# Development mode with watch
-pnpm dev
-
-# Run all tests
-pnpm test
-
-# Run tests in CI mode
-pnpm test:ci
-```
-
-### Testing
-
-```bash
-# Run unit tests
-pnpm test:unit
-
-# Run e2e tests
-pnpm test:e2e
-
-# Run type checking
-pnpm test:types
-
-# Run linting
-pnpm test:eslint
-
-# Run formatting check
-pnpm test:format
-
-# Fix formatting
-pnpm prettier:write
-```
-
-### Targeted Testing with Nx
-
-```bash
-# Target specific package
-npx nx run @tanstack/react-router:test:unit
-npx nx run @tanstack/router-core:test:types
-npx nx run @tanstack/history:test:eslint
-
-# Target multiple packages
-npx nx run-many --target=test:eslint --projects=@tanstack/history,@tanstack/router-core
-
-# Run affected tests only (compares to main branch)
-npx nx affected --target=test:unit
-
-# Exclude certain patterns
-npx nx run-many --target=test:unit --exclude="examples/**,e2e/**"
-
-# List all available projects
-npx nx show projects
-```
-
-### Granular Vitest Testing
-
-For even more precise test targeting within packages:
-
-```bash
-# Navigate to package directory first
-cd packages/react-router
-
-# Run specific test files
-npx vitest run tests/link.test.tsx
-npx vitest run tests/ClientOnly.test.tsx tests/Scripts.test.tsx
-
-# Run tests by name pattern
-npx vitest run tests/ClientOnly.test.tsx -t "should render fallback"
-npx vitest run -t "navigation" # Run all tests with "navigation" in name
-
-# Exclude test patterns
-npx vitest run --exclude="**/*link*" tests/
-
-# List available tests
-npx vitest list tests/link.test.tsx
-npx vitest list # List all tests in package
-
-# Through nx (passes args to vitest)
-npx nx run @tanstack/react-router:test:unit -- tests/ClientOnly.test.tsx
-npx nx run @tanstack/react-router:test:unit -- tests/link.test.tsx tests/Scripts.test.tsx
-```
-
-### Example Development
-
-```bash
-# Navigate to an example
-cd examples/react/basic
-
-# Run the example
-pnpm dev
-```
-
-## Development Workflow
-
-1. **Setup**: `pnpm install` and `pnpm exec playwright install`
-2. **Build**: `pnpm build:all` or `pnpm dev` for watch mode
-3. **Test**: Make changes and run relevant tests (use nx for targeted testing)
-4. **Examples**: Navigate to examples and run `pnpm dev` to test changes
-
-### Nx-Powered Development
-
-This repository uses Nx for efficient task execution:
-
-- **Caching**: Nx caches task results - repeated commands are faster
-- **Affected**: Only runs tasks for changed code (`nx affected`)
-- **Targeting**: Run tasks for specific packages or combinations
-- **Parallel Execution**: Multiple tasks run in parallel automatically
-- **Dependency Management**: Nx handles build order and dependencies
-
-## Code Organization
-
-### Monorepo Structure
-
-This is a pnpm workspace with packages organized by functionality:
-
-- Core packages provide the fundamental router logic
-- Framework packages provide React/Solid bindings
-- Tool packages provide development utilities
-- Start packages provide full-stack framework capabilities
-
-### Key Patterns
-
-- **Type Safety**: Extensive use of TypeScript for type-safe routing
-- **Framework Agnostic**: Core logic separated from framework bindings
-- **Plugin Architecture**: Universal bundler plugins using unplugin
-- **File-based Routing**: Support for both code-based and file-based routing
-- **Search Params**: First-class support for type-safe search parameters
-
-## Documentation Guidelines
-
-- **Internal Links**: Always write relative to `docs/` folder (e.g., `./guide/data-loading`)
-- **Examples**: Each major feature should have corresponding examples
-- **Type Safety**: Document TypeScript patterns and type inference
-- **Framework Specific**: Separate docs for React and Solid when needed
-
-## Critical Quality Checks
-
-**During prompt-driven development, always run unit and type tests to ensure validity. If either of these fail, do not stop or proceed (unless you have repeatedly failed and need human intervention).**
-
-**You can run these (or the ones you are working on) after each big change:**
-
-```bash
-pnpm test:eslint # Linting
-pnpm test:types # TypeScript compilation
-pnpm test:unit # Unit tests
-pnpm test:build # Build verification
-```
-
-**For comprehensive testing:**
-
-```bash
-pnpm test:ci # Full CI test suite
-pnpm test:e2e # End-to-end tests
-```
-
-**For targeted testing (recommended for efficiency):**
-
-```bash
-# Test only affected packages
-npx nx affected --target=test:unit
-npx nx affected --target=test:types
-npx nx affected --target=test:eslint
-
-# Test specific packages you're working on
-npx nx run @tanstack/react-router:test:unit
-npx nx run @tanstack/router-core:test:types
-
-# Test specific files/functionality you're working on
-cd packages/react-router
-npx vitest run tests/link.test.tsx -t "preloading"
-npx vitest run tests/useNavigate.test.tsx tests/useParams.test.tsx
-```
-
-**Pro Tips:**
-
-- Use `npx vitest list` to explore available tests before running
-- Use `-t "pattern"` to focus on specific functionality during development
-- Use `--exclude` patterns to skip unrelated tests
-- Combine nx package targeting with vitest file targeting for maximum precision
-
-## Package Dependencies
-
-The monorepo uses workspace dependencies extensively:
-
-- Core packages are dependencies of framework packages
-- Framework packages are dependencies of start packages
-- All packages use workspace protocol (`workspace:*`)
-
-## Environment Setup
-
-- **Node.js**: Required for development
-- **pnpm**: Package manager (required for workspace features)
-- **Playwright**: Required for e2e tests (`pnpm exec playwright install`)
-
-## Common Tasks
-
-### Adding New Routes
-
-- Use file-based routing in `src/routes/` directories
-- Or use code-based routing with route definitions
-- Run route generation with CLI tools
-
-### Testing Changes
-
-- Build packages: `pnpm build` or `pnpm dev`
-- Run example apps to test functionality
-- Use devtools for debugging router state
-
-**Available Test Targets per Package:**
-
-- `test:unit` - Unit tests with Vitest
-- `test:types` - TypeScript compilation across multiple TS versions
-- `test:eslint` - Linting with ESLint
-- `test:build` - Build verification (publint + attw)
-- `test:perf` - Performance benchmarks
-- `build` - Package building
-
-**Granular Test Targeting Strategies:**
-
-1. **Package Level**: Use nx to target specific packages
-2. **File Level**: Use vitest directly to target specific test files
-3. **Test Level**: Use vitest `-t` flag to target specific test names
-4. **Pattern Level**: Use vitest exclude patterns to skip certain tests
-
-Example workflow:
-
-```bash
-# 1. Test specific package
-npx nx run @tanstack/react-router:test:unit
-
-# 2. Test specific files within package
-cd packages/react-router && npx vitest run tests/link.test.tsx
-
-# 3. Test specific functionality
-npx vitest run tests/link.test.tsx -t "preloading"
-```
-
-### Documentation Updates
-
-- Update relevant docs in `docs/` directory
-- Ensure examples reflect documentation
-- Test documentation links and references
-
-## Framework-Specific Notes
-
-### React
-
-- Uses React Router components and hooks
-- Supports React Server Components (RSC)
-- Examples include React Query integration
-
-### Solid
-
-- Uses Solid Router components and primitives
-- Supports Solid Start for full-stack applications
-- Examples include Solid Query integration
-
-## References
-
-- Main Documentation: https://tanstack.com/router
-- GitHub Repository: https://github.com/TanStack/router
-- Discord Community: https://discord.com/invite/WrRKjPJ
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..81dabfadfd 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(),
],
})
```
@@ -326,10 +328,14 @@ Learn more about the [Server Functions](../server-functions.md).
```ts
- export async function GET() { // [!code --]
-+ export const ServerRoute = createServerFileRoute().methods({ // [!code ++]
-+ GET: async () => { // [!code ++]
- return Response.json("Hello, World!")
- }
++ export const Route = createFileRoute('/api/hello')({ // [!code ++]
++ server: { // [!code ++]
++ handlers: { // [!code ++]
++ GET: async () => { // [!code ++]
++ return Response.json("Hello, World!")
++ } // [!code ++]
++ } // [!code ++]
++ } // [!code ++]
+ }) // [!code ++]
```
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/e2e-utils/package.json b/e2e/e2e-utils/package.json
index 7376c0bca4..ad1b3f10e0 100644
--- a/e2e/e2e-utils/package.json
+++ b/e2e/e2e-utils/package.json
@@ -9,7 +9,8 @@
"type": "module",
"exports": {
".": {
- "import": "./src/index.ts"
+ "import": "./src/index.ts",
+ "default": "./src/index.ts"
},
"./package.json": "./package.json"
},
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-code-splitting/src/routeTree.gen.ts b/e2e/react-router/basic-file-based-code-splitting/src/routeTree.gen.ts
index 70f7404361..442312342a 100644
--- a/e2e/react-router/basic-file-based-code-splitting/src/routeTree.gen.ts
+++ b/e2e/react-router/basic-file-based-code-splitting/src/routeTree.gen.ts
@@ -147,25 +147,11 @@ export interface RootRouteChildren {
declare module '@tanstack/react-router' {
interface FileRoutesByPath {
- '/': {
- id: '/'
- path: '/'
- fullPath: '/'
- preLoaderRoute: typeof IndexRouteImport
- parentRoute: typeof rootRouteImport
- }
- '/_layout': {
- id: '/_layout'
- path: ''
- fullPath: ''
- preLoaderRoute: typeof LayoutRouteImport
- parentRoute: typeof rootRouteImport
- }
- '/posts': {
- id: '/posts'
- path: '/posts'
- fullPath: '/posts'
- preLoaderRoute: typeof PostsRouteImport
+ '/without-loader': {
+ id: '/without-loader'
+ path: '/without-loader'
+ fullPath: '/without-loader'
+ preLoaderRoute: typeof WithoutLoaderRouteImport
parentRoute: typeof rootRouteImport
}
'/viewport-test': {
@@ -175,26 +161,26 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof ViewportTestRouteImport
parentRoute: typeof rootRouteImport
}
- '/without-loader': {
- id: '/without-loader'
- path: '/without-loader'
- fullPath: '/without-loader'
- preLoaderRoute: typeof WithoutLoaderRouteImport
+ '/posts': {
+ id: '/posts'
+ path: '/posts'
+ fullPath: '/posts'
+ preLoaderRoute: typeof PostsRouteImport
parentRoute: typeof rootRouteImport
}
- '/_layout/_layout-2': {
- id: '/_layout/_layout-2'
+ '/_layout': {
+ id: '/_layout'
path: ''
fullPath: ''
- preLoaderRoute: typeof LayoutLayout2RouteImport
- parentRoute: typeof LayoutRoute
+ preLoaderRoute: typeof LayoutRouteImport
+ parentRoute: typeof rootRouteImport
}
- '/posts/$postId': {
- id: '/posts/$postId'
- path: '/$postId'
- fullPath: '/posts/$postId'
- preLoaderRoute: typeof PostsPostIdRouteImport
- parentRoute: typeof PostsRoute
+ '/': {
+ id: '/'
+ path: '/'
+ fullPath: '/'
+ preLoaderRoute: typeof IndexRouteImport
+ parentRoute: typeof rootRouteImport
}
'/posts/': {
id: '/posts/'
@@ -203,12 +189,19 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof PostsIndexRouteImport
parentRoute: typeof PostsRoute
}
- '/_layout/_layout-2/layout-a': {
- id: '/_layout/_layout-2/layout-a'
- path: '/layout-a'
- fullPath: '/layout-a'
- preLoaderRoute: typeof LayoutLayout2LayoutARouteImport
- parentRoute: typeof LayoutLayout2Route
+ '/posts/$postId': {
+ id: '/posts/$postId'
+ path: '/$postId'
+ fullPath: '/posts/$postId'
+ preLoaderRoute: typeof PostsPostIdRouteImport
+ parentRoute: typeof PostsRoute
+ }
+ '/_layout/_layout-2': {
+ id: '/_layout/_layout-2'
+ path: ''
+ fullPath: ''
+ preLoaderRoute: typeof LayoutLayout2RouteImport
+ parentRoute: typeof LayoutRoute
}
'/_layout/_layout-2/layout-b': {
id: '/_layout/_layout-2/layout-b'
@@ -217,6 +210,13 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof LayoutLayout2LayoutBRouteImport
parentRoute: typeof LayoutLayout2Route
}
+ '/_layout/_layout-2/layout-a': {
+ id: '/_layout/_layout-2/layout-a'
+ path: '/layout-a'
+ fullPath: '/layout-a'
+ preLoaderRoute: typeof LayoutLayout2LayoutARouteImport
+ parentRoute: typeof LayoutLayout2Route
+ }
}
}
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-file-based/src/routeTree.gen.ts b/e2e/react-router/basic-file-based/src/routeTree.gen.ts
index e44ac41896..62af050d6e 100644
--- a/e2e/react-router/basic-file-based/src/routeTree.gen.ts
+++ b/e2e/react-router/basic-file-based/src/routeTree.gen.ts
@@ -23,6 +23,7 @@ import { Route as LayoutRouteImport } from './routes/_layout'
import { Route as SearchParamsRouteRouteImport } from './routes/search-params/route'
import { Route as IndexRouteImport } from './routes/index'
import { Route as SearchParamsIndexRouteImport } from './routes/search-params/index'
+import { Route as RelativeIndexRouteImport } from './routes/relative/index'
import { Route as RedirectIndexRouteImport } from './routes/redirect/index'
import { Route as PostsIndexRouteImport } from './routes/posts.index'
import { Route as ParamsPsIndexRouteImport } from './routes/params-ps/index'
@@ -35,9 +36,15 @@ import { Route as groupLazyinsideRouteImport } from './routes/(group)/lazyinside
import { Route as groupInsideRouteImport } from './routes/(group)/inside'
import { Route as groupLayoutRouteImport } from './routes/(group)/_layout'
import { Route as anotherGroupOnlyrouteinsideRouteImport } from './routes/(another-group)/onlyrouteinside'
+import { Route as RelativeUseNavigateRouteRouteImport } from './routes/relative/useNavigate/route'
+import { Route as RelativeLinkRouteRouteImport } from './routes/relative/link/route'
import { Route as RedirectTargetIndexRouteImport } from './routes/redirect/$target/index'
import { Route as ParamsPsWildcardIndexRouteImport } from './routes/params-ps/wildcard/index'
import { Route as ParamsPsNamedIndexRouteImport } from './routes/params-ps/named/index'
+import { Route as RelativeUseNavigateRelativeUseNavigateBRouteImport } from './routes/relative/useNavigate/relative-useNavigate-b'
+import { Route as RelativeUseNavigateRelativeUseNavigateARouteImport } from './routes/relative/useNavigate/relative-useNavigate-a'
+import { Route as RelativeLinkRelativeLinkBRouteImport } from './routes/relative/link/relative-link-b'
+import { Route as RelativeLinkRelativeLinkARouteImport } from './routes/relative/link/relative-link-a'
import { Route as RedirectPreloadThirdRouteImport } from './routes/redirect/preload/third'
import { Route as RedirectPreloadSecondRouteImport } from './routes/redirect/preload/second'
import { Route as RedirectPreloadFirstRouteImport } from './routes/redirect/preload/first'
@@ -55,6 +62,16 @@ import { Route as LayoutLayout2LayoutBRouteImport } from './routes/_layout/_layo
import { Route as LayoutLayout2LayoutARouteImport } from './routes/_layout/_layout-2/layout-a'
import { Route as groupSubfolderInsideRouteImport } from './routes/(group)/subfolder/inside'
import { Route as groupLayoutInsidelayoutRouteImport } from './routes/(group)/_layout.insidelayout'
+import { Route as RelativeUseNavigateWithSearchIndexRouteImport } from './routes/relative/useNavigate/with-search/index'
+import { Route as RelativeUseNavigatePathIndexRouteImport } from './routes/relative/useNavigate/path/index'
+import { Route as RelativeUseNavigateNestedIndexRouteImport } from './routes/relative/useNavigate/nested/index'
+import { Route as RelativeLinkWithSearchIndexRouteImport } from './routes/relative/link/with-search/index'
+import { Route as RelativeLinkPathIndexRouteImport } from './routes/relative/link/path/index'
+import { Route as RelativeLinkNestedIndexRouteImport } from './routes/relative/link/nested/index'
+import { Route as RelativeUseNavigatePathPathIndexRouteImport } from './routes/relative/useNavigate/path/$path/index'
+import { Route as RelativeUseNavigateNestedDeepIndexRouteImport } from './routes/relative/useNavigate/nested/deep/index'
+import { Route as RelativeLinkPathPathIndexRouteImport } from './routes/relative/link/path/$path/index'
+import { Route as RelativeLinkNestedDeepIndexRouteImport } from './routes/relative/link/nested/deep/index'
const groupRouteImport = createFileRoute('/(group)')()
@@ -122,6 +139,11 @@ const SearchParamsIndexRoute = SearchParamsIndexRouteImport.update({
path: '/',
getParentRoute: () => SearchParamsRouteRoute,
} as any)
+const RelativeIndexRoute = RelativeIndexRouteImport.update({
+ id: '/relative/',
+ path: '/relative/',
+ getParentRoute: () => rootRouteImport,
+} as any)
const RedirectIndexRoute = RedirectIndexRouteImport.update({
id: '/redirect/',
path: '/redirect/',
@@ -184,6 +206,17 @@ const anotherGroupOnlyrouteinsideRoute =
path: '/onlyrouteinside',
getParentRoute: () => rootRouteImport,
} as any)
+const RelativeUseNavigateRouteRoute =
+ RelativeUseNavigateRouteRouteImport.update({
+ id: '/relative/useNavigate',
+ path: '/relative/useNavigate',
+ getParentRoute: () => rootRouteImport,
+ } as any)
+const RelativeLinkRouteRoute = RelativeLinkRouteRouteImport.update({
+ id: '/relative/link',
+ path: '/relative/link',
+ getParentRoute: () => rootRouteImport,
+} as any)
const RedirectTargetIndexRoute = RedirectTargetIndexRouteImport.update({
id: '/',
path: '/',
@@ -199,6 +232,30 @@ const ParamsPsNamedIndexRoute = ParamsPsNamedIndexRouteImport.update({
path: '/params-ps/named/',
getParentRoute: () => rootRouteImport,
} as any)
+const RelativeUseNavigateRelativeUseNavigateBRoute =
+ RelativeUseNavigateRelativeUseNavigateBRouteImport.update({
+ id: '/relative-useNavigate-b',
+ path: '/relative-useNavigate-b',
+ getParentRoute: () => RelativeUseNavigateRouteRoute,
+ } as any)
+const RelativeUseNavigateRelativeUseNavigateARoute =
+ RelativeUseNavigateRelativeUseNavigateARouteImport.update({
+ id: '/relative-useNavigate-a',
+ path: '/relative-useNavigate-a',
+ getParentRoute: () => RelativeUseNavigateRouteRoute,
+ } as any)
+const RelativeLinkRelativeLinkBRoute =
+ RelativeLinkRelativeLinkBRouteImport.update({
+ id: '/relative-link-b',
+ path: '/relative-link-b',
+ getParentRoute: () => RelativeLinkRouteRoute,
+ } as any)
+const RelativeLinkRelativeLinkARoute =
+ RelativeLinkRelativeLinkARouteImport.update({
+ id: '/relative-link-a',
+ path: '/relative-link-a',
+ getParentRoute: () => RelativeLinkRouteRoute,
+ } as any)
const RedirectPreloadThirdRoute = RedirectPreloadThirdRouteImport.update({
id: '/redirect/preload/third',
path: '/redirect/preload/third',
@@ -289,6 +346,64 @@ const groupLayoutInsidelayoutRoute = groupLayoutInsidelayoutRouteImport.update({
path: '/insidelayout',
getParentRoute: () => groupLayoutRoute,
} as any)
+const RelativeUseNavigateWithSearchIndexRoute =
+ RelativeUseNavigateWithSearchIndexRouteImport.update({
+ id: '/with-search/',
+ path: '/with-search/',
+ getParentRoute: () => RelativeUseNavigateRouteRoute,
+ } as any)
+const RelativeUseNavigatePathIndexRoute =
+ RelativeUseNavigatePathIndexRouteImport.update({
+ id: '/path/',
+ path: '/path/',
+ getParentRoute: () => RelativeUseNavigateRouteRoute,
+ } as any)
+const RelativeUseNavigateNestedIndexRoute =
+ RelativeUseNavigateNestedIndexRouteImport.update({
+ id: '/nested/',
+ path: '/nested/',
+ getParentRoute: () => RelativeUseNavigateRouteRoute,
+ } as any)
+const RelativeLinkWithSearchIndexRoute =
+ RelativeLinkWithSearchIndexRouteImport.update({
+ id: '/with-search/',
+ path: '/with-search/',
+ getParentRoute: () => RelativeLinkRouteRoute,
+ } as any)
+const RelativeLinkPathIndexRoute = RelativeLinkPathIndexRouteImport.update({
+ id: '/path/',
+ path: '/path/',
+ getParentRoute: () => RelativeLinkRouteRoute,
+} as any)
+const RelativeLinkNestedIndexRoute = RelativeLinkNestedIndexRouteImport.update({
+ id: '/nested/',
+ path: '/nested/',
+ getParentRoute: () => RelativeLinkRouteRoute,
+} as any)
+const RelativeUseNavigatePathPathIndexRoute =
+ RelativeUseNavigatePathPathIndexRouteImport.update({
+ id: '/path/$path/',
+ path: '/path/$path/',
+ getParentRoute: () => RelativeUseNavigateRouteRoute,
+ } as any)
+const RelativeUseNavigateNestedDeepIndexRoute =
+ RelativeUseNavigateNestedDeepIndexRouteImport.update({
+ id: '/nested/deep/',
+ path: '/nested/deep/',
+ getParentRoute: () => RelativeUseNavigateRouteRoute,
+ } as any)
+const RelativeLinkPathPathIndexRoute =
+ RelativeLinkPathPathIndexRouteImport.update({
+ id: '/path/$path/',
+ path: '/path/$path/',
+ getParentRoute: () => RelativeLinkRouteRoute,
+ } as any)
+const RelativeLinkNestedDeepIndexRoute =
+ RelativeLinkNestedDeepIndexRouteImport.update({
+ id: '/nested/deep/',
+ path: '/nested/deep/',
+ getParentRoute: () => RelativeLinkRouteRoute,
+ } as any)
export interface FileRoutesByFullPath {
'/': typeof groupLayoutRouteWithChildren
@@ -301,6 +416,8 @@ export interface FileRoutesByFullPath {
'/posts': typeof PostsRouteWithChildren
'/remountDeps': typeof RemountDepsRoute
'/대한민국': typeof Char45824Char54620Char48124Char44397Route
+ '/relative/link': typeof RelativeLinkRouteRouteWithChildren
+ '/relative/useNavigate': typeof RelativeUseNavigateRouteRouteWithChildren
'/onlyrouteinside': typeof anotherGroupOnlyrouteinsideRoute
'/inside': typeof groupInsideRoute
'/lazyinside': typeof groupLazyinsideRoute
@@ -311,6 +428,7 @@ export interface FileRoutesByFullPath {
'/params-ps': typeof ParamsPsIndexRoute
'/posts/': typeof PostsIndexRoute
'/redirect': typeof RedirectIndexRoute
+ '/relative': typeof RelativeIndexRoute
'/search-params/': typeof SearchParamsIndexRoute
'/insidelayout': typeof groupLayoutInsidelayoutRoute
'/subfolder/inside': typeof groupSubfolderInsideRoute
@@ -329,9 +447,23 @@ export interface FileRoutesByFullPath {
'/redirect/preload/first': typeof RedirectPreloadFirstRoute
'/redirect/preload/second': typeof RedirectPreloadSecondRoute
'/redirect/preload/third': typeof RedirectPreloadThirdRoute
+ '/relative/link/relative-link-a': typeof RelativeLinkRelativeLinkARoute
+ '/relative/link/relative-link-b': typeof RelativeLinkRelativeLinkBRoute
+ '/relative/useNavigate/relative-useNavigate-a': typeof RelativeUseNavigateRelativeUseNavigateARoute
+ '/relative/useNavigate/relative-useNavigate-b': typeof RelativeUseNavigateRelativeUseNavigateBRoute
'/params-ps/named': typeof ParamsPsNamedIndexRoute
'/params-ps/wildcard': typeof ParamsPsWildcardIndexRoute
'/redirect/$target/': typeof RedirectTargetIndexRoute
+ '/relative/link/nested': typeof RelativeLinkNestedIndexRoute
+ '/relative/link/path': typeof RelativeLinkPathIndexRoute
+ '/relative/link/with-search': typeof RelativeLinkWithSearchIndexRoute
+ '/relative/useNavigate/nested': typeof RelativeUseNavigateNestedIndexRoute
+ '/relative/useNavigate/path': typeof RelativeUseNavigatePathIndexRoute
+ '/relative/useNavigate/with-search': typeof RelativeUseNavigateWithSearchIndexRoute
+ '/relative/link/nested/deep': typeof RelativeLinkNestedDeepIndexRoute
+ '/relative/link/path/$path': typeof RelativeLinkPathPathIndexRoute
+ '/relative/useNavigate/nested/deep': typeof RelativeUseNavigateNestedDeepIndexRoute
+ '/relative/useNavigate/path/$path': typeof RelativeUseNavigatePathPathIndexRoute
}
export interface FileRoutesByTo {
'/': typeof groupLayoutRouteWithChildren
@@ -342,6 +474,8 @@ export interface FileRoutesByTo {
'/notRemountDeps': typeof NotRemountDepsRoute
'/remountDeps': typeof RemountDepsRoute
'/대한민국': typeof Char45824Char54620Char48124Char44397Route
+ '/relative/link': typeof RelativeLinkRouteRouteWithChildren
+ '/relative/useNavigate': typeof RelativeUseNavigateRouteRouteWithChildren
'/onlyrouteinside': typeof anotherGroupOnlyrouteinsideRoute
'/inside': typeof groupInsideRoute
'/lazyinside': typeof groupLazyinsideRoute
@@ -351,6 +485,7 @@ export interface FileRoutesByTo {
'/params-ps': typeof ParamsPsIndexRoute
'/posts': typeof PostsIndexRoute
'/redirect': typeof RedirectIndexRoute
+ '/relative': typeof RelativeIndexRoute
'/search-params': typeof SearchParamsIndexRoute
'/insidelayout': typeof groupLayoutInsidelayoutRoute
'/subfolder/inside': typeof groupSubfolderInsideRoute
@@ -369,9 +504,23 @@ export interface FileRoutesByTo {
'/redirect/preload/first': typeof RedirectPreloadFirstRoute
'/redirect/preload/second': typeof RedirectPreloadSecondRoute
'/redirect/preload/third': typeof RedirectPreloadThirdRoute
+ '/relative/link/relative-link-a': typeof RelativeLinkRelativeLinkARoute
+ '/relative/link/relative-link-b': typeof RelativeLinkRelativeLinkBRoute
+ '/relative/useNavigate/relative-useNavigate-a': typeof RelativeUseNavigateRelativeUseNavigateARoute
+ '/relative/useNavigate/relative-useNavigate-b': typeof RelativeUseNavigateRelativeUseNavigateBRoute
'/params-ps/named': typeof ParamsPsNamedIndexRoute
'/params-ps/wildcard': typeof ParamsPsWildcardIndexRoute
'/redirect/$target': typeof RedirectTargetIndexRoute
+ '/relative/link/nested': typeof RelativeLinkNestedIndexRoute
+ '/relative/link/path': typeof RelativeLinkPathIndexRoute
+ '/relative/link/with-search': typeof RelativeLinkWithSearchIndexRoute
+ '/relative/useNavigate/nested': typeof RelativeUseNavigateNestedIndexRoute
+ '/relative/useNavigate/path': typeof RelativeUseNavigatePathIndexRoute
+ '/relative/useNavigate/with-search': typeof RelativeUseNavigateWithSearchIndexRoute
+ '/relative/link/nested/deep': typeof RelativeLinkNestedDeepIndexRoute
+ '/relative/link/path/$path': typeof RelativeLinkPathPathIndexRoute
+ '/relative/useNavigate/nested/deep': typeof RelativeUseNavigateNestedDeepIndexRoute
+ '/relative/useNavigate/path/$path': typeof RelativeUseNavigatePathPathIndexRoute
}
export interface FileRoutesById {
__root__: typeof rootRouteImport
@@ -386,6 +535,8 @@ export interface FileRoutesById {
'/posts': typeof PostsRouteWithChildren
'/remountDeps': typeof RemountDepsRoute
'/대한민국': typeof Char45824Char54620Char48124Char44397Route
+ '/relative/link': typeof RelativeLinkRouteRouteWithChildren
+ '/relative/useNavigate': typeof RelativeUseNavigateRouteRouteWithChildren
'/(another-group)/onlyrouteinside': typeof anotherGroupOnlyrouteinsideRoute
'/(group)': typeof groupRouteWithChildren
'/(group)/_layout': typeof groupLayoutRouteWithChildren
@@ -399,6 +550,7 @@ export interface FileRoutesById {
'/params-ps/': typeof ParamsPsIndexRoute
'/posts/': typeof PostsIndexRoute
'/redirect/': typeof RedirectIndexRoute
+ '/relative/': typeof RelativeIndexRoute
'/search-params/': typeof SearchParamsIndexRoute
'/(group)/_layout/insidelayout': typeof groupLayoutInsidelayoutRoute
'/(group)/subfolder/inside': typeof groupSubfolderInsideRoute
@@ -417,9 +569,23 @@ export interface FileRoutesById {
'/redirect/preload/first': typeof RedirectPreloadFirstRoute
'/redirect/preload/second': typeof RedirectPreloadSecondRoute
'/redirect/preload/third': typeof RedirectPreloadThirdRoute
+ '/relative/link/relative-link-a': typeof RelativeLinkRelativeLinkARoute
+ '/relative/link/relative-link-b': typeof RelativeLinkRelativeLinkBRoute
+ '/relative/useNavigate/relative-useNavigate-a': typeof RelativeUseNavigateRelativeUseNavigateARoute
+ '/relative/useNavigate/relative-useNavigate-b': typeof RelativeUseNavigateRelativeUseNavigateBRoute
'/params-ps/named/': typeof ParamsPsNamedIndexRoute
'/params-ps/wildcard/': typeof ParamsPsWildcardIndexRoute
'/redirect/$target/': typeof RedirectTargetIndexRoute
+ '/relative/link/nested/': typeof RelativeLinkNestedIndexRoute
+ '/relative/link/path/': typeof RelativeLinkPathIndexRoute
+ '/relative/link/with-search/': typeof RelativeLinkWithSearchIndexRoute
+ '/relative/useNavigate/nested/': typeof RelativeUseNavigateNestedIndexRoute
+ '/relative/useNavigate/path/': typeof RelativeUseNavigatePathIndexRoute
+ '/relative/useNavigate/with-search/': typeof RelativeUseNavigateWithSearchIndexRoute
+ '/relative/link/nested/deep/': typeof RelativeLinkNestedDeepIndexRoute
+ '/relative/link/path/$path/': typeof RelativeLinkPathPathIndexRoute
+ '/relative/useNavigate/nested/deep/': typeof RelativeUseNavigateNestedDeepIndexRoute
+ '/relative/useNavigate/path/$path/': typeof RelativeUseNavigatePathPathIndexRoute
}
export interface FileRouteTypes {
fileRoutesByFullPath: FileRoutesByFullPath
@@ -434,6 +600,8 @@ export interface FileRouteTypes {
| '/posts'
| '/remountDeps'
| '/대한민국'
+ | '/relative/link'
+ | '/relative/useNavigate'
| '/onlyrouteinside'
| '/inside'
| '/lazyinside'
@@ -444,6 +612,7 @@ export interface FileRouteTypes {
| '/params-ps'
| '/posts/'
| '/redirect'
+ | '/relative'
| '/search-params/'
| '/insidelayout'
| '/subfolder/inside'
@@ -462,9 +631,23 @@ export interface FileRouteTypes {
| '/redirect/preload/first'
| '/redirect/preload/second'
| '/redirect/preload/third'
+ | '/relative/link/relative-link-a'
+ | '/relative/link/relative-link-b'
+ | '/relative/useNavigate/relative-useNavigate-a'
+ | '/relative/useNavigate/relative-useNavigate-b'
| '/params-ps/named'
| '/params-ps/wildcard'
| '/redirect/$target/'
+ | '/relative/link/nested'
+ | '/relative/link/path'
+ | '/relative/link/with-search'
+ | '/relative/useNavigate/nested'
+ | '/relative/useNavigate/path'
+ | '/relative/useNavigate/with-search'
+ | '/relative/link/nested/deep'
+ | '/relative/link/path/$path'
+ | '/relative/useNavigate/nested/deep'
+ | '/relative/useNavigate/path/$path'
fileRoutesByTo: FileRoutesByTo
to:
| '/'
@@ -475,6 +658,8 @@ export interface FileRouteTypes {
| '/notRemountDeps'
| '/remountDeps'
| '/대한민국'
+ | '/relative/link'
+ | '/relative/useNavigate'
| '/onlyrouteinside'
| '/inside'
| '/lazyinside'
@@ -484,6 +669,7 @@ export interface FileRouteTypes {
| '/params-ps'
| '/posts'
| '/redirect'
+ | '/relative'
| '/search-params'
| '/insidelayout'
| '/subfolder/inside'
@@ -502,9 +688,23 @@ export interface FileRouteTypes {
| '/redirect/preload/first'
| '/redirect/preload/second'
| '/redirect/preload/third'
+ | '/relative/link/relative-link-a'
+ | '/relative/link/relative-link-b'
+ | '/relative/useNavigate/relative-useNavigate-a'
+ | '/relative/useNavigate/relative-useNavigate-b'
| '/params-ps/named'
| '/params-ps/wildcard'
| '/redirect/$target'
+ | '/relative/link/nested'
+ | '/relative/link/path'
+ | '/relative/link/with-search'
+ | '/relative/useNavigate/nested'
+ | '/relative/useNavigate/path'
+ | '/relative/useNavigate/with-search'
+ | '/relative/link/nested/deep'
+ | '/relative/link/path/$path'
+ | '/relative/useNavigate/nested/deep'
+ | '/relative/useNavigate/path/$path'
id:
| '__root__'
| '/'
@@ -518,6 +718,8 @@ export interface FileRouteTypes {
| '/posts'
| '/remountDeps'
| '/대한민국'
+ | '/relative/link'
+ | '/relative/useNavigate'
| '/(another-group)/onlyrouteinside'
| '/(group)'
| '/(group)/_layout'
@@ -531,6 +733,7 @@ export interface FileRouteTypes {
| '/params-ps/'
| '/posts/'
| '/redirect/'
+ | '/relative/'
| '/search-params/'
| '/(group)/_layout/insidelayout'
| '/(group)/subfolder/inside'
@@ -549,9 +752,23 @@ export interface FileRouteTypes {
| '/redirect/preload/first'
| '/redirect/preload/second'
| '/redirect/preload/third'
+ | '/relative/link/relative-link-a'
+ | '/relative/link/relative-link-b'
+ | '/relative/useNavigate/relative-useNavigate-a'
+ | '/relative/useNavigate/relative-useNavigate-b'
| '/params-ps/named/'
| '/params-ps/wildcard/'
| '/redirect/$target/'
+ | '/relative/link/nested/'
+ | '/relative/link/path/'
+ | '/relative/link/with-search/'
+ | '/relative/useNavigate/nested/'
+ | '/relative/useNavigate/path/'
+ | '/relative/useNavigate/with-search/'
+ | '/relative/link/nested/deep/'
+ | '/relative/link/path/$path/'
+ | '/relative/useNavigate/nested/deep/'
+ | '/relative/useNavigate/path/$path/'
fileRoutesById: FileRoutesById
}
export interface RootRouteChildren {
@@ -566,12 +783,15 @@ export interface RootRouteChildren {
PostsRoute: typeof PostsRouteWithChildren
RemountDepsRoute: typeof RemountDepsRoute
Char45824Char54620Char48124Char44397Route: typeof Char45824Char54620Char48124Char44397Route
+ RelativeLinkRouteRoute: typeof RelativeLinkRouteRouteWithChildren
+ RelativeUseNavigateRouteRoute: typeof RelativeUseNavigateRouteRouteWithChildren
anotherGroupOnlyrouteinsideRoute: typeof anotherGroupOnlyrouteinsideRoute
groupRoute: typeof groupRouteWithChildren
RedirectTargetRoute: typeof RedirectTargetRouteWithChildren
StructuralSharingEnabledRoute: typeof StructuralSharingEnabledRoute
ParamsPsIndexRoute: typeof ParamsPsIndexRoute
RedirectIndexRoute: typeof RedirectIndexRoute
+ RelativeIndexRoute: typeof RelativeIndexRoute
ParamsPsNamedFooRoute: typeof ParamsPsNamedFooRoute
ParamsPsNamedPrefixChar123fooChar125Route: typeof ParamsPsNamedPrefixChar123fooChar125Route
ParamsPsNamedChar123fooChar125suffixRoute: typeof ParamsPsNamedChar123fooChar125suffixRoute
@@ -680,6 +900,13 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof SearchParamsIndexRouteImport
parentRoute: typeof SearchParamsRouteRoute
}
+ '/relative/': {
+ id: '/relative/'
+ path: '/relative'
+ fullPath: '/relative'
+ preLoaderRoute: typeof RelativeIndexRouteImport
+ parentRoute: typeof rootRouteImport
+ }
'/redirect/': {
id: '/redirect/'
path: '/redirect'
@@ -764,6 +991,20 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof anotherGroupOnlyrouteinsideRouteImport
parentRoute: typeof rootRouteImport
}
+ '/relative/useNavigate': {
+ id: '/relative/useNavigate'
+ path: '/relative/useNavigate'
+ fullPath: '/relative/useNavigate'
+ preLoaderRoute: typeof RelativeUseNavigateRouteRouteImport
+ parentRoute: typeof rootRouteImport
+ }
+ '/relative/link': {
+ id: '/relative/link'
+ path: '/relative/link'
+ fullPath: '/relative/link'
+ preLoaderRoute: typeof RelativeLinkRouteRouteImport
+ parentRoute: typeof rootRouteImport
+ }
'/redirect/$target/': {
id: '/redirect/$target/'
path: '/'
@@ -785,6 +1026,34 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof ParamsPsNamedIndexRouteImport
parentRoute: typeof rootRouteImport
}
+ '/relative/useNavigate/relative-useNavigate-b': {
+ id: '/relative/useNavigate/relative-useNavigate-b'
+ path: '/relative-useNavigate-b'
+ fullPath: '/relative/useNavigate/relative-useNavigate-b'
+ preLoaderRoute: typeof RelativeUseNavigateRelativeUseNavigateBRouteImport
+ parentRoute: typeof RelativeUseNavigateRouteRoute
+ }
+ '/relative/useNavigate/relative-useNavigate-a': {
+ id: '/relative/useNavigate/relative-useNavigate-a'
+ path: '/relative-useNavigate-a'
+ fullPath: '/relative/useNavigate/relative-useNavigate-a'
+ preLoaderRoute: typeof RelativeUseNavigateRelativeUseNavigateARouteImport
+ parentRoute: typeof RelativeUseNavigateRouteRoute
+ }
+ '/relative/link/relative-link-b': {
+ id: '/relative/link/relative-link-b'
+ path: '/relative-link-b'
+ fullPath: '/relative/link/relative-link-b'
+ preLoaderRoute: typeof RelativeLinkRelativeLinkBRouteImport
+ parentRoute: typeof RelativeLinkRouteRoute
+ }
+ '/relative/link/relative-link-a': {
+ id: '/relative/link/relative-link-a'
+ path: '/relative-link-a'
+ fullPath: '/relative/link/relative-link-a'
+ preLoaderRoute: typeof RelativeLinkRelativeLinkARouteImport
+ parentRoute: typeof RelativeLinkRouteRoute
+ }
'/redirect/preload/third': {
id: '/redirect/preload/third'
path: '/redirect/preload/third'
@@ -904,6 +1173,76 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof groupLayoutInsidelayoutRouteImport
parentRoute: typeof groupLayoutRoute
}
+ '/relative/useNavigate/with-search/': {
+ id: '/relative/useNavigate/with-search/'
+ path: '/with-search'
+ fullPath: '/relative/useNavigate/with-search'
+ preLoaderRoute: typeof RelativeUseNavigateWithSearchIndexRouteImport
+ parentRoute: typeof RelativeUseNavigateRouteRoute
+ }
+ '/relative/useNavigate/path/': {
+ id: '/relative/useNavigate/path/'
+ path: '/path'
+ fullPath: '/relative/useNavigate/path'
+ preLoaderRoute: typeof RelativeUseNavigatePathIndexRouteImport
+ parentRoute: typeof RelativeUseNavigateRouteRoute
+ }
+ '/relative/useNavigate/nested/': {
+ id: '/relative/useNavigate/nested/'
+ path: '/nested'
+ fullPath: '/relative/useNavigate/nested'
+ preLoaderRoute: typeof RelativeUseNavigateNestedIndexRouteImport
+ parentRoute: typeof RelativeUseNavigateRouteRoute
+ }
+ '/relative/link/with-search/': {
+ id: '/relative/link/with-search/'
+ path: '/with-search'
+ fullPath: '/relative/link/with-search'
+ preLoaderRoute: typeof RelativeLinkWithSearchIndexRouteImport
+ parentRoute: typeof RelativeLinkRouteRoute
+ }
+ '/relative/link/path/': {
+ id: '/relative/link/path/'
+ path: '/path'
+ fullPath: '/relative/link/path'
+ preLoaderRoute: typeof RelativeLinkPathIndexRouteImport
+ parentRoute: typeof RelativeLinkRouteRoute
+ }
+ '/relative/link/nested/': {
+ id: '/relative/link/nested/'
+ path: '/nested'
+ fullPath: '/relative/link/nested'
+ preLoaderRoute: typeof RelativeLinkNestedIndexRouteImport
+ parentRoute: typeof RelativeLinkRouteRoute
+ }
+ '/relative/useNavigate/path/$path/': {
+ id: '/relative/useNavigate/path/$path/'
+ path: '/path/$path'
+ fullPath: '/relative/useNavigate/path/$path'
+ preLoaderRoute: typeof RelativeUseNavigatePathPathIndexRouteImport
+ parentRoute: typeof RelativeUseNavigateRouteRoute
+ }
+ '/relative/useNavigate/nested/deep/': {
+ id: '/relative/useNavigate/nested/deep/'
+ path: '/nested/deep'
+ fullPath: '/relative/useNavigate/nested/deep'
+ preLoaderRoute: typeof RelativeUseNavigateNestedDeepIndexRouteImport
+ parentRoute: typeof RelativeUseNavigateRouteRoute
+ }
+ '/relative/link/path/$path/': {
+ id: '/relative/link/path/$path/'
+ path: '/path/$path'
+ fullPath: '/relative/link/path/$path'
+ preLoaderRoute: typeof RelativeLinkPathPathIndexRouteImport
+ parentRoute: typeof RelativeLinkRouteRoute
+ }
+ '/relative/link/nested/deep/': {
+ id: '/relative/link/nested/deep/'
+ path: '/nested/deep'
+ fullPath: '/relative/link/nested/deep'
+ preLoaderRoute: typeof RelativeLinkNestedDeepIndexRouteImport
+ parentRoute: typeof RelativeLinkRouteRoute
+ }
}
}
@@ -957,6 +1296,60 @@ const PostsRouteChildren: PostsRouteChildren = {
const PostsRouteWithChildren = PostsRoute._addFileChildren(PostsRouteChildren)
+interface RelativeLinkRouteRouteChildren {
+ RelativeLinkRelativeLinkARoute: typeof RelativeLinkRelativeLinkARoute
+ RelativeLinkRelativeLinkBRoute: typeof RelativeLinkRelativeLinkBRoute
+ RelativeLinkNestedIndexRoute: typeof RelativeLinkNestedIndexRoute
+ RelativeLinkPathIndexRoute: typeof RelativeLinkPathIndexRoute
+ RelativeLinkWithSearchIndexRoute: typeof RelativeLinkWithSearchIndexRoute
+ RelativeLinkNestedDeepIndexRoute: typeof RelativeLinkNestedDeepIndexRoute
+ RelativeLinkPathPathIndexRoute: typeof RelativeLinkPathPathIndexRoute
+}
+
+const RelativeLinkRouteRouteChildren: RelativeLinkRouteRouteChildren = {
+ RelativeLinkRelativeLinkARoute: RelativeLinkRelativeLinkARoute,
+ RelativeLinkRelativeLinkBRoute: RelativeLinkRelativeLinkBRoute,
+ RelativeLinkNestedIndexRoute: RelativeLinkNestedIndexRoute,
+ RelativeLinkPathIndexRoute: RelativeLinkPathIndexRoute,
+ RelativeLinkWithSearchIndexRoute: RelativeLinkWithSearchIndexRoute,
+ RelativeLinkNestedDeepIndexRoute: RelativeLinkNestedDeepIndexRoute,
+ RelativeLinkPathPathIndexRoute: RelativeLinkPathPathIndexRoute,
+}
+
+const RelativeLinkRouteRouteWithChildren =
+ RelativeLinkRouteRoute._addFileChildren(RelativeLinkRouteRouteChildren)
+
+interface RelativeUseNavigateRouteRouteChildren {
+ RelativeUseNavigateRelativeUseNavigateARoute: typeof RelativeUseNavigateRelativeUseNavigateARoute
+ RelativeUseNavigateRelativeUseNavigateBRoute: typeof RelativeUseNavigateRelativeUseNavigateBRoute
+ RelativeUseNavigateNestedIndexRoute: typeof RelativeUseNavigateNestedIndexRoute
+ RelativeUseNavigatePathIndexRoute: typeof RelativeUseNavigatePathIndexRoute
+ RelativeUseNavigateWithSearchIndexRoute: typeof RelativeUseNavigateWithSearchIndexRoute
+ RelativeUseNavigateNestedDeepIndexRoute: typeof RelativeUseNavigateNestedDeepIndexRoute
+ RelativeUseNavigatePathPathIndexRoute: typeof RelativeUseNavigatePathPathIndexRoute
+}
+
+const RelativeUseNavigateRouteRouteChildren: RelativeUseNavigateRouteRouteChildren =
+ {
+ RelativeUseNavigateRelativeUseNavigateARoute:
+ RelativeUseNavigateRelativeUseNavigateARoute,
+ RelativeUseNavigateRelativeUseNavigateBRoute:
+ RelativeUseNavigateRelativeUseNavigateBRoute,
+ RelativeUseNavigateNestedIndexRoute: RelativeUseNavigateNestedIndexRoute,
+ RelativeUseNavigatePathIndexRoute: RelativeUseNavigatePathIndexRoute,
+ RelativeUseNavigateWithSearchIndexRoute:
+ RelativeUseNavigateWithSearchIndexRoute,
+ RelativeUseNavigateNestedDeepIndexRoute:
+ RelativeUseNavigateNestedDeepIndexRoute,
+ RelativeUseNavigatePathPathIndexRoute:
+ RelativeUseNavigatePathPathIndexRoute,
+ }
+
+const RelativeUseNavigateRouteRouteWithChildren =
+ RelativeUseNavigateRouteRoute._addFileChildren(
+ RelativeUseNavigateRouteRouteChildren,
+ )
+
interface groupLayoutRouteChildren {
groupLayoutInsidelayoutRoute: typeof groupLayoutInsidelayoutRoute
}
@@ -1014,12 +1407,15 @@ const rootRouteChildren: RootRouteChildren = {
RemountDepsRoute: RemountDepsRoute,
Char45824Char54620Char48124Char44397Route:
Char45824Char54620Char48124Char44397Route,
+ RelativeLinkRouteRoute: RelativeLinkRouteRouteWithChildren,
+ RelativeUseNavigateRouteRoute: RelativeUseNavigateRouteRouteWithChildren,
anotherGroupOnlyrouteinsideRoute: anotherGroupOnlyrouteinsideRoute,
groupRoute: groupRouteWithChildren,
RedirectTargetRoute: RedirectTargetRouteWithChildren,
StructuralSharingEnabledRoute: StructuralSharingEnabledRoute,
ParamsPsIndexRoute: ParamsPsIndexRoute,
RedirectIndexRoute: RedirectIndexRoute,
+ RelativeIndexRoute: RelativeIndexRoute,
ParamsPsNamedFooRoute: ParamsPsNamedFooRoute,
ParamsPsNamedPrefixChar123fooChar125Route:
ParamsPsNamedPrefixChar123fooChar125Route,
diff --git a/e2e/react-router/basic-file-based/src/routes/__root.tsx b/e2e/react-router/basic-file-based/src/routes/__root.tsx
index 4062165c86..06734a3b95 100644
--- a/e2e/react-router/basic-file-based/src/routes/__root.tsx
+++ b/e2e/react-router/basic-file-based/src/routes/__root.tsx
@@ -122,6 +122,14 @@ function RootComponent() {
>
redirect
{' '}
+
+ relative routing
+ {' '}
+
+ Relative Routing Tests - Home
+
+
+ Using Links
+ Using useNavigate
+
+
+
+
+
+ )
+}
diff --git a/e2e/react-router/basic-file-based/src/routes/relative/link/nested/deep/index.tsx b/e2e/react-router/basic-file-based/src/routes/relative/link/nested/deep/index.tsx
new file mode 100644
index 0000000000..5cc4b4e58a
--- /dev/null
+++ b/e2e/react-router/basic-file-based/src/routes/relative/link/nested/deep/index.tsx
@@ -0,0 +1,13 @@
+import { createFileRoute } from '@tanstack/react-router'
+
+export const Route = createFileRoute('/relative/link/nested/deep/')({
+ component: RouteComponent,
+})
+
+function RouteComponent() {
+ return (
+
+ Hello "/relative/link/nested/deep/"!
+
+ )
+}
diff --git a/e2e/react-router/basic-file-based/src/routes/relative/link/nested/index.tsx b/e2e/react-router/basic-file-based/src/routes/relative/link/nested/index.tsx
new file mode 100644
index 0000000000..afca201e02
--- /dev/null
+++ b/e2e/react-router/basic-file-based/src/routes/relative/link/nested/index.tsx
@@ -0,0 +1,13 @@
+import { createFileRoute } from '@tanstack/react-router'
+
+export const Route = createFileRoute('/relative/link/nested/')({
+ component: RouteComponent,
+})
+
+function RouteComponent() {
+ return (
+
+ Hello "/relative/link/nested/"!
+
+ )
+}
diff --git a/e2e/react-router/basic-file-based/src/routes/relative/link/path/$path/index.tsx b/e2e/react-router/basic-file-based/src/routes/relative/link/path/$path/index.tsx
new file mode 100644
index 0000000000..30b13cb09d
--- /dev/null
+++ b/e2e/react-router/basic-file-based/src/routes/relative/link/path/$path/index.tsx
@@ -0,0 +1,31 @@
+import { Link, createFileRoute } from '@tanstack/react-router'
+
+export const Route = createFileRoute('/relative/link/path/$path/')({
+ component: RouteComponent,
+ loader: ({ params }) => {
+ return params
+ },
+})
+
+function RouteComponent() {
+ const { path } = Route.useParams()
+
+ return (
+
+
+ Hello from "/relative/links/path/{path}"!
+
+
+
+ To {path === 'a' ? 'b' : 'a'}
+
+
+
+ )
+}
diff --git a/e2e/react-router/basic-file-based/src/routes/relative/link/path/index.tsx b/e2e/react-router/basic-file-based/src/routes/relative/link/path/index.tsx
new file mode 100644
index 0000000000..be1c7b7a47
--- /dev/null
+++ b/e2e/react-router/basic-file-based/src/routes/relative/link/path/index.tsx
@@ -0,0 +1,18 @@
+import { Outlet, createFileRoute } from '@tanstack/react-router'
+
+export const Route = createFileRoute('/relative/link/path/')({
+ component: RouteComponent,
+})
+
+function RouteComponent() {
+ return (
+
+
+ Relative Routing Tests - Path Params
+
+
+
+
+
+ )
+}
diff --git a/e2e/react-router/basic-file-based/src/routes/relative/link/relative-link-a.tsx b/e2e/react-router/basic-file-based/src/routes/relative/link/relative-link-a.tsx
new file mode 100644
index 0000000000..72a1ee20ec
--- /dev/null
+++ b/e2e/react-router/basic-file-based/src/routes/relative/link/relative-link-a.tsx
@@ -0,0 +1,13 @@
+import { createFileRoute } from '@tanstack/react-router'
+
+export const Route = createFileRoute('/relative/link/relative-link-a')({
+ component: RouteComponent,
+})
+
+function RouteComponent() {
+ return (
+
+ Hello "/relative/link/relative-link-a"!
+
+ )
+}
diff --git a/e2e/react-router/basic-file-based/src/routes/relative/link/relative-link-b.tsx b/e2e/react-router/basic-file-based/src/routes/relative/link/relative-link-b.tsx
new file mode 100644
index 0000000000..e751331b3f
--- /dev/null
+++ b/e2e/react-router/basic-file-based/src/routes/relative/link/relative-link-b.tsx
@@ -0,0 +1,13 @@
+import { createFileRoute } from '@tanstack/react-router'
+
+export const Route = createFileRoute('/relative/link/relative-link-b')({
+ component: RouteComponent,
+})
+
+function RouteComponent() {
+ return (
+
+ Hello "/relative/link/relative-link-b"!
+
+ )
+}
diff --git a/e2e/react-router/basic-file-based/src/routes/relative/link/route.tsx b/e2e/react-router/basic-file-based/src/routes/relative/link/route.tsx
new file mode 100644
index 0000000000..ae3193613f
--- /dev/null
+++ b/e2e/react-router/basic-file-based/src/routes/relative/link/route.tsx
@@ -0,0 +1,103 @@
+import {
+ Link,
+ Outlet,
+ createFileRoute,
+ useNavigate,
+} from '@tanstack/react-router'
+import { useEffect } from 'react'
+
+export const Route = createFileRoute('/relative/link')({
+ component: RouteComponent,
+})
+
+function RouteComponent() {
+ const navigate = useNavigate()
+
+ useEffect(() => {
+ console.log('navigate')
+ }, [navigate])
+
+ return (
+
+
+ Relative Routing - Links - Index
+
+
+
+ Return To Home
+
+
+ Return To Index
+
+
+ Reload
+
+
+ Back
+
+
+ To Relative Link A
+
+
+ To Relative Link B
+
+
+ To Deeply Nested
+
+
+ To Path Param A
+
+
+ To With Search Params
+
+
+
+
+
+
+ )
+}
diff --git a/e2e/react-router/basic-file-based/src/routes/relative/link/with-search/index.tsx b/e2e/react-router/basic-file-based/src/routes/relative/link/with-search/index.tsx
new file mode 100644
index 0000000000..9891d26cc0
--- /dev/null
+++ b/e2e/react-router/basic-file-based/src/routes/relative/link/with-search/index.tsx
@@ -0,0 +1,28 @@
+import { Link, createFileRoute } from '@tanstack/react-router'
+import { z } from 'zod'
+
+export const Route = createFileRoute('/relative/link/with-search/')({
+ component: RouteComponent,
+ validateSearch: z.object({
+ searchParam: z.string().default('1'),
+ }),
+})
+
+function RouteComponent() {
+ const { searchParam } = Route.useSearch()
+ return (
+ <>
+
+ Hello "/relative/link/with-search/" searchParam: {searchParam}!
+
+
+
+ Update Search
+
+ >
+ )
+}
diff --git a/e2e/react-router/basic-file-based/src/routes/relative/useNavigate/nested/deep/index.tsx b/e2e/react-router/basic-file-based/src/routes/relative/useNavigate/nested/deep/index.tsx
new file mode 100644
index 0000000000..453a088d63
--- /dev/null
+++ b/e2e/react-router/basic-file-based/src/routes/relative/useNavigate/nested/deep/index.tsx
@@ -0,0 +1,13 @@
+import { createFileRoute } from '@tanstack/react-router'
+
+export const Route = createFileRoute('/relative/useNavigate/nested/deep/')({
+ component: RouteComponent,
+})
+
+function RouteComponent() {
+ return (
+
+ Hello "/relative/useNavigate/nested/deep/"!
+
+ )
+}
diff --git a/e2e/react-router/basic-file-based/src/routes/relative/useNavigate/nested/index.tsx b/e2e/react-router/basic-file-based/src/routes/relative/useNavigate/nested/index.tsx
new file mode 100644
index 0000000000..ace502df18
--- /dev/null
+++ b/e2e/react-router/basic-file-based/src/routes/relative/useNavigate/nested/index.tsx
@@ -0,0 +1,13 @@
+import { createFileRoute } from '@tanstack/react-router'
+
+export const Route = createFileRoute('/relative/useNavigate/nested/')({
+ component: RouteComponent,
+})
+
+function RouteComponent() {
+ return (
+
+ Hello "/relative/useNavigate/nested/"!
+
+ )
+}
diff --git a/e2e/react-router/basic-file-based/src/routes/relative/useNavigate/path/$path/index.tsx b/e2e/react-router/basic-file-based/src/routes/relative/useNavigate/path/$path/index.tsx
new file mode 100644
index 0000000000..2e6d4c59de
--- /dev/null
+++ b/e2e/react-router/basic-file-based/src/routes/relative/useNavigate/path/$path/index.tsx
@@ -0,0 +1,40 @@
+import { createFileRoute, useNavigate } from '@tanstack/react-router'
+
+export const Route = createFileRoute('/relative/useNavigate/path/$path/')({
+ component: RouteComponent,
+ loader: ({ params }) => {
+ return params
+ },
+})
+
+function RouteComponent() {
+ const navigate = useNavigate()
+
+ const { path } = Route.useParams()
+
+ return (
+
+
+ Hello from "/relative/useNavigate/path/{path}"!
+
+
+
+ navigate({
+ from: '/relative/useNavigate/path',
+ to: './$path',
+ params: { path: path === 'a' ? 'b' : 'a' },
+ })
+ }
+ className="mr-2"
+ data-testid="relative-useNavigate-path-param-switchAB"
+ >
+ To {path === 'a' ? 'b' : 'a'}
+
+
+
+ )
+}
diff --git a/e2e/react-router/basic-file-based/src/routes/relative/useNavigate/path/index.tsx b/e2e/react-router/basic-file-based/src/routes/relative/useNavigate/path/index.tsx
new file mode 100644
index 0000000000..18abb4af18
--- /dev/null
+++ b/e2e/react-router/basic-file-based/src/routes/relative/useNavigate/path/index.tsx
@@ -0,0 +1,18 @@
+import { Outlet, createFileRoute } from '@tanstack/react-router'
+
+export const Route = createFileRoute('/relative/useNavigate/path/')({
+ component: RouteComponent,
+})
+
+function RouteComponent() {
+ return (
+
+
+ Relative Routing Tests - Path Params
+
+
+
+
+
+ )
+}
diff --git a/e2e/react-router/basic-file-based/src/routes/relative/useNavigate/relative-useNavigate-a.tsx b/e2e/react-router/basic-file-based/src/routes/relative/useNavigate/relative-useNavigate-a.tsx
new file mode 100644
index 0000000000..e236d80f63
--- /dev/null
+++ b/e2e/react-router/basic-file-based/src/routes/relative/useNavigate/relative-useNavigate-a.tsx
@@ -0,0 +1,15 @@
+import { createFileRoute } from '@tanstack/react-router'
+
+export const Route = createFileRoute(
+ '/relative/useNavigate/relative-useNavigate-a',
+)({
+ component: RouteComponent,
+})
+
+function RouteComponent() {
+ return (
+
+ Hello "/relative/useNavigate/relative-useNavigate-a"!
+
+ )
+}
diff --git a/e2e/react-router/basic-file-based/src/routes/relative/useNavigate/relative-useNavigate-b.tsx b/e2e/react-router/basic-file-based/src/routes/relative/useNavigate/relative-useNavigate-b.tsx
new file mode 100644
index 0000000000..b6e1d607dd
--- /dev/null
+++ b/e2e/react-router/basic-file-based/src/routes/relative/useNavigate/relative-useNavigate-b.tsx
@@ -0,0 +1,15 @@
+import { createFileRoute } from '@tanstack/react-router'
+
+export const Route = createFileRoute(
+ '/relative/useNavigate/relative-useNavigate-b',
+)({
+ component: RouteComponent,
+})
+
+function RouteComponent() {
+ return (
+
+ Hello "/relative/useNavigate/relative-useNavigate-b"!
+
+ )
+}
diff --git a/e2e/react-router/basic-file-based/src/routes/relative/useNavigate/route.tsx b/e2e/react-router/basic-file-based/src/routes/relative/useNavigate/route.tsx
new file mode 100644
index 0000000000..567df92e8b
--- /dev/null
+++ b/e2e/react-router/basic-file-based/src/routes/relative/useNavigate/route.tsx
@@ -0,0 +1,134 @@
+import { Outlet, createFileRoute, useNavigate } from '@tanstack/react-router'
+import { useEffect } from 'react'
+
+export const Route = createFileRoute('/relative/useNavigate')({
+ component: RouteComponent,
+})
+
+function RouteComponent() {
+ const navigate = useNavigate()
+
+ useEffect(() => {
+ console.log('navigate')
+ }, [navigate])
+
+ return (
+
+
+ Relative Routing - Links - Index
+
+
+
+ navigate({
+ from: '/relative/useNavigate',
+ to: '..',
+ })
+ }
+ data-testid="relative-useNavigate-home"
+ className="mr-2 underline"
+ >
+ Return To Home
+
+
+ navigate({
+ from: '/relative/useNavigate',
+ to: '.',
+ })
+ }
+ data-testid="relative-useNavigate-index"
+ className="mr-2 underline"
+ >
+ Return To Index
+
+
+ navigate({
+ to: '.',
+ })
+ }
+ data-testid="relative-useNavigate-reload"
+ className="mr-2 underline"
+ >
+ Reload
+
+
+ navigate({
+ to: '..',
+ })
+ }
+ data-testid="relative-useNavigate-back"
+ className="mr-2 underline"
+ >
+ Back
+
+
+ navigate({
+ from: '/relative/useNavigate',
+ to: './relative-useNavigate-a',
+ })
+ }
+ data-testid="relative-useNavigate-a"
+ className="mr-2 underline"
+ >
+ To Relative useNavigate A
+
+
+ navigate({
+ from: '/relative/useNavigate',
+ to: './relative-useNavigate-b',
+ })
+ }
+ data-testid="relative-useNavigate-b"
+ className="mr-2 underline"
+ >
+ To Relative Link B
+
+
+ navigate({
+ from: '/relative/useNavigate',
+ to: './nested/deep',
+ })
+ }
+ data-testid="relative-useNavigate-deeply-nested"
+ className="mr-2 underline"
+ >
+ To Deeply Nested
+
+
+ navigate({
+ to: '/relative/useNavigate/path/$path',
+ params: { path: 'a' },
+ })
+ }
+ data-testid="relative-useNavigate-path"
+ className="mr-2 underline"
+ >
+ To Path Param A
+
+
+ navigate({
+ from: '/relative/useNavigate',
+ to: './with-search',
+ search: { searchParam: '1' },
+ })
+ }
+ data-testid="relative-useNavigate-withSearch"
+ className="mr-2 underline"
+ >
+ To With Search Params
+
+
+
+
+
+
+ )
+}
diff --git a/e2e/react-router/basic-file-based/src/routes/relative/useNavigate/with-search/index.tsx b/e2e/react-router/basic-file-based/src/routes/relative/useNavigate/with-search/index.tsx
new file mode 100644
index 0000000000..7342202e1d
--- /dev/null
+++ b/e2e/react-router/basic-file-based/src/routes/relative/useNavigate/with-search/index.tsx
@@ -0,0 +1,34 @@
+import { createFileRoute, useNavigate } from '@tanstack/react-router'
+import { z } from 'zod'
+
+export const Route = createFileRoute('/relative/useNavigate/with-search/')({
+ component: RouteComponent,
+ validateSearch: z.object({
+ searchParam: z.string().default('1'),
+ }),
+})
+
+function RouteComponent() {
+ const navigate = useNavigate()
+ const { searchParam } = Route.useSearch()
+
+ return (
+ <>
+
+ Hello "/relative/useNavigate/with-search/" searchParam: {searchParam}!
+
+
+
+ navigate({
+ to: '.',
+ search: { searchParam: '2' },
+ })
+ }
+ data-testid="relative-useNavigate-withSearch-update-param"
+ >
+ Update Search
+
+ >
+ )
+}
diff --git a/e2e/react-router/basic-file-based/tests/relative.spec.ts b/e2e/react-router/basic-file-based/tests/relative.spec.ts
new file mode 100644
index 0000000000..4850d3630d
--- /dev/null
+++ b/e2e/react-router/basic-file-based/tests/relative.spec.ts
@@ -0,0 +1,273 @@
+import { expect, test } from '@playwright/test'
+import combinateImport from 'combinate'
+import { getTestServerPort } from '@tanstack/router-e2e-utils'
+import packageJson from '../package.json' with { type: 'json' }
+
+// somehow playwright does not correctly import default exports
+const combinate = (combinateImport as any).default as typeof combinateImport
+
+const PORT = await getTestServerPort(packageJson.name)
+
+test.describe('relative_routing', () => {
+ const internalNavigationTestMatrix = combinate({
+ navigation: ['link', 'useNavigate'] as const,
+ })
+
+ internalNavigationTestMatrix.forEach(({ navigation }) => {
+ test(`simple relative navigation. navigation: ${navigation}`, async ({
+ page,
+ }) => {
+ await page.waitForLoadState('networkidle')
+ await page.goto(`/relative/${navigation}`)
+ await page.waitForURL(`http://localhost:${PORT}/relative/${navigation}`)
+
+ await expect(
+ page.getByTestId(`relative-${navigation}-header`),
+ ).toBeInViewport()
+
+ const indexLink = page.getByTestId(`relative-${navigation}-index`)
+ const backLink = page.getByTestId(`relative-${navigation}-back`)
+ const relativeRouteA = page.getByTestId(`relative-${navigation}-a`)
+ const relativeRouteB = page.getByTestId(`relative-${navigation}-b`)
+
+ await relativeRouteA.click()
+
+ await page.waitForURL(
+ `http://localhost:${PORT}/relative/${navigation}/relative-${navigation}-a`,
+ )
+
+ await expect(
+ page.getByTestId(`relative-${navigation}-header`),
+ ).toBeInViewport()
+
+ await expect(
+ page.getByTestId(`relative-${navigation}-a-header`),
+ ).toBeInViewport()
+
+ await relativeRouteB.click()
+
+ await page.waitForURL(
+ `http://localhost:${PORT}/relative/${navigation}/relative-${navigation}-b`,
+ )
+
+ await expect(
+ page.getByTestId(`relative-${navigation}-header`),
+ ).toBeInViewport()
+
+ await expect(
+ page.getByTestId(`relative-${navigation}-b-header`),
+ ).toBeInViewport()
+
+ await indexLink.click()
+
+ await page.waitForURL(`http://localhost:${PORT}/relative/${navigation}`)
+
+ await expect(
+ page.getByTestId(`relative-${navigation}-header`),
+ ).toBeInViewport()
+
+ await expect(
+ page.getByTestId(`relative-${navigation}-b-header`),
+ ).not.toBeInViewport()
+
+ await backLink.click()
+
+ await page.waitForURL(`http://localhost:${PORT}/relative`)
+
+ await expect(page.getByTestId(`relative-routing-home`)).toBeInViewport()
+ })
+
+ test(`nested chilren. navigation: ${navigation}`, async ({ page }) => {
+ await page.waitForLoadState('networkidle')
+ await page.goto(`/relative/${navigation}`)
+ await page.waitForURL(`http://localhost:${PORT}/relative/${navigation}`)
+
+ await expect(
+ page.getByTestId(`relative-${navigation}-header`),
+ ).toBeInViewport()
+
+ const backLink = page.getByTestId(`relative-${navigation}-back`)
+
+ const deeplyNestedChildRoute = page.getByTestId(
+ `relative-${navigation}-deeply-nested`,
+ )
+
+ await deeplyNestedChildRoute.click()
+
+ await page.waitForURL(
+ `http://localhost:${PORT}/relative/${navigation}/nested/deep`,
+ )
+
+ await expect(
+ page.getByTestId(`relative-${navigation}-nested-deep-header`),
+ ).toBeInViewport()
+
+ await backLink.click()
+
+ await page.waitForURL(
+ `http://localhost:${PORT}/relative/${navigation}/nested`,
+ )
+
+ await expect(
+ page.getByTestId(`relative-${navigation}-nested-header`),
+ ).toBeInViewport()
+ })
+
+ test(`with path params. navigation: ${navigation}`, async ({ page }) => {
+ await page.waitForLoadState('networkidle')
+ await page.goto(`/relative/${navigation}`)
+ await page.waitForURL(`http://localhost:${PORT}/relative/${navigation}`)
+
+ await expect(
+ page.getByTestId(`relative-${navigation}-header`),
+ ).toBeInViewport()
+
+ const pathParamRoute = page.getByTestId(`relative-${navigation}-path`)
+
+ await pathParamRoute.click()
+
+ await page.waitForURL(
+ `http://localhost:${PORT}/relative/${navigation}/path/a`,
+ )
+
+ expect(page.url().endsWith('/path/a')).toBe(true)
+
+ await expect(
+ page.getByTestId(`relative-${navigation}-path-param-header`),
+ ).toBeInViewport()
+
+ const switchParamLink = page.getByTestId(
+ `relative-${navigation}-path-param-switchAB`,
+ )
+
+ await switchParamLink.click()
+
+ await page.waitForURL(
+ `http://localhost:${PORT}/relative/${navigation}/path/b`,
+ )
+
+ expect(page.url().endsWith('/path/b')).toBe(true)
+
+ await expect(
+ page.getByTestId(`relative-${navigation}-path-param-header`),
+ ).toBeInViewport()
+ })
+
+ test(`with search params. navigation: ${navigation}`, async ({ page }) => {
+ await page.waitForLoadState('networkidle')
+ await page.goto(`/relative/${navigation}`)
+ await page.waitForURL(`http://localhost:${PORT}/relative/${navigation}`)
+
+ await expect(
+ page.getByTestId(`relative-${navigation}-header`),
+ ).toBeInViewport()
+
+ const searchParamRoute = page.getByTestId(
+ `relative-${navigation}-withSearch`,
+ )
+
+ await searchParamRoute.click()
+
+ let expectedUrl = new URL(
+ `http://localhost:${PORT}/relative/${navigation}/with-search?searchParam="1"`,
+ )
+
+ await page.waitForLoadState('domcontentloaded')
+
+ expect(page.url().toString()).toBe(expectedUrl.toString())
+
+ await expect(
+ page.getByTestId(`relative-${navigation}-withSearch-header`),
+ ).toBeInViewport()
+
+ await expect(
+ page.getByTestId(`relative-${navigation}-withSearch-header`),
+ ).toContainText('searchParam: 1')
+
+ const updateSearchLink = page.getByTestId(
+ `relative-${navigation}-withSearch-update-param`,
+ )
+
+ await updateSearchLink.click()
+
+ await page.waitForLoadState('domcontentloaded')
+
+ expectedUrl = new URL(
+ `http://localhost:${PORT}/relative/${navigation}/with-search?searchParam="2"`,
+ )
+
+ expect(page.url().toString()).toBe(expectedUrl.toString())
+
+ await expect(
+ page.getByTestId(`relative-${navigation}-withSearch-header`),
+ ).toContainText('searchParam: 2')
+
+ await expect(
+ page.getByTestId(`relative-${navigation}-withSearch-header`),
+ ).toBeInViewport()
+ })
+
+ test(`shouldn't cause excessive rendering. navigation: ${navigation}`, async ({
+ page,
+ }) => {
+ let navigateMsgs = 0
+
+ page.on('console', (msg) => {
+ if (msg.text() === 'navigate') {
+ navigateMsgs++
+ }
+ })
+
+ await page.waitForLoadState('networkidle')
+ await page.goto(`/relative/${navigation}`)
+ await page.waitForURL(`http://localhost:${PORT}/relative/${navigation}`)
+
+ await expect(
+ page.getByTestId(`relative-${navigation}-header`),
+ ).toBeInViewport()
+
+ expect(navigateMsgs).toBe(1)
+ const indexLink = page.getByTestId(`relative-${navigation}-index`)
+ const backLink = page.getByTestId(`relative-${navigation}-back`)
+ const relativeRouteA = page.getByTestId(`relative-${navigation}-a`)
+ const relativeRouteB = page.getByTestId(`relative-${navigation}-b`)
+ const deeplyNestedChildRoute = page.getByTestId(
+ `relative-${navigation}-deeply-nested`,
+ )
+ const pathParamRoute = page.getByTestId(`relative-${navigation}-path`)
+ const searchParamRoute = page.getByTestId(
+ `relative-${navigation}-withSearch`,
+ )
+
+ await relativeRouteA.click()
+ await page.waitForLoadState('domcontentloaded')
+ await relativeRouteB.click()
+ await page.waitForLoadState('domcontentloaded')
+ await deeplyNestedChildRoute.click()
+ await page.waitForLoadState('domcontentloaded')
+ await backLink.click()
+ await page.waitForLoadState('domcontentloaded')
+ await pathParamRoute.click()
+ await page.waitForLoadState('domcontentloaded')
+ const switchParamLink = page.getByTestId(
+ `relative-${navigation}-path-param-switchAB`,
+ )
+ await switchParamLink.click()
+ await page.waitForLoadState('domcontentloaded')
+ await searchParamRoute.click()
+ await page.waitForLoadState('domcontentloaded')
+
+ const updateSearchLink = page.getByTestId(
+ `relative-${navigation}-withSearch-update-param`,
+ )
+
+ await updateSearchLink.click()
+ await page.waitForLoadState('domcontentloaded')
+
+ await indexLink.click()
+ await page.waitForLoadState('domcontentloaded')
+
+ expect(navigateMsgs).toBe(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-file-based/src/routeTree.gen.ts b/e2e/react-router/basic-virtual-file-based/src/routeTree.gen.ts
index e5756ba8d7..ab3e216c96 100644
--- a/e2e/react-router/basic-virtual-file-based/src/routeTree.gen.ts
+++ b/e2e/react-router/basic-virtual-file-based/src/routeTree.gen.ts
@@ -168,11 +168,11 @@ export interface RootRouteChildren {
declare module '@tanstack/react-router' {
interface FileRoutesByPath {
- '/': {
- id: '/'
- path: '/'
- fullPath: '/'
- preLoaderRoute: typeof homeRouteImport
+ '/posts': {
+ id: '/posts'
+ path: '/posts'
+ fullPath: '/posts'
+ preLoaderRoute: typeof postsPostsRouteImport
parentRoute: typeof rootRouteImport
}
'/_first': {
@@ -182,25 +182,18 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof layoutFirstLayoutRouteImport
parentRoute: typeof rootRouteImport
}
- '/posts': {
- id: '/posts'
- path: '/posts'
- fullPath: '/posts'
- preLoaderRoute: typeof postsPostsRouteImport
- parentRoute: typeof rootRouteImport
- }
- '/classic/hello': {
- id: '/classic/hello'
- path: '/classic/hello'
- fullPath: '/classic/hello'
- preLoaderRoute: typeof ClassicHelloRouteRouteImport
- parentRoute: typeof rootRouteImport
- }
- '/posts/': {
- id: '/posts/'
+ '/': {
+ id: '/'
path: '/'
- fullPath: '/posts/'
- preLoaderRoute: typeof postsPostsHomeRouteImport
+ fullPath: '/'
+ preLoaderRoute: typeof homeRouteImport
+ parentRoute: typeof rootRouteImport
+ }
+ '/posts/$postId': {
+ id: '/posts/$postId'
+ path: '/$postId'
+ fullPath: '/posts/$postId'
+ preLoaderRoute: typeof postsPostsDetailRouteImport
parentRoute: typeof postsPostsRoute
}
'/_first/_second': {
@@ -210,32 +203,25 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof layoutSecondLayoutRouteImport
parentRoute: typeof layoutFirstLayoutRoute
}
- '/posts/$postId': {
- id: '/posts/$postId'
- path: '/$postId'
- fullPath: '/posts/$postId'
- preLoaderRoute: typeof postsPostsDetailRouteImport
+ '/posts/': {
+ id: '/posts/'
+ path: '/'
+ fullPath: '/posts/'
+ preLoaderRoute: typeof postsPostsHomeRouteImport
parentRoute: typeof postsPostsRoute
}
- '/_first/_second/layout-a': {
- id: '/_first/_second/layout-a'
- path: '/layout-a'
- fullPath: '/layout-a'
- preLoaderRoute: typeof aRouteImport
- parentRoute: typeof layoutSecondLayoutRoute
+ '/classic/hello': {
+ id: '/classic/hello'
+ path: '/classic/hello'
+ fullPath: '/classic/hello'
+ preLoaderRoute: typeof ClassicHelloRouteRouteImport
+ parentRoute: typeof rootRouteImport
}
- '/_first/_second/layout-b': {
- id: '/_first/_second/layout-b'
- path: '/layout-b'
- fullPath: '/layout-b'
- preLoaderRoute: typeof bRouteImport
- parentRoute: typeof layoutSecondLayoutRoute
- }
- '/classic/hello/universe': {
- id: '/classic/hello/universe'
- path: '/universe'
- fullPath: '/classic/hello/universe'
- preLoaderRoute: typeof ClassicHelloUniverseRouteImport
+ '/classic/hello/': {
+ id: '/classic/hello/'
+ path: '/'
+ fullPath: '/classic/hello/'
+ preLoaderRoute: typeof ClassicHelloIndexRouteImport
parentRoute: typeof ClassicHelloRouteRoute
}
'/classic/hello/world': {
@@ -245,13 +231,27 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof ClassicHelloWorldRouteImport
parentRoute: typeof ClassicHelloRouteRoute
}
- '/classic/hello/': {
- id: '/classic/hello/'
- path: '/'
- fullPath: '/classic/hello/'
- preLoaderRoute: typeof ClassicHelloIndexRouteImport
+ '/classic/hello/universe': {
+ id: '/classic/hello/universe'
+ path: '/universe'
+ fullPath: '/classic/hello/universe'
+ preLoaderRoute: typeof ClassicHelloUniverseRouteImport
parentRoute: typeof ClassicHelloRouteRoute
}
+ '/_first/_second/layout-b': {
+ id: '/_first/_second/layout-b'
+ path: '/layout-b'
+ fullPath: '/layout-b'
+ preLoaderRoute: typeof bRouteImport
+ parentRoute: typeof layoutSecondLayoutRoute
+ }
+ '/_first/_second/layout-a': {
+ id: '/_first/_second/layout-a'
+ path: '/layout-a'
+ fullPath: '/layout-a'
+ preLoaderRoute: typeof aRouteImport
+ parentRoute: typeof layoutSecondLayoutRoute
+ }
}
}
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/src/routeTree.gen.ts b/e2e/react-start/basic-react-query/src/routeTree.gen.ts
index 02c8e9e10d..bed82c504b 100644
--- a/e2e/react-start/basic-react-query/src/routeTree.gen.ts
+++ b/e2e/react-start/basic-react-query/src/routeTree.gen.ts
@@ -8,8 +8,6 @@
// 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 UsersRouteImport } from './routes/users'
import { Route as RedirectRouteImport } from './routes/redirect'
@@ -21,14 +19,12 @@ import { Route as UsersIndexRouteImport } from './routes/users.index'
import { Route as PostsIndexRouteImport } from './routes/posts.index'
import { Route as UsersUserIdRouteImport } from './routes/users.$userId'
import { Route as PostsPostIdRouteImport } from './routes/posts.$postId'
+import { Route as ApiUsersRouteImport } from './routes/api.users'
import { Route as LayoutLayout2RouteImport } from './routes/_layout/_layout-2'
import { Route as PostsPostIdDeepRouteImport } from './routes/posts_.$postId.deep'
+import { Route as ApiUsersIdRouteImport } from './routes/api/users.$id'
import { Route as LayoutLayout2LayoutBRouteImport } from './routes/_layout/_layout-2/layout-b'
import { Route as LayoutLayout2LayoutARouteImport } from './routes/_layout/_layout-2/layout-a'
-import { ServerRoute as ApiUsersServerRouteImport } from './routes/api.users'
-import { ServerRoute as ApiUsersIdServerRouteImport } from './routes/api/users.$id'
-
-const rootServerRouteImport = createServerRootRoute()
const UsersRoute = UsersRouteImport.update({
id: '/users',
@@ -79,6 +75,11 @@ const PostsPostIdRoute = PostsPostIdRouteImport.update({
path: '/$postId',
getParentRoute: () => PostsRoute,
} as any)
+const ApiUsersRoute = ApiUsersRouteImport.update({
+ id: '/api/users',
+ path: '/api/users',
+ getParentRoute: () => rootRouteImport,
+} as any)
const LayoutLayout2Route = LayoutLayout2RouteImport.update({
id: '/_layout-2',
getParentRoute: () => LayoutRoute,
@@ -88,6 +89,11 @@ const PostsPostIdDeepRoute = PostsPostIdDeepRouteImport.update({
path: '/posts/$postId/deep',
getParentRoute: () => rootRouteImport,
} as any)
+const ApiUsersIdRoute = ApiUsersIdRouteImport.update({
+ id: '/$id',
+ path: '/$id',
+ getParentRoute: () => ApiUsersRoute,
+} as any)
const LayoutLayout2LayoutBRoute = LayoutLayout2LayoutBRouteImport.update({
id: '/layout-b',
path: '/layout-b',
@@ -98,16 +104,6 @@ const LayoutLayout2LayoutARoute = LayoutLayout2LayoutARouteImport.update({
path: '/layout-a',
getParentRoute: () => LayoutLayout2Route,
} as any)
-const ApiUsersServerRoute = ApiUsersServerRouteImport.update({
- id: '/api/users',
- path: '/api/users',
- getParentRoute: () => rootServerRouteImport,
-} as any)
-const ApiUsersIdServerRoute = ApiUsersIdServerRouteImport.update({
- id: '/$id',
- path: '/$id',
- getParentRoute: () => ApiUsersServerRoute,
-} as any)
export interface FileRoutesByFullPath {
'/': typeof IndexRoute
@@ -115,24 +111,28 @@ export interface FileRoutesByFullPath {
'/posts': typeof PostsRouteWithChildren
'/redirect': typeof RedirectRoute
'/users': typeof UsersRouteWithChildren
+ '/api/users': typeof ApiUsersRouteWithChildren
'/posts/$postId': typeof PostsPostIdRoute
'/users/$userId': typeof UsersUserIdRoute
'/posts/': typeof PostsIndexRoute
'/users/': typeof UsersIndexRoute
'/layout-a': typeof LayoutLayout2LayoutARoute
'/layout-b': typeof LayoutLayout2LayoutBRoute
+ '/api/users/$id': typeof ApiUsersIdRoute
'/posts/$postId/deep': typeof PostsPostIdDeepRoute
}
export interface FileRoutesByTo {
'/': typeof IndexRoute
'/deferred': typeof DeferredRoute
'/redirect': typeof RedirectRoute
+ '/api/users': typeof ApiUsersRouteWithChildren
'/posts/$postId': typeof PostsPostIdRoute
'/users/$userId': typeof UsersUserIdRoute
'/posts': typeof PostsIndexRoute
'/users': typeof UsersIndexRoute
'/layout-a': typeof LayoutLayout2LayoutARoute
'/layout-b': typeof LayoutLayout2LayoutBRoute
+ '/api/users/$id': typeof ApiUsersIdRoute
'/posts/$postId/deep': typeof PostsPostIdDeepRoute
}
export interface FileRoutesById {
@@ -144,12 +144,14 @@ export interface FileRoutesById {
'/redirect': typeof RedirectRoute
'/users': typeof UsersRouteWithChildren
'/_layout/_layout-2': typeof LayoutLayout2RouteWithChildren
+ '/api/users': typeof ApiUsersRouteWithChildren
'/posts/$postId': typeof PostsPostIdRoute
'/users/$userId': typeof UsersUserIdRoute
'/posts/': typeof PostsIndexRoute
'/users/': typeof UsersIndexRoute
'/_layout/_layout-2/layout-a': typeof LayoutLayout2LayoutARoute
'/_layout/_layout-2/layout-b': typeof LayoutLayout2LayoutBRoute
+ '/api/users/$id': typeof ApiUsersIdRoute
'/posts_/$postId/deep': typeof PostsPostIdDeepRoute
}
export interface FileRouteTypes {
@@ -160,24 +162,28 @@ export interface FileRouteTypes {
| '/posts'
| '/redirect'
| '/users'
+ | '/api/users'
| '/posts/$postId'
| '/users/$userId'
| '/posts/'
| '/users/'
| '/layout-a'
| '/layout-b'
+ | '/api/users/$id'
| '/posts/$postId/deep'
fileRoutesByTo: FileRoutesByTo
to:
| '/'
| '/deferred'
| '/redirect'
+ | '/api/users'
| '/posts/$postId'
| '/users/$userId'
| '/posts'
| '/users'
| '/layout-a'
| '/layout-b'
+ | '/api/users/$id'
| '/posts/$postId/deep'
id:
| '__root__'
@@ -188,12 +194,14 @@ export interface FileRouteTypes {
| '/redirect'
| '/users'
| '/_layout/_layout-2'
+ | '/api/users'
| '/posts/$postId'
| '/users/$userId'
| '/posts/'
| '/users/'
| '/_layout/_layout-2/layout-a'
| '/_layout/_layout-2/layout-b'
+ | '/api/users/$id'
| '/posts_/$postId/deep'
fileRoutesById: FileRoutesById
}
@@ -204,32 +212,9 @@ export interface RootRouteChildren {
PostsRoute: typeof PostsRouteWithChildren
RedirectRoute: typeof RedirectRoute
UsersRoute: typeof UsersRouteWithChildren
+ ApiUsersRoute: typeof ApiUsersRouteWithChildren
PostsPostIdDeepRoute: typeof PostsPostIdDeepRoute
}
-export interface FileServerRoutesByFullPath {
- '/api/users': typeof ApiUsersServerRouteWithChildren
- '/api/users/$id': typeof ApiUsersIdServerRoute
-}
-export interface FileServerRoutesByTo {
- '/api/users': typeof ApiUsersServerRouteWithChildren
- '/api/users/$id': typeof ApiUsersIdServerRoute
-}
-export interface FileServerRoutesById {
- __root__: typeof rootServerRouteImport
- '/api/users': typeof ApiUsersServerRouteWithChildren
- '/api/users/$id': typeof ApiUsersIdServerRoute
-}
-export interface FileServerRouteTypes {
- fileServerRoutesByFullPath: FileServerRoutesByFullPath
- fullPaths: '/api/users' | '/api/users/$id'
- fileServerRoutesByTo: FileServerRoutesByTo
- to: '/api/users' | '/api/users/$id'
- id: '__root__' | '/api/users' | '/api/users/$id'
- fileServerRoutesById: FileServerRoutesById
-}
-export interface RootServerRouteChildren {
- ApiUsersServerRoute: typeof ApiUsersServerRouteWithChildren
-}
declare module '@tanstack/react-router' {
interface FileRoutesByPath {
@@ -303,6 +288,13 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof PostsPostIdRouteImport
parentRoute: typeof PostsRoute
}
+ '/api/users': {
+ id: '/api/users'
+ path: '/api/users'
+ fullPath: '/api/users'
+ preLoaderRoute: typeof ApiUsersRouteImport
+ parentRoute: typeof rootRouteImport
+ }
'/_layout/_layout-2': {
id: '/_layout/_layout-2'
path: ''
@@ -317,6 +309,13 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof PostsPostIdDeepRouteImport
parentRoute: typeof rootRouteImport
}
+ '/api/users/$id': {
+ id: '/api/users/$id'
+ path: '/$id'
+ fullPath: '/api/users/$id'
+ preLoaderRoute: typeof ApiUsersIdRouteImport
+ parentRoute: typeof ApiUsersRoute
+ }
'/_layout/_layout-2/layout-b': {
id: '/_layout/_layout-2/layout-b'
path: '/layout-b'
@@ -333,24 +332,6 @@ declare module '@tanstack/react-router' {
}
}
}
-declare module '@tanstack/react-start/server' {
- interface ServerFileRoutesByPath {
- '/api/users': {
- id: '/api/users'
- path: '/api/users'
- fullPath: '/api/users'
- preLoaderRoute: typeof ApiUsersServerRouteImport
- parentRoute: typeof rootServerRouteImport
- }
- '/api/users/$id': {
- id: '/api/users/$id'
- path: '/$id'
- fullPath: '/api/users/$id'
- preLoaderRoute: typeof ApiUsersIdServerRouteImport
- parentRoute: typeof ApiUsersServerRoute
- }
- }
-}
interface LayoutLayout2RouteChildren {
LayoutLayout2LayoutARoute: typeof LayoutLayout2LayoutARoute
@@ -401,16 +382,16 @@ const UsersRouteChildren: UsersRouteChildren = {
const UsersRouteWithChildren = UsersRoute._addFileChildren(UsersRouteChildren)
-interface ApiUsersServerRouteChildren {
- ApiUsersIdServerRoute: typeof ApiUsersIdServerRoute
+interface ApiUsersRouteChildren {
+ ApiUsersIdRoute: typeof ApiUsersIdRoute
}
-const ApiUsersServerRouteChildren: ApiUsersServerRouteChildren = {
- ApiUsersIdServerRoute: ApiUsersIdServerRoute,
+const ApiUsersRouteChildren: ApiUsersRouteChildren = {
+ ApiUsersIdRoute: ApiUsersIdRoute,
}
-const ApiUsersServerRouteWithChildren = ApiUsersServerRoute._addFileChildren(
- ApiUsersServerRouteChildren,
+const ApiUsersRouteWithChildren = ApiUsersRoute._addFileChildren(
+ ApiUsersRouteChildren,
)
const rootRouteChildren: RootRouteChildren = {
@@ -420,14 +401,9 @@ const rootRouteChildren: RootRouteChildren = {
PostsRoute: PostsRouteWithChildren,
RedirectRoute: RedirectRoute,
UsersRoute: UsersRouteWithChildren,
+ ApiUsersRoute: ApiUsersRouteWithChildren,
PostsPostIdDeepRoute: PostsPostIdDeepRoute,
}
export const routeTree = rootRouteImport
._addFileChildren(rootRouteChildren)
._addFileTypes()
-const rootServerRouteChildren: RootServerRouteChildren = {
- ApiUsersServerRoute: ApiUsersServerRouteWithChildren,
-}
-export const serverRouteTree = rootServerRouteImport
- ._addFileChildren(rootServerRouteChildren)
- ._addFileTypes()
diff --git a/e2e/react-start/basic-react-query/src/routes/api.users.ts b/e2e/react-start/basic-react-query/src/routes/api.users.ts
index e3865404bb..454aca50a0 100644
--- a/e2e/react-start/basic-react-query/src/routes/api.users.ts
+++ b/e2e/react-start/basic-react-query/src/routes/api.users.ts
@@ -1,4 +1,4 @@
-import { createServerFileRoute } from '@tanstack/react-start/server'
+import { createFileRoute } from '@tanstack/react-router'
import { json } from '@tanstack/react-start'
import axios from 'redaxios'
import type { User } from '../utils/users'
@@ -9,13 +9,17 @@ if (import.meta.env.VITE_NODE_ENV === 'test') {
queryURL = `http://localhost:${import.meta.env.VITE_EXTERNAL_PORT}`
}
-export const ServerRoute = createServerFileRoute('/api/users').methods({
- GET: async ({ request }) => {
- console.info('Fetching users... @', request.url)
- const res = await axios.get>(`${queryURL}/users`)
-
- const list = res.data.slice(0, 10)
-
- return json(list.map((u) => ({ id: u.id, name: u.name, email: u.email })))
+export const Route = createFileRoute('/api/users')({
+ server: {
+ handlers: {
+ GET: async ({ request }) => {
+ console.info('Fetching users... @', request.url)
+ const res = await axios.get>(`${queryURL}/users`)
+ const list = res.data.slice(0, 10)
+ return json(
+ list.map((u) => ({ id: u.id, name: u.name, email: u.email })),
+ )
+ },
+ },
},
})
diff --git a/e2e/react-start/basic-react-query/src/routes/api/users.$id.ts b/e2e/react-start/basic-react-query/src/routes/api/users.$id.ts
index 88e8b71fe0..70ad77d76b 100644
--- a/e2e/react-start/basic-react-query/src/routes/api/users.$id.ts
+++ b/e2e/react-start/basic-react-query/src/routes/api/users.$id.ts
@@ -1,4 +1,4 @@
-import { createServerFileRoute } from '@tanstack/react-start/server'
+import { createFileRoute } from '@tanstack/react-router'
import { json } from '@tanstack/react-start'
import axios from 'redaxios'
import type { User } from '../../utils/users'
@@ -9,20 +9,23 @@ if (import.meta.env.VITE_NODE_ENV === 'test') {
queryURL = `http://localhost:${import.meta.env.VITE_EXTERNAL_PORT}`
}
-export const ServerRoute = createServerFileRoute('/api/users/$id').methods({
- GET: async ({ request, params }) => {
- console.info(`Fetching users by id=${params.id}... @`, request.url)
- try {
- const res = await axios.get(`${queryURL}/users/` + params.id)
-
- return json({
- id: res.data.id,
- name: res.data.name,
- email: res.data.email,
- })
- } catch (e) {
- console.error(e)
- return json({ error: 'User not found' }, { status: 404 })
- }
+export const Route = createFileRoute('/api/users/$id')({
+ server: {
+ handlers: {
+ GET: async ({ request, params }) => {
+ console.info(`Fetching users by id=${params.id}... @`, request.url)
+ try {
+ const res = await axios.get(`${queryURL}/users/` + params.id)
+ return json({
+ id: res.data.id,
+ name: res.data.name,
+ email: res.data.email,
+ })
+ } catch (e) {
+ console.error(e)
+ return json({ error: 'User not found' }, { status: 404 })
+ }
+ },
+ },
},
})
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/routeTree.gen.ts b/e2e/react-start/basic/src/routeTree.gen.ts
index b6fc9282f6..e341ed9499 100644
--- a/e2e/react-start/basic/src/routeTree.gen.ts
+++ b/e2e/react-start/basic/src/routeTree.gen.ts
@@ -10,11 +10,6 @@
import { createFileRoute } from '@tanstack/react-router'
import type { CreateFileRoute, FileRoutesByPath } from '@tanstack/react-router'
-import type {
- CreateServerFileRoute,
- ServerFileRoutesByPath,
-} from '@tanstack/react-start/server'
-import { createServerRootRoute } from '@tanstack/react-start/server'
import { Route as rootRouteImport } from './routes/__root'
import { Route as Char45824Char54620Char48124Char44397RouteImport } from './routes/대한민국'
@@ -40,11 +35,13 @@ import { Route as RedirectTargetRouteImport } from './routes/redirect/$target'
import { Route as PostsPostIdRouteImport } from './routes/posts.$postId'
import { Route as NotFoundViaLoaderRouteImport } from './routes/not-found/via-loader'
import { Route as NotFoundViaBeforeLoadRouteImport } from './routes/not-found/via-beforeLoad'
+import { Route as ApiUsersRouteImport } from './routes/api.users'
import { Route as LayoutLayout2RouteImport } from './routes/_layout/_layout-2'
import { Route as RedirectTargetIndexRouteImport } from './routes/redirect/$target/index'
import { Route as RedirectTargetViaLoaderRouteImport } from './routes/redirect/$target/via-loader'
import { Route as RedirectTargetViaBeforeLoadRouteImport } from './routes/redirect/$target/via-beforeLoad'
import { Route as PostsPostIdDeepRouteImport } from './routes/posts_.$postId.deep'
+import { Route as ApiUsersIdRouteImport } from './routes/api/users.$id'
import { Route as LayoutLayout2LayoutBRouteImport } from './routes/_layout/_layout-2/layout-b'
import { Route as LayoutLayout2LayoutARouteImport } from './routes/_layout/_layout-2/layout-a'
import { Route as RedirectTargetServerFnIndexRouteImport } from './routes/redirect/$target/serverFn/index'
@@ -53,11 +50,8 @@ import { Route as RedirectTargetServerFnViaLoaderRouteImport } from './routes/re
import { Route as RedirectTargetServerFnViaBeforeLoadRouteImport } from './routes/redirect/$target/serverFn/via-beforeLoad'
import { Route as FooBarQuxHereRouteImport } from './routes/foo/$bar/$qux/_here'
import { Route as FooBarQuxHereIndexRouteImport } from './routes/foo/$bar/$qux/_here/index'
-import { ServerRoute as ApiUsersServerRouteImport } from './routes/api.users'
-import { ServerRoute as ApiUsersIdServerRouteImport } from './routes/api/users.$id'
const FooBarQuxRouteImport = createFileRoute('/foo/$bar/$qux')()
-const rootServerRouteImport = createServerRootRoute()
const Char45824Char54620Char48124Char44397Route =
Char45824Char54620Char48124Char44397RouteImport.update({
@@ -175,6 +169,11 @@ const NotFoundViaBeforeLoadRoute = NotFoundViaBeforeLoadRouteImport.update({
path: '/via-beforeLoad',
getParentRoute: () => NotFoundRouteRoute,
} as any)
+const ApiUsersRoute = ApiUsersRouteImport.update({
+ id: '/api/users',
+ path: '/api/users',
+ getParentRoute: () => rootRouteImport,
+} as any)
const LayoutLayout2Route = LayoutLayout2RouteImport.update({
id: '/_layout-2',
getParentRoute: () => LayoutRoute,
@@ -205,6 +204,11 @@ const PostsPostIdDeepRoute = PostsPostIdDeepRouteImport.update({
path: '/posts/$postId/deep',
getParentRoute: () => rootRouteImport,
} as any)
+const ApiUsersIdRoute = ApiUsersIdRouteImport.update({
+ id: '/$id',
+ path: '/$id',
+ getParentRoute: () => ApiUsersRoute,
+} as any)
const LayoutLayout2LayoutBRoute = LayoutLayout2LayoutBRouteImport.update({
id: '/layout-b',
path: '/layout-b',
@@ -248,16 +252,6 @@ const FooBarQuxHereIndexRoute = FooBarQuxHereIndexRouteImport.update({
path: '/',
getParentRoute: () => FooBarQuxHereRoute,
} as any)
-const ApiUsersServerRoute = ApiUsersServerRouteImport.update({
- id: '/api/users',
- path: '/api/users',
- getParentRoute: () => rootServerRouteImport,
-} as any)
-const ApiUsersIdServerRoute = ApiUsersIdServerRouteImport.update({
- id: '/$id',
- path: '/$id',
- getParentRoute: () => ApiUsersServerRoute,
-} as any)
export interface FileRoutesByFullPath {
'/': typeof IndexRoute
@@ -270,6 +264,7 @@ export interface FileRoutesByFullPath {
'/stream': typeof StreamRoute
'/users': typeof UsersRouteWithChildren
'/대한민국': typeof Char45824Char54620Char48124Char44397Route
+ '/api/users': typeof ApiUsersRouteWithChildren
'/not-found/via-beforeLoad': typeof NotFoundViaBeforeLoadRoute
'/not-found/via-loader': typeof NotFoundViaLoaderRoute
'/posts/$postId': typeof PostsPostIdRoute
@@ -284,6 +279,7 @@ export interface FileRoutesByFullPath {
'/users/': typeof UsersIndexRoute
'/layout-a': typeof LayoutLayout2LayoutARoute
'/layout-b': typeof LayoutLayout2LayoutBRoute
+ '/api/users/$id': typeof ApiUsersIdRoute
'/posts/$postId/deep': typeof PostsPostIdDeepRoute
'/redirect/$target/via-beforeLoad': typeof RedirectTargetViaBeforeLoadRoute
'/redirect/$target/via-loader': typeof RedirectTargetViaLoaderRoute
@@ -302,6 +298,7 @@ export interface FileRoutesByTo {
'/scripts': typeof ScriptsRoute
'/stream': typeof StreamRoute
'/대한민국': typeof Char45824Char54620Char48124Char44397Route
+ '/api/users': typeof ApiUsersRouteWithChildren
'/not-found/via-beforeLoad': typeof NotFoundViaBeforeLoadRoute
'/not-found/via-loader': typeof NotFoundViaLoaderRoute
'/posts/$postId': typeof PostsPostIdRoute
@@ -315,6 +312,7 @@ export interface FileRoutesByTo {
'/users': typeof UsersIndexRoute
'/layout-a': typeof LayoutLayout2LayoutARoute
'/layout-b': typeof LayoutLayout2LayoutBRoute
+ '/api/users/$id': typeof ApiUsersIdRoute
'/posts/$postId/deep': typeof PostsPostIdDeepRoute
'/redirect/$target/via-beforeLoad': typeof RedirectTargetViaBeforeLoadRoute
'/redirect/$target/via-loader': typeof RedirectTargetViaLoaderRoute
@@ -339,6 +337,7 @@ export interface FileRoutesById {
'/users': typeof UsersRouteWithChildren
'/대한민국': typeof Char45824Char54620Char48124Char44397Route
'/_layout/_layout-2': typeof LayoutLayout2RouteWithChildren
+ '/api/users': typeof ApiUsersRouteWithChildren
'/not-found/via-beforeLoad': typeof NotFoundViaBeforeLoadRoute
'/not-found/via-loader': typeof NotFoundViaLoaderRoute
'/posts/$postId': typeof PostsPostIdRoute
@@ -353,6 +352,7 @@ export interface FileRoutesById {
'/users/': typeof UsersIndexRoute
'/_layout/_layout-2/layout-a': typeof LayoutLayout2LayoutARoute
'/_layout/_layout-2/layout-b': typeof LayoutLayout2LayoutBRoute
+ '/api/users/$id': typeof ApiUsersIdRoute
'/posts_/$postId/deep': typeof PostsPostIdDeepRoute
'/redirect/$target/via-beforeLoad': typeof RedirectTargetViaBeforeLoadRoute
'/redirect/$target/via-loader': typeof RedirectTargetViaLoaderRoute
@@ -378,6 +378,7 @@ export interface FileRouteTypes {
| '/stream'
| '/users'
| '/대한민국'
+ | '/api/users'
| '/not-found/via-beforeLoad'
| '/not-found/via-loader'
| '/posts/$postId'
@@ -392,6 +393,7 @@ export interface FileRouteTypes {
| '/users/'
| '/layout-a'
| '/layout-b'
+ | '/api/users/$id'
| '/posts/$postId/deep'
| '/redirect/$target/via-beforeLoad'
| '/redirect/$target/via-loader'
@@ -410,6 +412,7 @@ export interface FileRouteTypes {
| '/scripts'
| '/stream'
| '/대한민국'
+ | '/api/users'
| '/not-found/via-beforeLoad'
| '/not-found/via-loader'
| '/posts/$postId'
@@ -423,6 +426,7 @@ export interface FileRouteTypes {
| '/users'
| '/layout-a'
| '/layout-b'
+ | '/api/users/$id'
| '/posts/$postId/deep'
| '/redirect/$target/via-beforeLoad'
| '/redirect/$target/via-loader'
@@ -446,6 +450,7 @@ export interface FileRouteTypes {
| '/users'
| '/대한민국'
| '/_layout/_layout-2'
+ | '/api/users'
| '/not-found/via-beforeLoad'
| '/not-found/via-loader'
| '/posts/$postId'
@@ -460,6 +465,7 @@ export interface FileRouteTypes {
| '/users/'
| '/_layout/_layout-2/layout-a'
| '/_layout/_layout-2/layout-b'
+ | '/api/users/$id'
| '/posts_/$postId/deep'
| '/redirect/$target/via-beforeLoad'
| '/redirect/$target/via-loader'
@@ -485,99 +491,20 @@ export interface RootRouteChildren {
StreamRoute: typeof StreamRoute
UsersRoute: typeof UsersRouteWithChildren
Char45824Char54620Char48124Char44397Route: typeof Char45824Char54620Char48124Char44397Route
+ ApiUsersRoute: typeof ApiUsersRouteWithChildren
RedirectTargetRoute: typeof RedirectTargetRouteWithChildren
RedirectIndexRoute: typeof RedirectIndexRoute
PostsPostIdDeepRoute: typeof PostsPostIdDeepRoute
FooBarQuxRoute: typeof FooBarQuxRouteWithChildren
}
-export interface FileServerRoutesByFullPath {
- '/api/users': typeof ApiUsersServerRouteWithChildren
- '/api/users/$id': typeof ApiUsersIdServerRoute
-}
-export interface FileServerRoutesByTo {
- '/api/users': typeof ApiUsersServerRouteWithChildren
- '/api/users/$id': typeof ApiUsersIdServerRoute
-}
-export interface FileServerRoutesById {
- __root__: typeof rootServerRouteImport
- '/api/users': typeof ApiUsersServerRouteWithChildren
- '/api/users/$id': typeof ApiUsersIdServerRoute
-}
-export interface FileServerRouteTypes {
- fileServerRoutesByFullPath: FileServerRoutesByFullPath
- fullPaths: '/api/users' | '/api/users/$id'
- fileServerRoutesByTo: FileServerRoutesByTo
- to: '/api/users' | '/api/users/$id'
- id: '__root__' | '/api/users' | '/api/users/$id'
- fileServerRoutesById: FileServerRoutesById
-}
-export interface RootServerRouteChildren {
- ApiUsersServerRoute: typeof ApiUsersServerRouteWithChildren
-}
declare module '@tanstack/react-router' {
interface FileRoutesByPath {
- '/': {
- id: '/'
- path: '/'
- fullPath: '/'
- preLoaderRoute: typeof IndexRouteImport
- parentRoute: typeof rootRouteImport
- }
- '/not-found': {
- id: '/not-found'
- path: '/not-found'
- fullPath: '/not-found'
- preLoaderRoute: typeof NotFoundRouteRouteImport
- parentRoute: typeof rootRouteImport
- }
- '/search-params': {
- id: '/search-params'
- path: '/search-params'
- fullPath: '/search-params'
- preLoaderRoute: typeof SearchParamsRouteRouteImport
- parentRoute: typeof rootRouteImport
- }
- '/_layout': {
- id: '/_layout'
- path: ''
- fullPath: ''
- preLoaderRoute: typeof LayoutRouteImport
- parentRoute: typeof rootRouteImport
- }
- '/deferred': {
- id: '/deferred'
- path: '/deferred'
- fullPath: '/deferred'
- preLoaderRoute: typeof DeferredRouteImport
- parentRoute: typeof rootRouteImport
- }
- '/links': {
- id: '/links'
- path: '/links'
- fullPath: '/links'
- preLoaderRoute: typeof LinksRouteImport
- parentRoute: typeof rootRouteImport
- }
- '/posts': {
- id: '/posts'
- path: '/posts'
- fullPath: '/posts'
- preLoaderRoute: typeof PostsRouteImport
- parentRoute: typeof rootRouteImport
- }
- '/scripts': {
- id: '/scripts'
- path: '/scripts'
- fullPath: '/scripts'
- preLoaderRoute: typeof ScriptsRouteImport
- parentRoute: typeof rootRouteImport
- }
- '/stream': {
- id: '/stream'
- path: '/stream'
- fullPath: '/stream'
- preLoaderRoute: typeof StreamRouteImport
+ '/대한민국': {
+ id: '/대한민국'
+ path: '/대한민국'
+ fullPath: '/대한민국'
+ preLoaderRoute: typeof Char45824Char54620Char48124Char44397RouteImport
parentRoute: typeof rootRouteImport
}
'/users': {
@@ -587,11 +514,158 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof UsersRouteImport
parentRoute: typeof rootRouteImport
}
- '/대한민국': {
- id: '/대한민국'
- path: '/대한민국'
- fullPath: '/대한민국'
- preLoaderRoute: typeof Char45824Char54620Char48124Char44397RouteImport
+ '/stream': {
+ id: '/stream'
+ path: '/stream'
+ fullPath: '/stream'
+ preLoaderRoute: typeof StreamRouteImport
+ parentRoute: typeof rootRouteImport
+ }
+ '/scripts': {
+ id: '/scripts'
+ path: '/scripts'
+ fullPath: '/scripts'
+ preLoaderRoute: typeof ScriptsRouteImport
+ parentRoute: typeof rootRouteImport
+ }
+ '/posts': {
+ id: '/posts'
+ path: '/posts'
+ fullPath: '/posts'
+ preLoaderRoute: typeof PostsRouteImport
+ parentRoute: typeof rootRouteImport
+ }
+ '/links': {
+ id: '/links'
+ path: '/links'
+ fullPath: '/links'
+ preLoaderRoute: typeof LinksRouteImport
+ parentRoute: typeof rootRouteImport
+ }
+ '/deferred': {
+ id: '/deferred'
+ path: '/deferred'
+ fullPath: '/deferred'
+ preLoaderRoute: typeof DeferredRouteImport
+ parentRoute: typeof rootRouteImport
+ }
+ '/_layout': {
+ id: '/_layout'
+ path: ''
+ fullPath: ''
+ preLoaderRoute: typeof LayoutRouteImport
+ parentRoute: typeof rootRouteImport
+ }
+ '/search-params': {
+ id: '/search-params'
+ path: '/search-params'
+ fullPath: '/search-params'
+ preLoaderRoute: typeof SearchParamsRouteRouteImport
+ parentRoute: typeof rootRouteImport
+ }
+ '/not-found': {
+ id: '/not-found'
+ path: '/not-found'
+ fullPath: '/not-found'
+ preLoaderRoute: typeof NotFoundRouteRouteImport
+ parentRoute: typeof rootRouteImport
+ }
+ '/': {
+ id: '/'
+ path: '/'
+ fullPath: '/'
+ preLoaderRoute: typeof IndexRouteImport
+ parentRoute: typeof rootRouteImport
+ }
+ '/users/': {
+ id: '/users/'
+ path: '/'
+ fullPath: '/users/'
+ preLoaderRoute: typeof UsersIndexRouteImport
+ parentRoute: typeof UsersRoute
+ }
+ '/search-params/': {
+ id: '/search-params/'
+ path: '/'
+ fullPath: '/search-params/'
+ preLoaderRoute: typeof SearchParamsIndexRouteImport
+ parentRoute: typeof SearchParamsRouteRoute
+ }
+ '/redirect/': {
+ id: '/redirect/'
+ path: '/redirect'
+ fullPath: '/redirect'
+ preLoaderRoute: typeof RedirectIndexRouteImport
+ parentRoute: typeof rootRouteImport
+ }
+ '/posts/': {
+ id: '/posts/'
+ path: '/'
+ fullPath: '/posts/'
+ preLoaderRoute: typeof PostsIndexRouteImport
+ parentRoute: typeof PostsRoute
+ }
+ '/not-found/': {
+ id: '/not-found/'
+ path: '/'
+ fullPath: '/not-found/'
+ preLoaderRoute: typeof NotFoundIndexRouteImport
+ parentRoute: typeof NotFoundRouteRoute
+ }
+ '/users/$userId': {
+ id: '/users/$userId'
+ path: '/$userId'
+ fullPath: '/users/$userId'
+ preLoaderRoute: typeof UsersUserIdRouteImport
+ parentRoute: typeof UsersRoute
+ }
+ '/search-params/loader-throws-redirect': {
+ id: '/search-params/loader-throws-redirect'
+ path: '/loader-throws-redirect'
+ fullPath: '/search-params/loader-throws-redirect'
+ preLoaderRoute: typeof SearchParamsLoaderThrowsRedirectRouteImport
+ parentRoute: typeof SearchParamsRouteRoute
+ }
+ '/search-params/default': {
+ id: '/search-params/default'
+ path: '/default'
+ fullPath: '/search-params/default'
+ preLoaderRoute: typeof SearchParamsDefaultRouteImport
+ parentRoute: typeof SearchParamsRouteRoute
+ }
+ '/redirect/$target': {
+ id: '/redirect/$target'
+ path: '/redirect/$target'
+ fullPath: '/redirect/$target'
+ preLoaderRoute: typeof RedirectTargetRouteImport
+ parentRoute: typeof rootRouteImport
+ }
+ '/posts/$postId': {
+ id: '/posts/$postId'
+ path: '/$postId'
+ fullPath: '/posts/$postId'
+ preLoaderRoute: typeof PostsPostIdRouteImport
+ parentRoute: typeof PostsRoute
+ }
+ '/not-found/via-loader': {
+ id: '/not-found/via-loader'
+ path: '/via-loader'
+ fullPath: '/not-found/via-loader'
+ preLoaderRoute: typeof NotFoundViaLoaderRouteImport
+ parentRoute: typeof NotFoundRouteRoute
+ }
+ '/not-found/via-beforeLoad': {
+ id: '/not-found/via-beforeLoad'
+ path: '/via-beforeLoad'
+ fullPath: '/not-found/via-beforeLoad'
+ preLoaderRoute: typeof NotFoundViaBeforeLoadRouteImport
+ parentRoute: typeof NotFoundRouteRoute
+ }
+ '/api/users': {
+ id: '/api/users'
+ path: '/api/users'
+ fullPath: '/api/users'
+ preLoaderRoute: typeof ApiUsersRouteImport
parentRoute: typeof rootRouteImport
}
'/_layout/_layout-2': {
@@ -601,130 +675,18 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof LayoutLayout2RouteImport
parentRoute: typeof LayoutRoute
}
- '/api/users': {
- id: '/api/users'
- path: ''
- fullPath: '/api/users'
- preLoaderRoute: unknown
+ '/foo/$bar/$qux': {
+ id: '/foo/$bar/$qux'
+ path: '/foo/$bar/$qux'
+ fullPath: '/foo/$bar/$qux'
+ preLoaderRoute: typeof FooBarQuxRouteImport
parentRoute: typeof rootRouteImport
}
- '/not-found/via-beforeLoad': {
- id: '/not-found/via-beforeLoad'
- path: '/via-beforeLoad'
- fullPath: '/not-found/via-beforeLoad'
- preLoaderRoute: typeof NotFoundViaBeforeLoadRouteImport
- parentRoute: typeof NotFoundRouteRoute
- }
- '/not-found/via-loader': {
- id: '/not-found/via-loader'
- path: '/via-loader'
- fullPath: '/not-found/via-loader'
- preLoaderRoute: typeof NotFoundViaLoaderRouteImport
- parentRoute: typeof NotFoundRouteRoute
- }
- '/posts/$postId': {
- id: '/posts/$postId'
- path: '/$postId'
- fullPath: '/posts/$postId'
- preLoaderRoute: typeof PostsPostIdRouteImport
- parentRoute: typeof PostsRoute
- }
- '/redirect/$target': {
- id: '/redirect/$target'
- path: '/redirect/$target'
- fullPath: '/redirect/$target'
- preLoaderRoute: typeof RedirectTargetRouteImport
- parentRoute: typeof rootRouteImport
- }
- '/search-params/default': {
- id: '/search-params/default'
- path: '/default'
- fullPath: '/search-params/default'
- preLoaderRoute: typeof SearchParamsDefaultRouteImport
- parentRoute: typeof SearchParamsRouteRoute
- }
- '/search-params/loader-throws-redirect': {
- id: '/search-params/loader-throws-redirect'
- path: '/loader-throws-redirect'
- fullPath: '/search-params/loader-throws-redirect'
- preLoaderRoute: typeof SearchParamsLoaderThrowsRedirectRouteImport
- parentRoute: typeof SearchParamsRouteRoute
- }
- '/users/$userId': {
- id: '/users/$userId'
- path: '/$userId'
- fullPath: '/users/$userId'
- preLoaderRoute: typeof UsersUserIdRouteImport
- parentRoute: typeof UsersRoute
- }
- '/not-found/': {
- id: '/not-found/'
+ '/redirect/$target/': {
+ id: '/redirect/$target/'
path: '/'
- fullPath: '/not-found/'
- preLoaderRoute: typeof NotFoundIndexRouteImport
- parentRoute: typeof NotFoundRouteRoute
- }
- '/posts/': {
- id: '/posts/'
- path: '/'
- fullPath: '/posts/'
- preLoaderRoute: typeof PostsIndexRouteImport
- parentRoute: typeof PostsRoute
- }
- '/redirect/': {
- id: '/redirect/'
- path: '/redirect'
- fullPath: '/redirect'
- preLoaderRoute: typeof RedirectIndexRouteImport
- parentRoute: typeof rootRouteImport
- }
- '/search-params/': {
- id: '/search-params/'
- path: '/'
- fullPath: '/search-params/'
- preLoaderRoute: typeof SearchParamsIndexRouteImport
- parentRoute: typeof SearchParamsRouteRoute
- }
- '/users/': {
- id: '/users/'
- path: '/'
- fullPath: '/users/'
- preLoaderRoute: typeof UsersIndexRouteImport
- parentRoute: typeof UsersRoute
- }
- '/_layout/_layout-2/layout-a': {
- id: '/_layout/_layout-2/layout-a'
- path: '/layout-a'
- fullPath: '/layout-a'
- preLoaderRoute: typeof LayoutLayout2LayoutARouteImport
- parentRoute: typeof LayoutLayout2Route
- }
- '/_layout/_layout-2/layout-b': {
- id: '/_layout/_layout-2/layout-b'
- path: '/layout-b'
- fullPath: '/layout-b'
- preLoaderRoute: typeof LayoutLayout2LayoutBRouteImport
- parentRoute: typeof LayoutLayout2Route
- }
- '/api/users/$id': {
- id: '/api/users/$id'
- path: ''
- fullPath: '/api/users/$id'
- preLoaderRoute: unknown
- parentRoute: typeof rootRouteImport
- }
- '/posts_/$postId/deep': {
- id: '/posts_/$postId/deep'
- path: '/posts/$postId/deep'
- fullPath: '/posts/$postId/deep'
- preLoaderRoute: typeof PostsPostIdDeepRouteImport
- parentRoute: typeof rootRouteImport
- }
- '/redirect/$target/via-beforeLoad': {
- id: '/redirect/$target/via-beforeLoad'
- path: '/via-beforeLoad'
- fullPath: '/redirect/$target/via-beforeLoad'
- preLoaderRoute: typeof RedirectTargetViaBeforeLoadRouteImport
+ fullPath: '/redirect/$target/'
+ preLoaderRoute: typeof RedirectTargetIndexRouteImport
parentRoute: typeof RedirectTargetRoute
}
'/redirect/$target/via-loader': {
@@ -734,32 +696,46 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof RedirectTargetViaLoaderRouteImport
parentRoute: typeof RedirectTargetRoute
}
- '/redirect/$target/': {
- id: '/redirect/$target/'
- path: '/'
- fullPath: '/redirect/$target/'
- preLoaderRoute: typeof RedirectTargetIndexRouteImport
+ '/redirect/$target/via-beforeLoad': {
+ id: '/redirect/$target/via-beforeLoad'
+ path: '/via-beforeLoad'
+ fullPath: '/redirect/$target/via-beforeLoad'
+ preLoaderRoute: typeof RedirectTargetViaBeforeLoadRouteImport
parentRoute: typeof RedirectTargetRoute
}
- '/foo/$bar/$qux/_here': {
- id: '/foo/$bar/$qux/_here'
- path: '/foo/$bar/$qux'
- fullPath: '/foo/$bar/$qux'
- preLoaderRoute: typeof FooBarQuxHereRouteImport
- parentRoute: typeof FooBarQuxRoute
+ '/posts_/$postId/deep': {
+ id: '/posts_/$postId/deep'
+ path: '/posts/$postId/deep'
+ fullPath: '/posts/$postId/deep'
+ preLoaderRoute: typeof PostsPostIdDeepRouteImport
+ parentRoute: typeof rootRouteImport
}
- '/redirect/$target/serverFn/via-beforeLoad': {
- id: '/redirect/$target/serverFn/via-beforeLoad'
- path: '/serverFn/via-beforeLoad'
- fullPath: '/redirect/$target/serverFn/via-beforeLoad'
- preLoaderRoute: typeof RedirectTargetServerFnViaBeforeLoadRouteImport
- parentRoute: typeof RedirectTargetRoute
+ '/api/users/$id': {
+ id: '/api/users/$id'
+ path: '/$id'
+ fullPath: '/api/users/$id'
+ preLoaderRoute: typeof ApiUsersIdRouteImport
+ parentRoute: typeof ApiUsersRoute
}
- '/redirect/$target/serverFn/via-loader': {
- id: '/redirect/$target/serverFn/via-loader'
- path: '/serverFn/via-loader'
- fullPath: '/redirect/$target/serverFn/via-loader'
- preLoaderRoute: typeof RedirectTargetServerFnViaLoaderRouteImport
+ '/_layout/_layout-2/layout-b': {
+ id: '/_layout/_layout-2/layout-b'
+ path: '/layout-b'
+ fullPath: '/layout-b'
+ preLoaderRoute: typeof LayoutLayout2LayoutBRouteImport
+ parentRoute: typeof LayoutLayout2Route
+ }
+ '/_layout/_layout-2/layout-a': {
+ id: '/_layout/_layout-2/layout-a'
+ path: '/layout-a'
+ fullPath: '/layout-a'
+ preLoaderRoute: typeof LayoutLayout2LayoutARouteImport
+ parentRoute: typeof LayoutLayout2Route
+ }
+ '/redirect/$target/serverFn/': {
+ id: '/redirect/$target/serverFn/'
+ path: '/serverFn'
+ fullPath: '/redirect/$target/serverFn'
+ preLoaderRoute: typeof RedirectTargetServerFnIndexRouteImport
parentRoute: typeof RedirectTargetRoute
}
'/redirect/$target/serverFn/via-useServerFn': {
@@ -769,13 +745,27 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof RedirectTargetServerFnViaUseServerFnRouteImport
parentRoute: typeof RedirectTargetRoute
}
- '/redirect/$target/serverFn/': {
- id: '/redirect/$target/serverFn/'
- path: '/serverFn'
- fullPath: '/redirect/$target/serverFn'
- preLoaderRoute: typeof RedirectTargetServerFnIndexRouteImport
+ '/redirect/$target/serverFn/via-loader': {
+ id: '/redirect/$target/serverFn/via-loader'
+ path: '/serverFn/via-loader'
+ fullPath: '/redirect/$target/serverFn/via-loader'
+ preLoaderRoute: typeof RedirectTargetServerFnViaLoaderRouteImport
parentRoute: typeof RedirectTargetRoute
}
+ '/redirect/$target/serverFn/via-beforeLoad': {
+ id: '/redirect/$target/serverFn/via-beforeLoad'
+ path: '/serverFn/via-beforeLoad'
+ fullPath: '/redirect/$target/serverFn/via-beforeLoad'
+ preLoaderRoute: typeof RedirectTargetServerFnViaBeforeLoadRouteImport
+ parentRoute: typeof RedirectTargetRoute
+ }
+ '/foo/$bar/$qux/_here': {
+ id: '/foo/$bar/$qux/_here'
+ path: '/foo/$bar/$qux'
+ fullPath: '/foo/$bar/$qux'
+ preLoaderRoute: typeof FooBarQuxHereRouteImport
+ parentRoute: typeof FooBarQuxRoute
+ }
'/foo/$bar/$qux/_here/': {
id: '/foo/$bar/$qux/_here/'
path: '/'
@@ -783,283 +773,6 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof FooBarQuxHereIndexRouteImport
parentRoute: typeof FooBarQuxHereRoute
}
- '/foo/$bar/$qux': {
- id: '/foo/$bar/$qux'
- path: '/foo/$bar/$qux'
- fullPath: '/foo/$bar/$qux'
- preLoaderRoute: typeof FooBarQuxRouteImport
- parentRoute: typeof rootRouteImport
- }
- }
-}
-declare module '@tanstack/react-start/server' {
- interface ServerFileRoutesByPath {
- '/': {
- id: '/'
- path: '/'
- fullPath: '/'
- preLoaderRoute: unknown
- parentRoute: typeof rootServerRouteImport
- }
- '/not-found': {
- id: '/not-found'
- path: '/not-found'
- fullPath: '/not-found'
- preLoaderRoute: unknown
- parentRoute: typeof rootServerRouteImport
- }
- '/search-params': {
- id: '/search-params'
- path: '/search-params'
- fullPath: '/search-params'
- preLoaderRoute: unknown
- parentRoute: typeof rootServerRouteImport
- }
- '/_layout': {
- id: '/_layout'
- path: ''
- fullPath: ''
- preLoaderRoute: unknown
- parentRoute: typeof rootServerRouteImport
- }
- '/deferred': {
- id: '/deferred'
- path: '/deferred'
- fullPath: '/deferred'
- preLoaderRoute: unknown
- parentRoute: typeof rootServerRouteImport
- }
- '/links': {
- id: '/links'
- path: '/links'
- fullPath: '/links'
- preLoaderRoute: unknown
- parentRoute: typeof rootServerRouteImport
- }
- '/posts': {
- id: '/posts'
- path: '/posts'
- fullPath: '/posts'
- preLoaderRoute: unknown
- parentRoute: typeof rootServerRouteImport
- }
- '/scripts': {
- id: '/scripts'
- path: '/scripts'
- fullPath: '/scripts'
- preLoaderRoute: unknown
- parentRoute: typeof rootServerRouteImport
- }
- '/stream': {
- id: '/stream'
- path: '/stream'
- fullPath: '/stream'
- preLoaderRoute: unknown
- parentRoute: typeof rootServerRouteImport
- }
- '/users': {
- id: '/users'
- path: '/users'
- fullPath: '/users'
- preLoaderRoute: unknown
- parentRoute: typeof rootServerRouteImport
- }
- '/대한민국': {
- id: '/대한민국'
- path: '/대한민국'
- fullPath: '/대한민국'
- preLoaderRoute: unknown
- parentRoute: typeof rootServerRouteImport
- }
- '/_layout/_layout-2': {
- id: '/_layout/_layout-2'
- path: ''
- fullPath: ''
- preLoaderRoute: unknown
- parentRoute: typeof rootServerRouteImport
- }
- '/api/users': {
- id: '/api/users'
- path: '/api/users'
- fullPath: '/api/users'
- preLoaderRoute: typeof ApiUsersServerRouteImport
- parentRoute: typeof rootServerRouteImport
- }
- '/not-found/via-beforeLoad': {
- id: '/not-found/via-beforeLoad'
- path: '/via-beforeLoad'
- fullPath: '/not-found/via-beforeLoad'
- preLoaderRoute: unknown
- parentRoute: typeof rootServerRouteImport
- }
- '/not-found/via-loader': {
- id: '/not-found/via-loader'
- path: '/via-loader'
- fullPath: '/not-found/via-loader'
- preLoaderRoute: unknown
- parentRoute: typeof rootServerRouteImport
- }
- '/posts/$postId': {
- id: '/posts/$postId'
- path: '/$postId'
- fullPath: '/posts/$postId'
- preLoaderRoute: unknown
- parentRoute: typeof rootServerRouteImport
- }
- '/redirect/$target': {
- id: '/redirect/$target'
- path: '/redirect/$target'
- fullPath: '/redirect/$target'
- preLoaderRoute: unknown
- parentRoute: typeof rootServerRouteImport
- }
- '/search-params/default': {
- id: '/search-params/default'
- path: '/default'
- fullPath: '/search-params/default'
- preLoaderRoute: unknown
- parentRoute: typeof rootServerRouteImport
- }
- '/search-params/loader-throws-redirect': {
- id: '/search-params/loader-throws-redirect'
- path: '/loader-throws-redirect'
- fullPath: '/search-params/loader-throws-redirect'
- preLoaderRoute: unknown
- parentRoute: typeof rootServerRouteImport
- }
- '/users/$userId': {
- id: '/users/$userId'
- path: '/$userId'
- fullPath: '/users/$userId'
- preLoaderRoute: unknown
- parentRoute: typeof rootServerRouteImport
- }
- '/not-found/': {
- id: '/not-found/'
- path: '/'
- fullPath: '/not-found/'
- preLoaderRoute: unknown
- parentRoute: typeof rootServerRouteImport
- }
- '/posts/': {
- id: '/posts/'
- path: '/'
- fullPath: '/posts/'
- preLoaderRoute: unknown
- parentRoute: typeof rootServerRouteImport
- }
- '/redirect/': {
- id: '/redirect/'
- path: '/redirect'
- fullPath: '/redirect'
- preLoaderRoute: unknown
- parentRoute: typeof rootServerRouteImport
- }
- '/search-params/': {
- id: '/search-params/'
- path: '/'
- fullPath: '/search-params/'
- preLoaderRoute: unknown
- parentRoute: typeof rootServerRouteImport
- }
- '/users/': {
- id: '/users/'
- path: '/'
- fullPath: '/users/'
- preLoaderRoute: unknown
- parentRoute: typeof rootServerRouteImport
- }
- '/_layout/_layout-2/layout-a': {
- id: '/_layout/_layout-2/layout-a'
- path: '/layout-a'
- fullPath: '/layout-a'
- preLoaderRoute: unknown
- parentRoute: typeof rootServerRouteImport
- }
- '/_layout/_layout-2/layout-b': {
- id: '/_layout/_layout-2/layout-b'
- path: '/layout-b'
- fullPath: '/layout-b'
- preLoaderRoute: unknown
- parentRoute: typeof rootServerRouteImport
- }
- '/api/users/$id': {
- id: '/api/users/$id'
- path: '/$id'
- fullPath: '/api/users/$id'
- preLoaderRoute: typeof ApiUsersIdServerRouteImport
- parentRoute: typeof ApiUsersServerRoute
- }
- '/posts_/$postId/deep': {
- id: '/posts_/$postId/deep'
- path: '/posts/$postId/deep'
- fullPath: '/posts/$postId/deep'
- preLoaderRoute: unknown
- parentRoute: typeof rootServerRouteImport
- }
- '/redirect/$target/via-beforeLoad': {
- id: '/redirect/$target/via-beforeLoad'
- path: '/via-beforeLoad'
- fullPath: '/redirect/$target/via-beforeLoad'
- preLoaderRoute: unknown
- parentRoute: typeof rootServerRouteImport
- }
- '/redirect/$target/via-loader': {
- id: '/redirect/$target/via-loader'
- path: '/via-loader'
- fullPath: '/redirect/$target/via-loader'
- preLoaderRoute: unknown
- parentRoute: typeof rootServerRouteImport
- }
- '/redirect/$target/': {
- id: '/redirect/$target/'
- path: '/'
- fullPath: '/redirect/$target/'
- preLoaderRoute: unknown
- parentRoute: typeof rootServerRouteImport
- }
- '/foo/$bar/$qux/_here': {
- id: '/foo/$bar/$qux/_here'
- path: '/foo/$bar/$qux'
- fullPath: '/foo/$bar/$qux'
- preLoaderRoute: unknown
- parentRoute: typeof rootServerRouteImport
- }
- '/redirect/$target/serverFn/via-beforeLoad': {
- id: '/redirect/$target/serverFn/via-beforeLoad'
- path: '/serverFn/via-beforeLoad'
- fullPath: '/redirect/$target/serverFn/via-beforeLoad'
- preLoaderRoute: unknown
- parentRoute: typeof rootServerRouteImport
- }
- '/redirect/$target/serverFn/via-loader': {
- id: '/redirect/$target/serverFn/via-loader'
- path: '/serverFn/via-loader'
- fullPath: '/redirect/$target/serverFn/via-loader'
- preLoaderRoute: unknown
- parentRoute: typeof rootServerRouteImport
- }
- '/redirect/$target/serverFn/via-useServerFn': {
- id: '/redirect/$target/serverFn/via-useServerFn'
- path: '/serverFn/via-useServerFn'
- fullPath: '/redirect/$target/serverFn/via-useServerFn'
- preLoaderRoute: unknown
- parentRoute: typeof rootServerRouteImport
- }
- '/redirect/$target/serverFn/': {
- id: '/redirect/$target/serverFn/'
- path: '/serverFn'
- fullPath: '/redirect/$target/serverFn'
- preLoaderRoute: unknown
- parentRoute: typeof rootServerRouteImport
- }
- '/foo/$bar/$qux/_here/': {
- id: '/foo/$bar/$qux/_here/'
- path: '/'
- fullPath: '/foo/$bar/$qux/'
- preLoaderRoute: unknown
- parentRoute: typeof rootServerRouteImport
- }
}
}
@@ -1071,14 +784,6 @@ declare module './routes/index' {
FileRoutesByPath['/']['path'],
FileRoutesByPath['/']['fullPath']
>
-
- const createServerFileRoute: CreateServerFileRoute<
- ServerFileRoutesByPath['/']['parentRoute'],
- ServerFileRoutesByPath['/']['id'],
- ServerFileRoutesByPath['/']['path'],
- ServerFileRoutesByPath['/']['fullPath'],
- unknown
- >
}
declare module './routes/not-found/route' {
const createFileRoute: CreateFileRoute<
@@ -1088,14 +793,6 @@ declare module './routes/not-found/route' {
FileRoutesByPath['/not-found']['path'],
FileRoutesByPath['/not-found']['fullPath']
>
-
- const createServerFileRoute: CreateServerFileRoute<
- ServerFileRoutesByPath['/not-found']['parentRoute'],
- ServerFileRoutesByPath['/not-found']['id'],
- ServerFileRoutesByPath['/not-found']['path'],
- ServerFileRoutesByPath['/not-found']['fullPath'],
- unknown
- >
}
declare module './routes/search-params/route' {
const createFileRoute: CreateFileRoute<
@@ -1105,14 +802,6 @@ declare module './routes/search-params/route' {
FileRoutesByPath['/search-params']['path'],
FileRoutesByPath['/search-params']['fullPath']
>
-
- const createServerFileRoute: CreateServerFileRoute<
- ServerFileRoutesByPath['/search-params']['parentRoute'],
- ServerFileRoutesByPath['/search-params']['id'],
- ServerFileRoutesByPath['/search-params']['path'],
- ServerFileRoutesByPath['/search-params']['fullPath'],
- unknown
- >
}
declare module './routes/_layout' {
const createFileRoute: CreateFileRoute<
@@ -1122,14 +811,6 @@ declare module './routes/_layout' {
FileRoutesByPath['/_layout']['path'],
FileRoutesByPath['/_layout']['fullPath']
>
-
- const createServerFileRoute: CreateServerFileRoute<
- ServerFileRoutesByPath['/_layout']['parentRoute'],
- ServerFileRoutesByPath['/_layout']['id'],
- ServerFileRoutesByPath['/_layout']['path'],
- ServerFileRoutesByPath['/_layout']['fullPath'],
- unknown
- >
}
declare module './routes/deferred' {
const createFileRoute: CreateFileRoute<
@@ -1139,14 +820,6 @@ declare module './routes/deferred' {
FileRoutesByPath['/deferred']['path'],
FileRoutesByPath['/deferred']['fullPath']
>
-
- const createServerFileRoute: CreateServerFileRoute<
- ServerFileRoutesByPath['/deferred']['parentRoute'],
- ServerFileRoutesByPath['/deferred']['id'],
- ServerFileRoutesByPath['/deferred']['path'],
- ServerFileRoutesByPath['/deferred']['fullPath'],
- unknown
- >
}
declare module './routes/links' {
const createFileRoute: CreateFileRoute<
@@ -1156,14 +829,6 @@ declare module './routes/links' {
FileRoutesByPath['/links']['path'],
FileRoutesByPath['/links']['fullPath']
>
-
- const createServerFileRoute: CreateServerFileRoute<
- ServerFileRoutesByPath['/links']['parentRoute'],
- ServerFileRoutesByPath['/links']['id'],
- ServerFileRoutesByPath['/links']['path'],
- ServerFileRoutesByPath['/links']['fullPath'],
- unknown
- >
}
declare module './routes/posts' {
const createFileRoute: CreateFileRoute<
@@ -1173,14 +838,6 @@ declare module './routes/posts' {
FileRoutesByPath['/posts']['path'],
FileRoutesByPath['/posts']['fullPath']
>
-
- const createServerFileRoute: CreateServerFileRoute<
- ServerFileRoutesByPath['/posts']['parentRoute'],
- ServerFileRoutesByPath['/posts']['id'],
- ServerFileRoutesByPath['/posts']['path'],
- ServerFileRoutesByPath['/posts']['fullPath'],
- unknown
- >
}
declare module './routes/scripts' {
const createFileRoute: CreateFileRoute<
@@ -1190,14 +847,6 @@ declare module './routes/scripts' {
FileRoutesByPath['/scripts']['path'],
FileRoutesByPath['/scripts']['fullPath']
>
-
- const createServerFileRoute: CreateServerFileRoute<
- ServerFileRoutesByPath['/scripts']['parentRoute'],
- ServerFileRoutesByPath['/scripts']['id'],
- ServerFileRoutesByPath['/scripts']['path'],
- ServerFileRoutesByPath['/scripts']['fullPath'],
- unknown
- >
}
declare module './routes/stream' {
const createFileRoute: CreateFileRoute<
@@ -1207,14 +856,6 @@ declare module './routes/stream' {
FileRoutesByPath['/stream']['path'],
FileRoutesByPath['/stream']['fullPath']
>
-
- const createServerFileRoute: CreateServerFileRoute<
- ServerFileRoutesByPath['/stream']['parentRoute'],
- ServerFileRoutesByPath['/stream']['id'],
- ServerFileRoutesByPath['/stream']['path'],
- ServerFileRoutesByPath['/stream']['fullPath'],
- unknown
- >
}
declare module './routes/users' {
const createFileRoute: CreateFileRoute<
@@ -1224,14 +865,6 @@ declare module './routes/users' {
FileRoutesByPath['/users']['path'],
FileRoutesByPath['/users']['fullPath']
>
-
- const createServerFileRoute: CreateServerFileRoute<
- ServerFileRoutesByPath['/users']['parentRoute'],
- ServerFileRoutesByPath['/users']['id'],
- ServerFileRoutesByPath['/users']['path'],
- ServerFileRoutesByPath['/users']['fullPath'],
- unknown
- >
}
declare module './routes/대한민국' {
const createFileRoute: CreateFileRoute<
@@ -1241,14 +874,6 @@ declare module './routes/대한민국' {
FileRoutesByPath['/대한민국']['path'],
FileRoutesByPath['/대한민국']['fullPath']
>
-
- const createServerFileRoute: CreateServerFileRoute<
- ServerFileRoutesByPath['/대한민국']['parentRoute'],
- ServerFileRoutesByPath['/대한민국']['id'],
- ServerFileRoutesByPath['/대한민국']['path'],
- ServerFileRoutesByPath['/대한민국']['fullPath'],
- unknown
- >
}
declare module './routes/_layout/_layout-2' {
const createFileRoute: CreateFileRoute<
@@ -1258,14 +883,6 @@ declare module './routes/_layout/_layout-2' {
FileRoutesByPath['/_layout/_layout-2']['path'],
FileRoutesByPath['/_layout/_layout-2']['fullPath']
>
-
- const createServerFileRoute: CreateServerFileRoute<
- ServerFileRoutesByPath['/_layout/_layout-2']['parentRoute'],
- ServerFileRoutesByPath['/_layout/_layout-2']['id'],
- ServerFileRoutesByPath['/_layout/_layout-2']['path'],
- ServerFileRoutesByPath['/_layout/_layout-2']['fullPath'],
- unknown
- >
}
declare module './routes/api.users' {
const createFileRoute: CreateFileRoute<
@@ -1275,14 +892,6 @@ declare module './routes/api.users' {
FileRoutesByPath['/api/users']['path'],
FileRoutesByPath['/api/users']['fullPath']
>
-
- const createServerFileRoute: CreateServerFileRoute<
- ServerFileRoutesByPath['/api/users']['parentRoute'],
- ServerFileRoutesByPath['/api/users']['id'],
- ServerFileRoutesByPath['/api/users']['path'],
- ServerFileRoutesByPath['/api/users']['fullPath'],
- unknown
- >
}
declare module './routes/not-found/via-beforeLoad' {
const createFileRoute: CreateFileRoute<
@@ -1292,14 +901,6 @@ declare module './routes/not-found/via-beforeLoad' {
FileRoutesByPath['/not-found/via-beforeLoad']['path'],
FileRoutesByPath['/not-found/via-beforeLoad']['fullPath']
>
-
- const createServerFileRoute: CreateServerFileRoute<
- ServerFileRoutesByPath['/not-found/via-beforeLoad']['parentRoute'],
- ServerFileRoutesByPath['/not-found/via-beforeLoad']['id'],
- ServerFileRoutesByPath['/not-found/via-beforeLoad']['path'],
- ServerFileRoutesByPath['/not-found/via-beforeLoad']['fullPath'],
- unknown
- >
}
declare module './routes/not-found/via-loader' {
const createFileRoute: CreateFileRoute<
@@ -1309,14 +910,6 @@ declare module './routes/not-found/via-loader' {
FileRoutesByPath['/not-found/via-loader']['path'],
FileRoutesByPath['/not-found/via-loader']['fullPath']
>
-
- const createServerFileRoute: CreateServerFileRoute<
- ServerFileRoutesByPath['/not-found/via-loader']['parentRoute'],
- ServerFileRoutesByPath['/not-found/via-loader']['id'],
- ServerFileRoutesByPath['/not-found/via-loader']['path'],
- ServerFileRoutesByPath['/not-found/via-loader']['fullPath'],
- unknown
- >
}
declare module './routes/posts.$postId' {
const createFileRoute: CreateFileRoute<
@@ -1326,14 +919,6 @@ declare module './routes/posts.$postId' {
FileRoutesByPath['/posts/$postId']['path'],
FileRoutesByPath['/posts/$postId']['fullPath']
>
-
- const createServerFileRoute: CreateServerFileRoute<
- ServerFileRoutesByPath['/posts/$postId']['parentRoute'],
- ServerFileRoutesByPath['/posts/$postId']['id'],
- ServerFileRoutesByPath['/posts/$postId']['path'],
- ServerFileRoutesByPath['/posts/$postId']['fullPath'],
- unknown
- >
}
declare module './routes/redirect/$target' {
const createFileRoute: CreateFileRoute<
@@ -1343,14 +928,6 @@ declare module './routes/redirect/$target' {
FileRoutesByPath['/redirect/$target']['path'],
FileRoutesByPath['/redirect/$target']['fullPath']
>
-
- const createServerFileRoute: CreateServerFileRoute<
- ServerFileRoutesByPath['/redirect/$target']['parentRoute'],
- ServerFileRoutesByPath['/redirect/$target']['id'],
- ServerFileRoutesByPath['/redirect/$target']['path'],
- ServerFileRoutesByPath['/redirect/$target']['fullPath'],
- unknown
- >
}
declare module './routes/search-params/default' {
const createFileRoute: CreateFileRoute<
@@ -1360,14 +937,6 @@ declare module './routes/search-params/default' {
FileRoutesByPath['/search-params/default']['path'],
FileRoutesByPath['/search-params/default']['fullPath']
>
-
- const createServerFileRoute: CreateServerFileRoute<
- ServerFileRoutesByPath['/search-params/default']['parentRoute'],
- ServerFileRoutesByPath['/search-params/default']['id'],
- ServerFileRoutesByPath['/search-params/default']['path'],
- ServerFileRoutesByPath['/search-params/default']['fullPath'],
- unknown
- >
}
declare module './routes/search-params/loader-throws-redirect' {
const createFileRoute: CreateFileRoute<
@@ -1377,14 +946,6 @@ declare module './routes/search-params/loader-throws-redirect' {
FileRoutesByPath['/search-params/loader-throws-redirect']['path'],
FileRoutesByPath['/search-params/loader-throws-redirect']['fullPath']
>
-
- const createServerFileRoute: CreateServerFileRoute<
- ServerFileRoutesByPath['/search-params/loader-throws-redirect']['parentRoute'],
- ServerFileRoutesByPath['/search-params/loader-throws-redirect']['id'],
- ServerFileRoutesByPath['/search-params/loader-throws-redirect']['path'],
- ServerFileRoutesByPath['/search-params/loader-throws-redirect']['fullPath'],
- unknown
- >
}
declare module './routes/users.$userId' {
const createFileRoute: CreateFileRoute<
@@ -1394,14 +955,6 @@ declare module './routes/users.$userId' {
FileRoutesByPath['/users/$userId']['path'],
FileRoutesByPath['/users/$userId']['fullPath']
>
-
- const createServerFileRoute: CreateServerFileRoute<
- ServerFileRoutesByPath['/users/$userId']['parentRoute'],
- ServerFileRoutesByPath['/users/$userId']['id'],
- ServerFileRoutesByPath['/users/$userId']['path'],
- ServerFileRoutesByPath['/users/$userId']['fullPath'],
- unknown
- >
}
declare module './routes/not-found/index' {
const createFileRoute: CreateFileRoute<
@@ -1411,14 +964,6 @@ declare module './routes/not-found/index' {
FileRoutesByPath['/not-found/']['path'],
FileRoutesByPath['/not-found/']['fullPath']
>
-
- const createServerFileRoute: CreateServerFileRoute<
- ServerFileRoutesByPath['/not-found/']['parentRoute'],
- ServerFileRoutesByPath['/not-found/']['id'],
- ServerFileRoutesByPath['/not-found/']['path'],
- ServerFileRoutesByPath['/not-found/']['fullPath'],
- unknown
- >
}
declare module './routes/posts.index' {
const createFileRoute: CreateFileRoute<
@@ -1428,14 +973,6 @@ declare module './routes/posts.index' {
FileRoutesByPath['/posts/']['path'],
FileRoutesByPath['/posts/']['fullPath']
>
-
- const createServerFileRoute: CreateServerFileRoute<
- ServerFileRoutesByPath['/posts/']['parentRoute'],
- ServerFileRoutesByPath['/posts/']['id'],
- ServerFileRoutesByPath['/posts/']['path'],
- ServerFileRoutesByPath['/posts/']['fullPath'],
- unknown
- >
}
declare module './routes/redirect/index' {
const createFileRoute: CreateFileRoute<
@@ -1445,14 +982,6 @@ declare module './routes/redirect/index' {
FileRoutesByPath['/redirect/']['path'],
FileRoutesByPath['/redirect/']['fullPath']
>
-
- const createServerFileRoute: CreateServerFileRoute<
- ServerFileRoutesByPath['/redirect/']['parentRoute'],
- ServerFileRoutesByPath['/redirect/']['id'],
- ServerFileRoutesByPath['/redirect/']['path'],
- ServerFileRoutesByPath['/redirect/']['fullPath'],
- unknown
- >
}
declare module './routes/search-params/index' {
const createFileRoute: CreateFileRoute<
@@ -1462,14 +991,6 @@ declare module './routes/search-params/index' {
FileRoutesByPath['/search-params/']['path'],
FileRoutesByPath['/search-params/']['fullPath']
>
-
- const createServerFileRoute: CreateServerFileRoute<
- ServerFileRoutesByPath['/search-params/']['parentRoute'],
- ServerFileRoutesByPath['/search-params/']['id'],
- ServerFileRoutesByPath['/search-params/']['path'],
- ServerFileRoutesByPath['/search-params/']['fullPath'],
- unknown
- >
}
declare module './routes/users.index' {
const createFileRoute: CreateFileRoute<
@@ -1479,14 +1000,6 @@ declare module './routes/users.index' {
FileRoutesByPath['/users/']['path'],
FileRoutesByPath['/users/']['fullPath']
>
-
- const createServerFileRoute: CreateServerFileRoute<
- ServerFileRoutesByPath['/users/']['parentRoute'],
- ServerFileRoutesByPath['/users/']['id'],
- ServerFileRoutesByPath['/users/']['path'],
- ServerFileRoutesByPath['/users/']['fullPath'],
- unknown
- >
}
declare module './routes/_layout/_layout-2/layout-a' {
const createFileRoute: CreateFileRoute<
@@ -1496,14 +1009,6 @@ declare module './routes/_layout/_layout-2/layout-a' {
FileRoutesByPath['/_layout/_layout-2/layout-a']['path'],
FileRoutesByPath['/_layout/_layout-2/layout-a']['fullPath']
>
-
- const createServerFileRoute: CreateServerFileRoute<
- ServerFileRoutesByPath['/_layout/_layout-2/layout-a']['parentRoute'],
- ServerFileRoutesByPath['/_layout/_layout-2/layout-a']['id'],
- ServerFileRoutesByPath['/_layout/_layout-2/layout-a']['path'],
- ServerFileRoutesByPath['/_layout/_layout-2/layout-a']['fullPath'],
- unknown
- >
}
declare module './routes/_layout/_layout-2/layout-b' {
const createFileRoute: CreateFileRoute<
@@ -1513,14 +1018,6 @@ declare module './routes/_layout/_layout-2/layout-b' {
FileRoutesByPath['/_layout/_layout-2/layout-b']['path'],
FileRoutesByPath['/_layout/_layout-2/layout-b']['fullPath']
>
-
- const createServerFileRoute: CreateServerFileRoute<
- ServerFileRoutesByPath['/_layout/_layout-2/layout-b']['parentRoute'],
- ServerFileRoutesByPath['/_layout/_layout-2/layout-b']['id'],
- ServerFileRoutesByPath['/_layout/_layout-2/layout-b']['path'],
- ServerFileRoutesByPath['/_layout/_layout-2/layout-b']['fullPath'],
- unknown
- >
}
declare module './routes/api/users.$id' {
const createFileRoute: CreateFileRoute<
@@ -1530,14 +1027,6 @@ declare module './routes/api/users.$id' {
FileRoutesByPath['/api/users/$id']['path'],
FileRoutesByPath['/api/users/$id']['fullPath']
>
-
- const createServerFileRoute: CreateServerFileRoute<
- ServerFileRoutesByPath['/api/users/$id']['parentRoute'],
- ServerFileRoutesByPath['/api/users/$id']['id'],
- ServerFileRoutesByPath['/api/users/$id']['path'],
- ServerFileRoutesByPath['/api/users/$id']['fullPath'],
- unknown
- >
}
declare module './routes/posts_.$postId.deep' {
const createFileRoute: CreateFileRoute<
@@ -1547,14 +1036,6 @@ declare module './routes/posts_.$postId.deep' {
FileRoutesByPath['/posts_/$postId/deep']['path'],
FileRoutesByPath['/posts_/$postId/deep']['fullPath']
>
-
- const createServerFileRoute: CreateServerFileRoute<
- ServerFileRoutesByPath['/posts_/$postId/deep']['parentRoute'],
- ServerFileRoutesByPath['/posts_/$postId/deep']['id'],
- ServerFileRoutesByPath['/posts_/$postId/deep']['path'],
- ServerFileRoutesByPath['/posts_/$postId/deep']['fullPath'],
- unknown
- >
}
declare module './routes/redirect/$target/via-beforeLoad' {
const createFileRoute: CreateFileRoute<
@@ -1564,14 +1045,6 @@ declare module './routes/redirect/$target/via-beforeLoad' {
FileRoutesByPath['/redirect/$target/via-beforeLoad']['path'],
FileRoutesByPath['/redirect/$target/via-beforeLoad']['fullPath']
>
-
- const createServerFileRoute: CreateServerFileRoute<
- ServerFileRoutesByPath['/redirect/$target/via-beforeLoad']['parentRoute'],
- ServerFileRoutesByPath['/redirect/$target/via-beforeLoad']['id'],
- ServerFileRoutesByPath['/redirect/$target/via-beforeLoad']['path'],
- ServerFileRoutesByPath['/redirect/$target/via-beforeLoad']['fullPath'],
- unknown
- >
}
declare module './routes/redirect/$target/via-loader' {
const createFileRoute: CreateFileRoute<
@@ -1581,14 +1054,6 @@ declare module './routes/redirect/$target/via-loader' {
FileRoutesByPath['/redirect/$target/via-loader']['path'],
FileRoutesByPath['/redirect/$target/via-loader']['fullPath']
>
-
- const createServerFileRoute: CreateServerFileRoute<
- ServerFileRoutesByPath['/redirect/$target/via-loader']['parentRoute'],
- ServerFileRoutesByPath['/redirect/$target/via-loader']['id'],
- ServerFileRoutesByPath['/redirect/$target/via-loader']['path'],
- ServerFileRoutesByPath['/redirect/$target/via-loader']['fullPath'],
- unknown
- >
}
declare module './routes/redirect/$target/index' {
const createFileRoute: CreateFileRoute<
@@ -1598,14 +1063,6 @@ declare module './routes/redirect/$target/index' {
FileRoutesByPath['/redirect/$target/']['path'],
FileRoutesByPath['/redirect/$target/']['fullPath']
>
-
- const createServerFileRoute: CreateServerFileRoute<
- ServerFileRoutesByPath['/redirect/$target/']['parentRoute'],
- ServerFileRoutesByPath['/redirect/$target/']['id'],
- ServerFileRoutesByPath['/redirect/$target/']['path'],
- ServerFileRoutesByPath['/redirect/$target/']['fullPath'],
- unknown
- >
}
declare module './routes/foo/$bar/$qux/_here' {
const createFileRoute: CreateFileRoute<
@@ -1615,14 +1072,6 @@ declare module './routes/foo/$bar/$qux/_here' {
FileRoutesByPath['/foo/$bar/$qux/_here']['path'],
FileRoutesByPath['/foo/$bar/$qux/_here']['fullPath']
>
-
- const createServerFileRoute: CreateServerFileRoute<
- ServerFileRoutesByPath['/foo/$bar/$qux/_here']['parentRoute'],
- ServerFileRoutesByPath['/foo/$bar/$qux/_here']['id'],
- ServerFileRoutesByPath['/foo/$bar/$qux/_here']['path'],
- ServerFileRoutesByPath['/foo/$bar/$qux/_here']['fullPath'],
- unknown
- >
}
declare module './routes/redirect/$target/serverFn/via-beforeLoad' {
const createFileRoute: CreateFileRoute<
@@ -1632,14 +1081,6 @@ declare module './routes/redirect/$target/serverFn/via-beforeLoad' {
FileRoutesByPath['/redirect/$target/serverFn/via-beforeLoad']['path'],
FileRoutesByPath['/redirect/$target/serverFn/via-beforeLoad']['fullPath']
>
-
- const createServerFileRoute: CreateServerFileRoute<
- ServerFileRoutesByPath['/redirect/$target/serverFn/via-beforeLoad']['parentRoute'],
- ServerFileRoutesByPath['/redirect/$target/serverFn/via-beforeLoad']['id'],
- ServerFileRoutesByPath['/redirect/$target/serverFn/via-beforeLoad']['path'],
- ServerFileRoutesByPath['/redirect/$target/serverFn/via-beforeLoad']['fullPath'],
- unknown
- >
}
declare module './routes/redirect/$target/serverFn/via-loader' {
const createFileRoute: CreateFileRoute<
@@ -1649,14 +1090,6 @@ declare module './routes/redirect/$target/serverFn/via-loader' {
FileRoutesByPath['/redirect/$target/serverFn/via-loader']['path'],
FileRoutesByPath['/redirect/$target/serverFn/via-loader']['fullPath']
>
-
- const createServerFileRoute: CreateServerFileRoute<
- ServerFileRoutesByPath['/redirect/$target/serverFn/via-loader']['parentRoute'],
- ServerFileRoutesByPath['/redirect/$target/serverFn/via-loader']['id'],
- ServerFileRoutesByPath['/redirect/$target/serverFn/via-loader']['path'],
- ServerFileRoutesByPath['/redirect/$target/serverFn/via-loader']['fullPath'],
- unknown
- >
}
declare module './routes/redirect/$target/serverFn/via-useServerFn' {
const createFileRoute: CreateFileRoute<
@@ -1666,14 +1099,6 @@ declare module './routes/redirect/$target/serverFn/via-useServerFn' {
FileRoutesByPath['/redirect/$target/serverFn/via-useServerFn']['path'],
FileRoutesByPath['/redirect/$target/serverFn/via-useServerFn']['fullPath']
>
-
- const createServerFileRoute: CreateServerFileRoute<
- ServerFileRoutesByPath['/redirect/$target/serverFn/via-useServerFn']['parentRoute'],
- ServerFileRoutesByPath['/redirect/$target/serverFn/via-useServerFn']['id'],
- ServerFileRoutesByPath['/redirect/$target/serverFn/via-useServerFn']['path'],
- ServerFileRoutesByPath['/redirect/$target/serverFn/via-useServerFn']['fullPath'],
- unknown
- >
}
declare module './routes/redirect/$target/serverFn/index' {
const createFileRoute: CreateFileRoute<
@@ -1683,14 +1108,6 @@ declare module './routes/redirect/$target/serverFn/index' {
FileRoutesByPath['/redirect/$target/serverFn/']['path'],
FileRoutesByPath['/redirect/$target/serverFn/']['fullPath']
>
-
- const createServerFileRoute: CreateServerFileRoute<
- ServerFileRoutesByPath['/redirect/$target/serverFn/']['parentRoute'],
- ServerFileRoutesByPath['/redirect/$target/serverFn/']['id'],
- ServerFileRoutesByPath['/redirect/$target/serverFn/']['path'],
- ServerFileRoutesByPath['/redirect/$target/serverFn/']['fullPath'],
- unknown
- >
}
declare module './routes/foo/$bar/$qux/_here/index' {
const createFileRoute: CreateFileRoute<
@@ -1700,14 +1117,6 @@ declare module './routes/foo/$bar/$qux/_here/index' {
FileRoutesByPath['/foo/$bar/$qux/_here/']['path'],
FileRoutesByPath['/foo/$bar/$qux/_here/']['fullPath']
>
-
- const createServerFileRoute: CreateServerFileRoute<
- ServerFileRoutesByPath['/foo/$bar/$qux/_here/']['parentRoute'],
- ServerFileRoutesByPath['/foo/$bar/$qux/_here/']['id'],
- ServerFileRoutesByPath['/foo/$bar/$qux/_here/']['path'],
- ServerFileRoutesByPath['/foo/$bar/$qux/_here/']['fullPath'],
- unknown
- >
}
interface NotFoundRouteRouteChildren {
@@ -1790,6 +1199,18 @@ const UsersRouteChildren: UsersRouteChildren = {
const UsersRouteWithChildren = UsersRoute._addFileChildren(UsersRouteChildren)
+interface ApiUsersRouteChildren {
+ ApiUsersIdRoute: typeof ApiUsersIdRoute
+}
+
+const ApiUsersRouteChildren: ApiUsersRouteChildren = {
+ ApiUsersIdRoute: ApiUsersIdRoute,
+}
+
+const ApiUsersRouteWithChildren = ApiUsersRoute._addFileChildren(
+ ApiUsersRouteChildren,
+)
+
interface RedirectTargetRouteChildren {
RedirectTargetViaBeforeLoadRoute: typeof RedirectTargetViaBeforeLoadRoute
RedirectTargetViaLoaderRoute: typeof RedirectTargetViaLoaderRoute
@@ -1840,18 +1261,6 @@ const FooBarQuxRouteWithChildren = FooBarQuxRoute._addFileChildren(
FooBarQuxRouteChildren,
)
-interface ApiUsersServerRouteChildren {
- ApiUsersIdServerRoute: typeof ApiUsersIdServerRoute
-}
-
-const ApiUsersServerRouteChildren: ApiUsersServerRouteChildren = {
- ApiUsersIdServerRoute: ApiUsersIdServerRoute,
-}
-
-const ApiUsersServerRouteWithChildren = ApiUsersServerRoute._addFileChildren(
- ApiUsersServerRouteChildren,
-)
-
const rootRouteChildren: RootRouteChildren = {
IndexRoute: IndexRoute,
NotFoundRouteRoute: NotFoundRouteRouteWithChildren,
@@ -1865,6 +1274,7 @@ const rootRouteChildren: RootRouteChildren = {
UsersRoute: UsersRouteWithChildren,
Char45824Char54620Char48124Char44397Route:
Char45824Char54620Char48124Char44397Route,
+ ApiUsersRoute: ApiUsersRouteWithChildren,
RedirectTargetRoute: RedirectTargetRouteWithChildren,
RedirectIndexRoute: RedirectIndexRoute,
PostsPostIdDeepRoute: PostsPostIdDeepRoute,
@@ -1873,9 +1283,3 @@ const rootRouteChildren: RootRouteChildren = {
export const routeTree = rootRouteImport
._addFileChildren(rootRouteChildren)
._addFileTypes()
-const rootServerRouteChildren: RootServerRouteChildren = {
- ApiUsersServerRoute: ApiUsersServerRouteWithChildren,
-}
-export const serverRouteTree = rootServerRouteImport
- ._addFileChildren(rootServerRouteChildren)
- ._addFileTypes()
diff --git a/e2e/react-start/basic/src/routes/api.users.ts b/e2e/react-start/basic/src/routes/api.users.ts
index 6a27f556c6..a760bd201e 100644
--- a/e2e/react-start/basic/src/routes/api.users.ts
+++ b/e2e/react-start/basic/src/routes/api.users.ts
@@ -9,13 +9,19 @@ if (import.meta.env.VITE_NODE_ENV === 'test') {
queryURL = `http://localhost:${import.meta.env.VITE_EXTERNAL_PORT}`
}
-export const ServerRoute = createServerFileRoute().methods({
- GET: async ({ request }) => {
- console.info('Fetching users... @', request.url)
- const res = await axios.get>(`${queryURL}/users`)
+export const Route = createFileRoute({
+ server: {
+ handlers: {
+ GET: async ({ request }) => {
+ console.info('Fetching users... @', request.url)
+ const res = await axios.get>(`${queryURL}/users`)
- const list = res.data.slice(0, 10)
+ const list = res.data.slice(0, 10)
- return json(list.map((u) => ({ id: u.id, name: u.name, email: u.email })))
+ return json(
+ list.map((u) => ({ id: u.id, name: u.name, email: u.email })),
+ )
+ },
+ },
},
})
diff --git a/e2e/react-start/basic/src/routes/api/users.$id.ts b/e2e/react-start/basic/src/routes/api/users.$id.ts
index 4da7586562..4133889844 100644
--- a/e2e/react-start/basic/src/routes/api/users.$id.ts
+++ b/e2e/react-start/basic/src/routes/api/users.$id.ts
@@ -8,20 +8,24 @@ if (import.meta.env.VITE_NODE_ENV === 'test') {
queryURL = `http://localhost:${import.meta.env.VITE_EXTERNAL_PORT}`
}
-export const ServerRoute = createServerFileRoute().methods({
- GET: async ({ request, params }) => {
- console.info(`Fetching users by id=${params.id}... @`, request.url)
- try {
- const res = await axios.get(`${queryURL}/users/` + params.id)
+export const Route = createFileRoute({
+ server: {
+ handlers: {
+ GET: async ({ request, params }) => {
+ console.info(`Fetching users by id=${params.id}... @`, request.url)
+ try {
+ const res = await axios.get(`${queryURL}/users/` + params.id)
- return json({
- id: res.data.id,
- name: res.data.name,
- email: res.data.email,
- })
- } catch (e) {
- console.error(e)
- return json({ error: 'User not found' }, { status: 404 })
- }
+ return json({
+ id: res.data.id,
+ name: res.data.name,
+ email: res.data.email,
+ })
+ } catch (e) {
+ console.error(e)
+ return json({ error: 'User not found' }, { status: 404 })
+ }
+ },
+ },
},
})
diff --git a/e2e/react-start/basic/src/server.ts b/e2e/react-start/basic/src/server.ts
index 77cb4a1316..00d13b4d17 100644
--- a/e2e/react-start/basic/src/server.ts
+++ b/e2e/react-start/basic/src/server.ts
@@ -1,13 +1,11 @@
// DO NOT DELETE THIS FILE!!!
// This file is a good smoke test to make sure the custom server entry is working
-import {
- createStartHandler,
- defaultStreamHandler,
-} from '@tanstack/react-start/server'
-import { createRouter } from './router'
+import handler from '@tanstack/react-start/server-entry'
console.log("[server-entry]: using custom server entry in 'src/server.ts'")
-export default createStartHandler({
- createRouter,
-})(defaultStreamHandler)
+export default {
+ fetch(request: Request) {
+ return handler.fetch(request)
+ },
+}
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/routeTree.gen.ts b/e2e/react-start/custom-basepath/src/routeTree.gen.ts
index 81100d418e..2e46070990 100644
--- a/e2e/react-start/custom-basepath/src/routeTree.gen.ts
+++ b/e2e/react-start/custom-basepath/src/routeTree.gen.ts
@@ -8,8 +8,6 @@
// 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 UsersRouteImport } from './routes/users'
import { Route as PostsRouteImport } from './routes/posts'
@@ -20,11 +18,9 @@ import { Route as UsersIndexRouteImport } from './routes/users.index'
import { Route as PostsIndexRouteImport } from './routes/posts.index'
import { Route as UsersUserIdRouteImport } from './routes/users.$userId'
import { Route as PostsPostIdRouteImport } from './routes/posts.$postId'
+import { Route as ApiUsersRouteImport } from './routes/api.users'
import { Route as PostsPostIdDeepRouteImport } from './routes/posts_.$postId.deep'
-import { ServerRoute as ApiUsersServerRouteImport } from './routes/api.users'
-import { ServerRoute as ApiUsersIdServerRouteImport } from './routes/api/users.$id'
-
-const rootServerRouteImport = createServerRootRoute()
+import { Route as ApiUsersIdRouteImport } from './routes/api/users.$id'
const UsersRoute = UsersRouteImport.update({
id: '/users',
@@ -71,20 +67,20 @@ const PostsPostIdRoute = PostsPostIdRouteImport.update({
path: '/$postId',
getParentRoute: () => PostsRoute,
} as any)
+const ApiUsersRoute = ApiUsersRouteImport.update({
+ id: '/api/users',
+ path: '/api/users',
+ getParentRoute: () => rootRouteImport,
+} as any)
const PostsPostIdDeepRoute = PostsPostIdDeepRouteImport.update({
id: '/posts_/$postId/deep',
path: '/posts/$postId/deep',
getParentRoute: () => rootRouteImport,
} as any)
-const ApiUsersServerRoute = ApiUsersServerRouteImport.update({
- id: '/api/users',
- path: '/api/users',
- getParentRoute: () => rootServerRouteImport,
-} as any)
-const ApiUsersIdServerRoute = ApiUsersIdServerRouteImport.update({
+const ApiUsersIdRoute = ApiUsersIdRouteImport.update({
id: '/$id',
path: '/$id',
- getParentRoute: () => ApiUsersServerRoute,
+ getParentRoute: () => ApiUsersRoute,
} as any)
export interface FileRoutesByFullPath {
@@ -93,20 +89,24 @@ export interface FileRoutesByFullPath {
'/logout': typeof LogoutRoute
'/posts': typeof PostsRouteWithChildren
'/users': typeof UsersRouteWithChildren
+ '/api/users': typeof ApiUsersRouteWithChildren
'/posts/$postId': typeof PostsPostIdRoute
'/users/$userId': typeof UsersUserIdRoute
'/posts/': typeof PostsIndexRoute
'/users/': typeof UsersIndexRoute
+ '/api/users/$id': typeof ApiUsersIdRoute
'/posts/$postId/deep': typeof PostsPostIdDeepRoute
}
export interface FileRoutesByTo {
'/': typeof IndexRoute
'/deferred': typeof DeferredRoute
'/logout': typeof LogoutRoute
+ '/api/users': typeof ApiUsersRouteWithChildren
'/posts/$postId': typeof PostsPostIdRoute
'/users/$userId': typeof UsersUserIdRoute
'/posts': typeof PostsIndexRoute
'/users': typeof UsersIndexRoute
+ '/api/users/$id': typeof ApiUsersIdRoute
'/posts/$postId/deep': typeof PostsPostIdDeepRoute
}
export interface FileRoutesById {
@@ -116,10 +116,12 @@ export interface FileRoutesById {
'/logout': typeof LogoutRoute
'/posts': typeof PostsRouteWithChildren
'/users': typeof UsersRouteWithChildren
+ '/api/users': typeof ApiUsersRouteWithChildren
'/posts/$postId': typeof PostsPostIdRoute
'/users/$userId': typeof UsersUserIdRoute
'/posts/': typeof PostsIndexRoute
'/users/': typeof UsersIndexRoute
+ '/api/users/$id': typeof ApiUsersIdRoute
'/posts_/$postId/deep': typeof PostsPostIdDeepRoute
}
export interface FileRouteTypes {
@@ -130,20 +132,24 @@ export interface FileRouteTypes {
| '/logout'
| '/posts'
| '/users'
+ | '/api/users'
| '/posts/$postId'
| '/users/$userId'
| '/posts/'
| '/users/'
+ | '/api/users/$id'
| '/posts/$postId/deep'
fileRoutesByTo: FileRoutesByTo
to:
| '/'
| '/deferred'
| '/logout'
+ | '/api/users'
| '/posts/$postId'
| '/users/$userId'
| '/posts'
| '/users'
+ | '/api/users/$id'
| '/posts/$postId/deep'
id:
| '__root__'
@@ -152,10 +158,12 @@ export interface FileRouteTypes {
| '/logout'
| '/posts'
| '/users'
+ | '/api/users'
| '/posts/$postId'
| '/users/$userId'
| '/posts/'
| '/users/'
+ | '/api/users/$id'
| '/posts_/$postId/deep'
fileRoutesById: FileRoutesById
}
@@ -165,32 +173,9 @@ export interface RootRouteChildren {
LogoutRoute: typeof LogoutRoute
PostsRoute: typeof PostsRouteWithChildren
UsersRoute: typeof UsersRouteWithChildren
+ ApiUsersRoute: typeof ApiUsersRouteWithChildren
PostsPostIdDeepRoute: typeof PostsPostIdDeepRoute
}
-export interface FileServerRoutesByFullPath {
- '/api/users': typeof ApiUsersServerRouteWithChildren
- '/api/users/$id': typeof ApiUsersIdServerRoute
-}
-export interface FileServerRoutesByTo {
- '/api/users': typeof ApiUsersServerRouteWithChildren
- '/api/users/$id': typeof ApiUsersIdServerRoute
-}
-export interface FileServerRoutesById {
- __root__: typeof rootServerRouteImport
- '/api/users': typeof ApiUsersServerRouteWithChildren
- '/api/users/$id': typeof ApiUsersIdServerRoute
-}
-export interface FileServerRouteTypes {
- fileServerRoutesByFullPath: FileServerRoutesByFullPath
- fullPaths: '/api/users' | '/api/users/$id'
- fileServerRoutesByTo: FileServerRoutesByTo
- to: '/api/users' | '/api/users/$id'
- id: '__root__' | '/api/users' | '/api/users/$id'
- fileServerRoutesById: FileServerRoutesById
-}
-export interface RootServerRouteChildren {
- ApiUsersServerRoute: typeof ApiUsersServerRouteWithChildren
-}
declare module '@tanstack/react-router' {
interface FileRoutesByPath {
@@ -257,6 +242,13 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof PostsPostIdRouteImport
parentRoute: typeof PostsRoute
}
+ '/api/users': {
+ id: '/api/users'
+ path: '/api/users'
+ fullPath: '/api/users'
+ preLoaderRoute: typeof ApiUsersRouteImport
+ parentRoute: typeof rootRouteImport
+ }
'/posts_/$postId/deep': {
id: '/posts_/$postId/deep'
path: '/posts/$postId/deep'
@@ -264,23 +256,12 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof PostsPostIdDeepRouteImport
parentRoute: typeof rootRouteImport
}
- }
-}
-declare module '@tanstack/react-start/server' {
- interface ServerFileRoutesByPath {
- '/api/users': {
- id: '/api/users'
- path: '/api/users'
- fullPath: '/api/users'
- preLoaderRoute: typeof ApiUsersServerRouteImport
- parentRoute: typeof rootServerRouteImport
- }
'/api/users/$id': {
id: '/api/users/$id'
path: '/$id'
fullPath: '/api/users/$id'
- preLoaderRoute: typeof ApiUsersIdServerRouteImport
- parentRoute: typeof ApiUsersServerRoute
+ preLoaderRoute: typeof ApiUsersIdRouteImport
+ parentRoute: typeof ApiUsersRoute
}
}
}
@@ -309,16 +290,16 @@ const UsersRouteChildren: UsersRouteChildren = {
const UsersRouteWithChildren = UsersRoute._addFileChildren(UsersRouteChildren)
-interface ApiUsersServerRouteChildren {
- ApiUsersIdServerRoute: typeof ApiUsersIdServerRoute
+interface ApiUsersRouteChildren {
+ ApiUsersIdRoute: typeof ApiUsersIdRoute
}
-const ApiUsersServerRouteChildren: ApiUsersServerRouteChildren = {
- ApiUsersIdServerRoute: ApiUsersIdServerRoute,
+const ApiUsersRouteChildren: ApiUsersRouteChildren = {
+ ApiUsersIdRoute: ApiUsersIdRoute,
}
-const ApiUsersServerRouteWithChildren = ApiUsersServerRoute._addFileChildren(
- ApiUsersServerRouteChildren,
+const ApiUsersRouteWithChildren = ApiUsersRoute._addFileChildren(
+ ApiUsersRouteChildren,
)
const rootRouteChildren: RootRouteChildren = {
@@ -327,14 +308,9 @@ const rootRouteChildren: RootRouteChildren = {
LogoutRoute: LogoutRoute,
PostsRoute: PostsRouteWithChildren,
UsersRoute: UsersRouteWithChildren,
+ ApiUsersRoute: ApiUsersRouteWithChildren,
PostsPostIdDeepRoute: PostsPostIdDeepRoute,
}
export const routeTree = rootRouteImport
._addFileChildren(rootRouteChildren)
._addFileTypes()
-const rootServerRouteChildren: RootServerRouteChildren = {
- ApiUsersServerRoute: ApiUsersServerRouteWithChildren,
-}
-export const serverRouteTree = rootServerRouteImport
- ._addFileChildren(rootServerRouteChildren)
- ._addFileTypes()
diff --git a/e2e/react-start/custom-basepath/src/routes/api.users.ts b/e2e/react-start/custom-basepath/src/routes/api.users.ts
index fdb8d0067c..a03076490b 100644
--- a/e2e/react-start/custom-basepath/src/routes/api.users.ts
+++ b/e2e/react-start/custom-basepath/src/routes/api.users.ts
@@ -1,4 +1,4 @@
-import { createServerFileRoute } from '@tanstack/react-start/server'
+import { createFileRoute } from '@tanstack/react-router'
import { json } from '@tanstack/react-start'
import axios from 'redaxios'
@@ -10,13 +10,19 @@ if (import.meta.env.VITE_NODE_ENV === 'test') {
queryURL = `http://localhost:${import.meta.env.VITE_EXTERNAL_PORT}`
}
-export const ServerRoute = createServerFileRoute('/api/users').methods({
- GET: async ({ request }) => {
- console.info('Fetching users... @', request.url)
- const res = await axios.get>(`${queryURL}/users`)
+export const Route = createFileRoute('/api/users')({
+ server: {
+ handlers: {
+ GET: async ({ request }) => {
+ console.info('Fetching users... @', request.url)
+ const res = await axios.get>(`${queryURL}/users`)
- const list = res.data.slice(0, 10)
+ const list = res.data.slice(0, 10)
- return json(list.map((u) => ({ id: u.id, name: u.name, email: u.email })))
+ return json(
+ list.map((u) => ({ id: u.id, name: u.name, email: u.email })),
+ )
+ },
+ },
},
})
diff --git a/e2e/react-start/custom-basepath/src/routes/api/users.$id.ts b/e2e/react-start/custom-basepath/src/routes/api/users.$id.ts
index e3f2a1c388..5a2b9fe621 100644
--- a/e2e/react-start/custom-basepath/src/routes/api/users.$id.ts
+++ b/e2e/react-start/custom-basepath/src/routes/api/users.$id.ts
@@ -1,7 +1,7 @@
-import { createServerFileRoute } from '@tanstack/react-start/server'
import { json } from '@tanstack/react-start'
import axios from 'redaxios'
import type { User } from '~/utils/users'
+import { createFileRoute } from '@tanstack/react-router'
let queryURL = 'https://jsonplaceholder.typicode.com'
@@ -9,20 +9,24 @@ if (import.meta.env.VITE_NODE_ENV === 'test') {
queryURL = `http://localhost:${import.meta.env.VITE_EXTERNAL_PORT}`
}
-export const ServerRoute = createServerFileRoute('/api/users/$id').methods({
- GET: async ({ request, params }) => {
- console.info(`Fetching users by id=${params.id}... @`, request.url)
- try {
- const res = await axios.get(`${queryURL}/users/` + params.id)
+export const Route = createFileRoute('/api/users/$id')({
+ server: {
+ handlers: {
+ GET: async ({ request, params }) => {
+ console.info(`Fetching users by id=${params.id}... @`, request.url)
+ try {
+ const res = await axios.get(`${queryURL}/users/` + params.id)
- return json({
- id: res.data.id,
- name: res.data.name,
- email: res.data.email,
- })
- } catch (e) {
- console.error(e)
- return json({ error: 'User not found' }, { status: 404 })
- }
+ return json({
+ id: res.data.id,
+ name: res.data.name,
+ email: res.data.email,
+ })
+ } catch (e) {
+ console.error(e)
+ return json({ error: 'User not found' }, { status: 404 })
+ }
+ },
+ },
},
})
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..54289a04f3
--- /dev/null
+++ b/e2e/react-start/server-context/src/routeTree.gen.ts
@@ -0,0 +1,103 @@
+/* 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 FooRouteImport } from './routes/foo'
+import { Route as IndexRouteImport } from './routes/index'
+import { Route as FooBarRouteImport } from './routes/foo/bar'
+
+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)
+
+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
+}
+
+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
+ }
+ }
+}
+
+interface FooRouteChildren {
+ FooBarRoute: typeof FooBarRoute
+}
+
+const FooRouteChildren: FooRouteChildren = {
+ FooBarRoute: FooBarRoute,
+}
+
+const FooRouteWithChildren = FooRoute._addFileChildren(FooRouteChildren)
+
+const rootRouteChildren: RootRouteChildren = {
+ IndexRoute: IndexRoute,
+ FooRoute: FooRouteWithChildren,
+}
+export const routeTree = rootRouteImport
+ ._addFileChildren(rootRouteChildren)
+ ._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..20aaa6006f
--- /dev/null
+++ b/e2e/react-start/server-context/src/routes/__root.tsx
@@ -0,0 +1,67 @@
+///
+import * as React from 'react'
+import {
+ HeadContent,
+ Link,
+ 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: DefaultCatchBoundary,
+ notFoundComponent: () => ,
+ shellComponent: RootDocument,
+})
+
+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..df570bb0db
--- /dev/null
+++ b/e2e/react-start/server-context/src/routes/foo.ts
@@ -0,0 +1,29 @@
+import { createMiddleware, json } from '@tanstack/react-start'
+import { createFileRoute } from '@tanstack/react-router'
+
+const testParentMiddleware = createMiddleware().server(async ({ next }) => {
+ const result = await next({ context: { testParent: true } })
+ return result
+})
+
+const testMiddleware = createMiddleware()
+ .middleware([testParentMiddleware])
+ .server(async ({ next }) => {
+ const result = await next({ context: { test: true } })
+ return result
+ })
+
+export const Route = createFileRoute('/foo')({
+ server: {
+ middleware: [testMiddleware],
+ handlers: {
+ GET: ({ request, context }) => {
+ return json({
+ url: request.url,
+ context: context,
+ expectedContext: { testParent: true, test: true },
+ })
+ },
+ },
+ },
+})
diff --git a/e2e/react-start/server-context/src/routes/foo/bar.tsx b/e2e/react-start/server-context/src/routes/foo/bar.tsx
new file mode 100644
index 0000000000..e37e8b6803
--- /dev/null
+++ b/e2e/react-start/server-context/src/routes/foo/bar.tsx
@@ -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/src/routeTree.gen.ts b/e2e/react-start/server-routes/src/routeTree.gen.ts
index 1d1d61ae49..5775b8640f 100644
--- a/e2e/react-start/server-routes/src/routeTree.gen.ts
+++ b/e2e/react-start/server-routes/src/routeTree.gen.ts
@@ -8,14 +8,10 @@
// 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 MergeServerFnMiddlewareContextRouteImport } from './routes/merge-server-fn-middleware-context'
import { Route as IndexRouteImport } from './routes/index'
-import { ServerRoute as ApiMiddlewareContextServerRouteImport } from './routes/api/middleware-context'
-
-const rootServerRouteImport = createServerRootRoute()
+import { Route as ApiMiddlewareContextRouteImport } from './routes/api/middleware-context'
const MergeServerFnMiddlewareContextRoute =
MergeServerFnMiddlewareContextRouteImport.update({
@@ -28,58 +24,47 @@ const IndexRoute = IndexRouteImport.update({
path: '/',
getParentRoute: () => rootRouteImport,
} as any)
-const ApiMiddlewareContextServerRoute =
- ApiMiddlewareContextServerRouteImport.update({
- id: '/api/middleware-context',
- path: '/api/middleware-context',
- getParentRoute: () => rootServerRouteImport,
- } as any)
+const ApiMiddlewareContextRoute = ApiMiddlewareContextRouteImport.update({
+ id: '/api/middleware-context',
+ path: '/api/middleware-context',
+ getParentRoute: () => rootRouteImport,
+} as any)
export interface FileRoutesByFullPath {
'/': typeof IndexRoute
'/merge-server-fn-middleware-context': typeof MergeServerFnMiddlewareContextRoute
+ '/api/middleware-context': typeof ApiMiddlewareContextRoute
}
export interface FileRoutesByTo {
'/': typeof IndexRoute
'/merge-server-fn-middleware-context': typeof MergeServerFnMiddlewareContextRoute
+ '/api/middleware-context': typeof ApiMiddlewareContextRoute
}
export interface FileRoutesById {
__root__: typeof rootRouteImport
'/': typeof IndexRoute
'/merge-server-fn-middleware-context': typeof MergeServerFnMiddlewareContextRoute
+ '/api/middleware-context': typeof ApiMiddlewareContextRoute
}
export interface FileRouteTypes {
fileRoutesByFullPath: FileRoutesByFullPath
- fullPaths: '/' | '/merge-server-fn-middleware-context'
+ fullPaths:
+ | '/'
+ | '/merge-server-fn-middleware-context'
+ | '/api/middleware-context'
fileRoutesByTo: FileRoutesByTo
- to: '/' | '/merge-server-fn-middleware-context'
- id: '__root__' | '/' | '/merge-server-fn-middleware-context'
+ to: '/' | '/merge-server-fn-middleware-context' | '/api/middleware-context'
+ id:
+ | '__root__'
+ | '/'
+ | '/merge-server-fn-middleware-context'
+ | '/api/middleware-context'
fileRoutesById: FileRoutesById
}
export interface RootRouteChildren {
IndexRoute: typeof IndexRoute
MergeServerFnMiddlewareContextRoute: typeof MergeServerFnMiddlewareContextRoute
-}
-export interface FileServerRoutesByFullPath {
- '/api/middleware-context': typeof ApiMiddlewareContextServerRoute
-}
-export interface FileServerRoutesByTo {
- '/api/middleware-context': typeof ApiMiddlewareContextServerRoute
-}
-export interface FileServerRoutesById {
- __root__: typeof rootServerRouteImport
- '/api/middleware-context': typeof ApiMiddlewareContextServerRoute
-}
-export interface FileServerRouteTypes {
- fileServerRoutesByFullPath: FileServerRoutesByFullPath
- fullPaths: '/api/middleware-context'
- fileServerRoutesByTo: FileServerRoutesByTo
- to: '/api/middleware-context'
- id: '__root__' | '/api/middleware-context'
- fileServerRoutesById: FileServerRoutesById
-}
-export interface RootServerRouteChildren {
- ApiMiddlewareContextServerRoute: typeof ApiMiddlewareContextServerRoute
+ ApiMiddlewareContextRoute: typeof ApiMiddlewareContextRoute
}
declare module '@tanstack/react-router' {
@@ -98,16 +83,12 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof IndexRouteImport
parentRoute: typeof rootRouteImport
}
- }
-}
-declare module '@tanstack/react-start/server' {
- interface ServerFileRoutesByPath {
'/api/middleware-context': {
id: '/api/middleware-context'
path: '/api/middleware-context'
fullPath: '/api/middleware-context'
- preLoaderRoute: typeof ApiMiddlewareContextServerRouteImport
- parentRoute: typeof rootServerRouteImport
+ preLoaderRoute: typeof ApiMiddlewareContextRouteImport
+ parentRoute: typeof rootRouteImport
}
}
}
@@ -115,13 +96,8 @@ declare module '@tanstack/react-start/server' {
const rootRouteChildren: RootRouteChildren = {
IndexRoute: IndexRoute,
MergeServerFnMiddlewareContextRoute: MergeServerFnMiddlewareContextRoute,
+ ApiMiddlewareContextRoute: ApiMiddlewareContextRoute,
}
export const routeTree = rootRouteImport
._addFileChildren(rootRouteChildren)
._addFileTypes()
-const rootServerRouteChildren: RootServerRouteChildren = {
- ApiMiddlewareContextServerRoute: ApiMiddlewareContextServerRoute,
-}
-export const serverRouteTree = rootServerRouteImport
- ._addFileChildren(rootServerRouteChildren)
- ._addFileTypes()
diff --git a/e2e/react-start/server-routes/src/routes/api/middleware-context.ts b/e2e/react-start/server-routes/src/routes/api/middleware-context.ts
index bc75e29126..e897aa9a3a 100644
--- a/e2e/react-start/server-routes/src/routes/api/middleware-context.ts
+++ b/e2e/react-start/server-routes/src/routes/api/middleware-context.ts
@@ -1,28 +1,29 @@
-import { createServerFileRoute } from '@tanstack/react-start/server'
+import { createFileRoute } from '@tanstack/react-router'
import { createMiddleware, json } from '@tanstack/react-start'
-const testParentMiddleware = createMiddleware({ type: 'request' }).server(
- async ({ next }) => {
- const result = await next({ context: { testParent: true } })
- return result
- },
-)
+const testParentMiddleware = createMiddleware().server(async ({ next }) => {
+ const result = await next({ context: { testParent: true } })
+ return result
+})
-const testMiddleware = createMiddleware({ type: 'request' })
+const testMiddleware = createMiddleware()
.middleware([testParentMiddleware])
.server(async ({ next }) => {
const result = await next({ context: { test: true } })
return result
})
-export const ServerRoute = createServerFileRoute('/api/middleware-context')
- .middleware([testMiddleware])
- .methods({
- GET: ({ request, context }) => {
- return json({
- url: request.url,
- context: context,
- expectedContext: { testParent: true, test: true },
- })
+export const Route = createFileRoute('/api/middleware-context')({
+ server: {
+ middleware: [testMiddleware],
+ handlers: {
+ GET: ({ request, context }) => {
+ return json({
+ url: request.url,
+ context: context,
+ expectedContext: { testParent: true, test: true },
+ })
+ },
},
- })
+ },
+})
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/src/routeTree.gen.ts b/e2e/react-start/website/src/routeTree.gen.ts
index e8358b4aa3..b880aa5798 100644
--- a/e2e/react-start/website/src/routeTree.gen.ts
+++ b/e2e/react-start/website/src/routeTree.gen.ts
@@ -8,8 +8,6 @@
// 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 LibraryRouteImport } from './routes/_library'
import { Route as LibraryIndexRouteImport } from './routes/_library.index'
@@ -19,11 +17,9 @@ import { Route as LibraryProjectVersionIndexRouteImport } from './routes/_librar
import { Route as ProjectVersionDocsIndexRouteImport } from './routes/$project.$version.docs.index'
import { Route as ProjectVersionDocsFrameworkFrameworkRouteImport } from './routes/$project.$version.docs.framework.$framework'
import { Route as ProjectVersionDocsFrameworkFrameworkIndexRouteImport } from './routes/$project.$version.docs.framework.$framework.index'
+import { Route as ProjectVersionDocsFrameworkFrameworkChar123Char125DotmdRouteImport } from './routes/$project.$version.docs.framework.$framework.{$}[.]md'
import { Route as ProjectVersionDocsFrameworkFrameworkSplatRouteImport } from './routes/$project.$version.docs.framework.$framework.$'
import { Route as ProjectVersionDocsFrameworkFrameworkExamplesSplatRouteImport } from './routes/$project.$version.docs.framework.$framework.examples.$'
-import { ServerRoute as ProjectVersionDocsFrameworkFrameworkChar123Char125DotmdServerRouteImport } from './routes/$project.$version.docs.framework.$framework.{$}[.]md'
-
-const rootServerRouteImport = createServerRootRoute()
const LibraryRoute = LibraryRouteImport.update({
id: '/_library',
@@ -67,6 +63,12 @@ const ProjectVersionDocsFrameworkFrameworkIndexRoute =
path: '/',
getParentRoute: () => ProjectVersionDocsFrameworkFrameworkRoute,
} as any)
+const ProjectVersionDocsFrameworkFrameworkChar123Char125DotmdRoute =
+ ProjectVersionDocsFrameworkFrameworkChar123Char125DotmdRouteImport.update({
+ id: '/{$}.md',
+ path: '/{$}.md',
+ getParentRoute: () => ProjectVersionDocsFrameworkFrameworkRoute,
+ } as any)
const ProjectVersionDocsFrameworkFrameworkSplatRoute =
ProjectVersionDocsFrameworkFrameworkSplatRouteImport.update({
id: '/$',
@@ -79,14 +81,6 @@ const ProjectVersionDocsFrameworkFrameworkExamplesSplatRoute =
path: '/examples/$',
getParentRoute: () => ProjectVersionDocsFrameworkFrameworkRoute,
} as any)
-const ProjectVersionDocsFrameworkFrameworkChar123Char125DotmdServerRoute =
- ProjectVersionDocsFrameworkFrameworkChar123Char125DotmdServerRouteImport.update(
- {
- id: '/$project/$version/docs/framework/$framework/{$}.md',
- path: '/$project/$version/docs/framework/$framework/{$}.md',
- getParentRoute: () => rootServerRouteImport,
- } as any,
- )
export interface FileRoutesByFullPath {
'/$project': typeof ProjectIndexRoute
@@ -95,6 +89,7 @@ export interface FileRoutesByFullPath {
'/$project/$version': typeof LibraryProjectVersionIndexRoute
'/$project/$version/docs/framework/$framework': typeof ProjectVersionDocsFrameworkFrameworkRouteWithChildren
'/$project/$version/docs/framework/$framework/$': typeof ProjectVersionDocsFrameworkFrameworkSplatRoute
+ '/$project/$version/docs/framework/$framework/{$}.md': typeof ProjectVersionDocsFrameworkFrameworkChar123Char125DotmdRoute
'/$project/$version/docs/framework/$framework/': typeof ProjectVersionDocsFrameworkFrameworkIndexRoute
'/$project/$version/docs/framework/$framework/examples/$': typeof ProjectVersionDocsFrameworkFrameworkExamplesSplatRoute
}
@@ -104,6 +99,7 @@ export interface FileRoutesByTo {
'/$project/$version/docs': typeof ProjectVersionDocsIndexRoute
'/$project/$version': typeof LibraryProjectVersionIndexRoute
'/$project/$version/docs/framework/$framework/$': typeof ProjectVersionDocsFrameworkFrameworkSplatRoute
+ '/$project/$version/docs/framework/$framework/{$}.md': typeof ProjectVersionDocsFrameworkFrameworkChar123Char125DotmdRoute
'/$project/$version/docs/framework/$framework': typeof ProjectVersionDocsFrameworkFrameworkIndexRoute
'/$project/$version/docs/framework/$framework/examples/$': typeof ProjectVersionDocsFrameworkFrameworkExamplesSplatRoute
}
@@ -117,6 +113,7 @@ export interface FileRoutesById {
'/_library/$project/$version/': typeof LibraryProjectVersionIndexRoute
'/$project/$version/docs/framework/$framework': typeof ProjectVersionDocsFrameworkFrameworkRouteWithChildren
'/$project/$version/docs/framework/$framework/$': typeof ProjectVersionDocsFrameworkFrameworkSplatRoute
+ '/$project/$version/docs/framework/$framework/{$}.md': typeof ProjectVersionDocsFrameworkFrameworkChar123Char125DotmdRoute
'/$project/$version/docs/framework/$framework/': typeof ProjectVersionDocsFrameworkFrameworkIndexRoute
'/$project/$version/docs/framework/$framework/examples/$': typeof ProjectVersionDocsFrameworkFrameworkExamplesSplatRoute
}
@@ -129,6 +126,7 @@ export interface FileRouteTypes {
| '/$project/$version'
| '/$project/$version/docs/framework/$framework'
| '/$project/$version/docs/framework/$framework/$'
+ | '/$project/$version/docs/framework/$framework/{$}.md'
| '/$project/$version/docs/framework/$framework/'
| '/$project/$version/docs/framework/$framework/examples/$'
fileRoutesByTo: FileRoutesByTo
@@ -138,6 +136,7 @@ export interface FileRouteTypes {
| '/$project/$version/docs'
| '/$project/$version'
| '/$project/$version/docs/framework/$framework/$'
+ | '/$project/$version/docs/framework/$framework/{$}.md'
| '/$project/$version/docs/framework/$framework'
| '/$project/$version/docs/framework/$framework/examples/$'
id:
@@ -150,6 +149,7 @@ export interface FileRouteTypes {
| '/_library/$project/$version/'
| '/$project/$version/docs/framework/$framework'
| '/$project/$version/docs/framework/$framework/$'
+ | '/$project/$version/docs/framework/$framework/{$}.md'
| '/$project/$version/docs/framework/$framework/'
| '/$project/$version/docs/framework/$framework/examples/$'
fileRoutesById: FileRoutesById
@@ -160,27 +160,6 @@ export interface RootRouteChildren {
ProjectVersionDocsIndexRoute: typeof ProjectVersionDocsIndexRoute
ProjectVersionDocsFrameworkFrameworkRoute: typeof ProjectVersionDocsFrameworkFrameworkRouteWithChildren
}
-export interface FileServerRoutesByFullPath {
- '/$project/$version/docs/framework/$framework/{$}.md': typeof ProjectVersionDocsFrameworkFrameworkChar123Char125DotmdServerRoute
-}
-export interface FileServerRoutesByTo {
- '/$project/$version/docs/framework/$framework/{$}.md': typeof ProjectVersionDocsFrameworkFrameworkChar123Char125DotmdServerRoute
-}
-export interface FileServerRoutesById {
- __root__: typeof rootServerRouteImport
- '/$project/$version/docs/framework/$framework/{$}.md': typeof ProjectVersionDocsFrameworkFrameworkChar123Char125DotmdServerRoute
-}
-export interface FileServerRouteTypes {
- fileServerRoutesByFullPath: FileServerRoutesByFullPath
- fullPaths: '/$project/$version/docs/framework/$framework/{$}.md'
- fileServerRoutesByTo: FileServerRoutesByTo
- to: '/$project/$version/docs/framework/$framework/{$}.md'
- id: '__root__' | '/$project/$version/docs/framework/$framework/{$}.md'
- fileServerRoutesById: FileServerRoutesById
-}
-export interface RootServerRouteChildren {
- ProjectVersionDocsFrameworkFrameworkChar123Char125DotmdServerRoute: typeof ProjectVersionDocsFrameworkFrameworkChar123Char125DotmdServerRoute
-}
declare module '@tanstack/react-router' {
interface FileRoutesByPath {
@@ -240,6 +219,13 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof ProjectVersionDocsFrameworkFrameworkIndexRouteImport
parentRoute: typeof ProjectVersionDocsFrameworkFrameworkRoute
}
+ '/$project/$version/docs/framework/$framework/{$}.md': {
+ id: '/$project/$version/docs/framework/$framework/{$}.md'
+ path: '/{$}.md'
+ fullPath: '/$project/$version/docs/framework/$framework/{$}.md'
+ preLoaderRoute: typeof ProjectVersionDocsFrameworkFrameworkChar123Char125DotmdRouteImport
+ parentRoute: typeof ProjectVersionDocsFrameworkFrameworkRoute
+ }
'/$project/$version/docs/framework/$framework/$': {
id: '/$project/$version/docs/framework/$framework/$'
path: '/$'
@@ -256,17 +242,6 @@ declare module '@tanstack/react-router' {
}
}
}
-declare module '@tanstack/react-start/server' {
- interface ServerFileRoutesByPath {
- '/$project/$version/docs/framework/$framework/{$}.md': {
- id: '/$project/$version/docs/framework/$framework/{$}.md'
- path: '/$project/$version/docs/framework/$framework/{$}.md'
- fullPath: '/$project/$version/docs/framework/$framework/{$}.md'
- preLoaderRoute: typeof ProjectVersionDocsFrameworkFrameworkChar123Char125DotmdServerRouteImport
- parentRoute: typeof rootServerRouteImport
- }
- }
-}
interface LibraryProjectRouteChildren {
LibraryProjectVersionIndexRoute: typeof LibraryProjectVersionIndexRoute
@@ -295,6 +270,7 @@ const LibraryRouteWithChildren =
interface ProjectVersionDocsFrameworkFrameworkRouteChildren {
ProjectVersionDocsFrameworkFrameworkSplatRoute: typeof ProjectVersionDocsFrameworkFrameworkSplatRoute
+ ProjectVersionDocsFrameworkFrameworkChar123Char125DotmdRoute: typeof ProjectVersionDocsFrameworkFrameworkChar123Char125DotmdRoute
ProjectVersionDocsFrameworkFrameworkIndexRoute: typeof ProjectVersionDocsFrameworkFrameworkIndexRoute
ProjectVersionDocsFrameworkFrameworkExamplesSplatRoute: typeof ProjectVersionDocsFrameworkFrameworkExamplesSplatRoute
}
@@ -303,6 +279,8 @@ const ProjectVersionDocsFrameworkFrameworkRouteChildren: ProjectVersionDocsFrame
{
ProjectVersionDocsFrameworkFrameworkSplatRoute:
ProjectVersionDocsFrameworkFrameworkSplatRoute,
+ ProjectVersionDocsFrameworkFrameworkChar123Char125DotmdRoute:
+ ProjectVersionDocsFrameworkFrameworkChar123Char125DotmdRoute,
ProjectVersionDocsFrameworkFrameworkIndexRoute:
ProjectVersionDocsFrameworkFrameworkIndexRoute,
ProjectVersionDocsFrameworkFrameworkExamplesSplatRoute:
@@ -324,10 +302,3 @@ const rootRouteChildren: RootRouteChildren = {
export const routeTree = rootRouteImport
._addFileChildren(rootRouteChildren)
._addFileTypes()
-const rootServerRouteChildren: RootServerRouteChildren = {
- ProjectVersionDocsFrameworkFrameworkChar123Char125DotmdServerRoute:
- ProjectVersionDocsFrameworkFrameworkChar123Char125DotmdServerRoute,
-}
-export const serverRouteTree = rootServerRouteImport
- ._addFileChildren(rootServerRouteChildren)
- ._addFileTypes()
diff --git a/e2e/react-start/website/src/routes/$project.$version.docs.framework.$framework.{$}[.]md.tsx b/e2e/react-start/website/src/routes/$project.$version.docs.framework.$framework.{$}[.]md.tsx
index d1deb64810..f9cdba1c17 100644
--- a/e2e/react-start/website/src/routes/$project.$version.docs.framework.$framework.{$}[.]md.tsx
+++ b/e2e/react-start/website/src/routes/$project.$version.docs.framework.$framework.{$}[.]md.tsx
@@ -1,25 +1,26 @@
-import { createServerFileRoute } from '@tanstack/react-start/server'
+import { createFileRoute } from '@tanstack/react-router'
import { getDocument } from '~/server/document'
-export const ServerRoute = createServerFileRoute(
+export const Route = createFileRoute(
'/$project/$version/docs/framework/$framework/{$}.md',
-).methods({
- GET: async ({ params }) => {
- const splat = params['_splat'] || ''
- const docPath = splat.split('.md')[0]
-
- if (!docPath) {
- return new Response('Document not found', { status: 404 })
- }
-
- const doc = await getDocument({ data: docPath })
- const markdown = `# ${doc.title}\n\n${doc.content}`
-
- return new Response(markdown, {
- headers: {
- 'Content-Type': 'text/markdown',
- 'Content-Disposition': `inline; filename="${doc.title}.md"`,
+)({
+ server: {
+ handlers: {
+ GET: async ({ params }) => {
+ const splat = params['_splat'] || ''
+ const docPath = splat.split('.md')[0]
+ if (!docPath) {
+ return new Response('Document not found', { status: 404 })
+ }
+ const doc = await getDocument({ data: docPath })
+ const markdown = `# ${doc.title}\n\n${doc.content}`
+ return new Response(markdown, {
+ headers: {
+ 'Content-Type': 'text/markdown',
+ 'Content-Disposition': `inline; filename="${doc.title}.md"`,
+ },
+ })
},
- })
+ },
},
})
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-code-splitting/src/routeTree.gen.ts b/e2e/solid-router/basic-file-based-code-splitting/src/routeTree.gen.ts
index 0fedabf762..f52487e717 100644
--- a/e2e/solid-router/basic-file-based-code-splitting/src/routeTree.gen.ts
+++ b/e2e/solid-router/basic-file-based-code-splitting/src/routeTree.gen.ts
@@ -147,25 +147,11 @@ export interface RootRouteChildren {
declare module '@tanstack/solid-router' {
interface FileRoutesByPath {
- '/': {
- id: '/'
- path: '/'
- fullPath: '/'
- preLoaderRoute: typeof IndexRouteImport
- parentRoute: typeof rootRouteImport
- }
- '/_layout': {
- id: '/_layout'
- path: ''
- fullPath: ''
- preLoaderRoute: typeof LayoutRouteImport
- parentRoute: typeof rootRouteImport
- }
- '/posts': {
- id: '/posts'
- path: '/posts'
- fullPath: '/posts'
- preLoaderRoute: typeof PostsRouteImport
+ '/without-loader': {
+ id: '/without-loader'
+ path: '/without-loader'
+ fullPath: '/without-loader'
+ preLoaderRoute: typeof WithoutLoaderRouteImport
parentRoute: typeof rootRouteImport
}
'/viewport-test': {
@@ -175,26 +161,26 @@ declare module '@tanstack/solid-router' {
preLoaderRoute: typeof ViewportTestRouteImport
parentRoute: typeof rootRouteImport
}
- '/without-loader': {
- id: '/without-loader'
- path: '/without-loader'
- fullPath: '/without-loader'
- preLoaderRoute: typeof WithoutLoaderRouteImport
+ '/posts': {
+ id: '/posts'
+ path: '/posts'
+ fullPath: '/posts'
+ preLoaderRoute: typeof PostsRouteImport
parentRoute: typeof rootRouteImport
}
- '/_layout/_layout-2': {
- id: '/_layout/_layout-2'
+ '/_layout': {
+ id: '/_layout'
path: ''
fullPath: ''
- preLoaderRoute: typeof LayoutLayout2RouteImport
- parentRoute: typeof LayoutRoute
+ preLoaderRoute: typeof LayoutRouteImport
+ parentRoute: typeof rootRouteImport
}
- '/posts/$postId': {
- id: '/posts/$postId'
- path: '/$postId'
- fullPath: '/posts/$postId'
- preLoaderRoute: typeof PostsPostIdRouteImport
- parentRoute: typeof PostsRoute
+ '/': {
+ id: '/'
+ path: '/'
+ fullPath: '/'
+ preLoaderRoute: typeof IndexRouteImport
+ parentRoute: typeof rootRouteImport
}
'/posts/': {
id: '/posts/'
@@ -203,12 +189,19 @@ declare module '@tanstack/solid-router' {
preLoaderRoute: typeof PostsIndexRouteImport
parentRoute: typeof PostsRoute
}
- '/_layout/_layout-2/layout-a': {
- id: '/_layout/_layout-2/layout-a'
- path: '/layout-a'
- fullPath: '/layout-a'
- preLoaderRoute: typeof LayoutLayout2LayoutARouteImport
- parentRoute: typeof LayoutLayout2Route
+ '/posts/$postId': {
+ id: '/posts/$postId'
+ path: '/$postId'
+ fullPath: '/posts/$postId'
+ preLoaderRoute: typeof PostsPostIdRouteImport
+ parentRoute: typeof PostsRoute
+ }
+ '/_layout/_layout-2': {
+ id: '/_layout/_layout-2'
+ path: ''
+ fullPath: ''
+ preLoaderRoute: typeof LayoutLayout2RouteImport
+ parentRoute: typeof LayoutRoute
}
'/_layout/_layout-2/layout-b': {
id: '/_layout/_layout-2/layout-b'
@@ -217,6 +210,13 @@ declare module '@tanstack/solid-router' {
preLoaderRoute: typeof LayoutLayout2LayoutBRouteImport
parentRoute: typeof LayoutLayout2Route
}
+ '/_layout/_layout-2/layout-a': {
+ id: '/_layout/_layout-2/layout-a'
+ path: '/layout-a'
+ fullPath: '/layout-a'
+ preLoaderRoute: typeof LayoutLayout2LayoutARouteImport
+ parentRoute: typeof LayoutLayout2Route
+ }
}
}
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-file-based/src/routeTree.gen.ts b/e2e/solid-router/basic-file-based/src/routeTree.gen.ts
index 08d8fb4978..b81fbe69d5 100644
--- a/e2e/solid-router/basic-file-based/src/routeTree.gen.ts
+++ b/e2e/solid-router/basic-file-based/src/routeTree.gen.ts
@@ -22,6 +22,7 @@ import { Route as LayoutRouteImport } from './routes/_layout'
import { Route as SearchParamsRouteRouteImport } from './routes/search-params/route'
import { Route as IndexRouteImport } from './routes/index'
import { Route as SearchParamsIndexRouteImport } from './routes/search-params/index'
+import { Route as RelativeIndexRouteImport } from './routes/relative/index'
import { Route as RedirectIndexRouteImport } from './routes/redirect/index'
import { Route as PostsIndexRouteImport } from './routes/posts.index'
import { Route as SearchParamsDefaultRouteImport } from './routes/search-params/default'
@@ -32,7 +33,13 @@ import { Route as groupLazyinsideRouteImport } from './routes/(group)/lazyinside
import { Route as groupInsideRouteImport } from './routes/(group)/inside'
import { Route as groupLayoutRouteImport } from './routes/(group)/_layout'
import { Route as anotherGroupOnlyrouteinsideRouteImport } from './routes/(another-group)/onlyrouteinside'
+import { Route as RelativeUseNavigateRouteRouteImport } from './routes/relative/useNavigate/route'
+import { Route as RelativeLinkRouteRouteImport } from './routes/relative/link/route'
import { Route as RedirectTargetIndexRouteImport } from './routes/redirect/$target/index'
+import { Route as RelativeUseNavigateRelativeUseNavigateBRouteImport } from './routes/relative/useNavigate/relative-useNavigate-b'
+import { Route as RelativeUseNavigateRelativeUseNavigateARouteImport } from './routes/relative/useNavigate/relative-useNavigate-a'
+import { Route as RelativeLinkRelativeLinkBRouteImport } from './routes/relative/link/relative-link-b'
+import { Route as RelativeLinkRelativeLinkARouteImport } from './routes/relative/link/relative-link-a'
import { Route as RedirectPreloadThirdRouteImport } from './routes/redirect/preload/third'
import { Route as RedirectPreloadSecondRouteImport } from './routes/redirect/preload/second'
import { Route as RedirectPreloadFirstRouteImport } from './routes/redirect/preload/first'
@@ -44,6 +51,16 @@ import { Route as LayoutLayout2LayoutBRouteImport } from './routes/_layout/_layo
import { Route as LayoutLayout2LayoutARouteImport } from './routes/_layout/_layout-2/layout-a'
import { Route as groupSubfolderInsideRouteImport } from './routes/(group)/subfolder/inside'
import { Route as groupLayoutInsidelayoutRouteImport } from './routes/(group)/_layout.insidelayout'
+import { Route as RelativeUseNavigateWithSearchIndexRouteImport } from './routes/relative/useNavigate/with-search/index'
+import { Route as RelativeUseNavigatePathIndexRouteImport } from './routes/relative/useNavigate/path/index'
+import { Route as RelativeUseNavigateNestedIndexRouteImport } from './routes/relative/useNavigate/nested/index'
+import { Route as RelativeLinkWithSearchIndexRouteImport } from './routes/relative/link/with-search/index'
+import { Route as RelativeLinkPathIndexRouteImport } from './routes/relative/link/path/index'
+import { Route as RelativeLinkNestedIndexRouteImport } from './routes/relative/link/nested/index'
+import { Route as RelativeUseNavigatePathPathIndexRouteImport } from './routes/relative/useNavigate/path/$path/index'
+import { Route as RelativeUseNavigateNestedDeepIndexRouteImport } from './routes/relative/useNavigate/nested/deep/index'
+import { Route as RelativeLinkPathPathIndexRouteImport } from './routes/relative/link/path/$path/index'
+import { Route as RelativeLinkNestedDeepIndexRouteImport } from './routes/relative/link/nested/deep/index'
const groupRouteImport = createFileRoute('/(group)')()
@@ -105,6 +122,11 @@ const SearchParamsIndexRoute = SearchParamsIndexRouteImport.update({
path: '/',
getParentRoute: () => SearchParamsRouteRoute,
} as any)
+const RelativeIndexRoute = RelativeIndexRouteImport.update({
+ id: '/relative/',
+ path: '/relative/',
+ getParentRoute: () => rootRouteImport,
+} as any)
const RedirectIndexRoute = RedirectIndexRouteImport.update({
id: '/redirect/',
path: '/redirect/',
@@ -156,11 +178,46 @@ const anotherGroupOnlyrouteinsideRoute =
path: '/onlyrouteinside',
getParentRoute: () => rootRouteImport,
} as any)
+const RelativeUseNavigateRouteRoute =
+ RelativeUseNavigateRouteRouteImport.update({
+ id: '/relative/useNavigate',
+ path: '/relative/useNavigate',
+ getParentRoute: () => rootRouteImport,
+ } as any)
+const RelativeLinkRouteRoute = RelativeLinkRouteRouteImport.update({
+ id: '/relative/link',
+ path: '/relative/link',
+ getParentRoute: () => rootRouteImport,
+} as any)
const RedirectTargetIndexRoute = RedirectTargetIndexRouteImport.update({
id: '/',
path: '/',
getParentRoute: () => RedirectTargetRoute,
} as any)
+const RelativeUseNavigateRelativeUseNavigateBRoute =
+ RelativeUseNavigateRelativeUseNavigateBRouteImport.update({
+ id: '/relative-useNavigate-b',
+ path: '/relative-useNavigate-b',
+ getParentRoute: () => RelativeUseNavigateRouteRoute,
+ } as any)
+const RelativeUseNavigateRelativeUseNavigateARoute =
+ RelativeUseNavigateRelativeUseNavigateARouteImport.update({
+ id: '/relative-useNavigate-a',
+ path: '/relative-useNavigate-a',
+ getParentRoute: () => RelativeUseNavigateRouteRoute,
+ } as any)
+const RelativeLinkRelativeLinkBRoute =
+ RelativeLinkRelativeLinkBRouteImport.update({
+ id: '/relative-link-b',
+ path: '/relative-link-b',
+ getParentRoute: () => RelativeLinkRouteRoute,
+ } as any)
+const RelativeLinkRelativeLinkARoute =
+ RelativeLinkRelativeLinkARouteImport.update({
+ id: '/relative-link-a',
+ path: '/relative-link-a',
+ getParentRoute: () => RelativeLinkRouteRoute,
+ } as any)
const RedirectPreloadThirdRoute = RedirectPreloadThirdRouteImport.update({
id: '/redirect/preload/third',
path: '/redirect/preload/third',
@@ -217,6 +274,64 @@ const groupLayoutInsidelayoutRoute = groupLayoutInsidelayoutRouteImport.update({
path: '/insidelayout',
getParentRoute: () => groupLayoutRoute,
} as any)
+const RelativeUseNavigateWithSearchIndexRoute =
+ RelativeUseNavigateWithSearchIndexRouteImport.update({
+ id: '/with-search/',
+ path: '/with-search/',
+ getParentRoute: () => RelativeUseNavigateRouteRoute,
+ } as any)
+const RelativeUseNavigatePathIndexRoute =
+ RelativeUseNavigatePathIndexRouteImport.update({
+ id: '/path/',
+ path: '/path/',
+ getParentRoute: () => RelativeUseNavigateRouteRoute,
+ } as any)
+const RelativeUseNavigateNestedIndexRoute =
+ RelativeUseNavigateNestedIndexRouteImport.update({
+ id: '/nested/',
+ path: '/nested/',
+ getParentRoute: () => RelativeUseNavigateRouteRoute,
+ } as any)
+const RelativeLinkWithSearchIndexRoute =
+ RelativeLinkWithSearchIndexRouteImport.update({
+ id: '/with-search/',
+ path: '/with-search/',
+ getParentRoute: () => RelativeLinkRouteRoute,
+ } as any)
+const RelativeLinkPathIndexRoute = RelativeLinkPathIndexRouteImport.update({
+ id: '/path/',
+ path: '/path/',
+ getParentRoute: () => RelativeLinkRouteRoute,
+} as any)
+const RelativeLinkNestedIndexRoute = RelativeLinkNestedIndexRouteImport.update({
+ id: '/nested/',
+ path: '/nested/',
+ getParentRoute: () => RelativeLinkRouteRoute,
+} as any)
+const RelativeUseNavigatePathPathIndexRoute =
+ RelativeUseNavigatePathPathIndexRouteImport.update({
+ id: '/path/$path/',
+ path: '/path/$path/',
+ getParentRoute: () => RelativeUseNavigateRouteRoute,
+ } as any)
+const RelativeUseNavigateNestedDeepIndexRoute =
+ RelativeUseNavigateNestedDeepIndexRouteImport.update({
+ id: '/nested/deep/',
+ path: '/nested/deep/',
+ getParentRoute: () => RelativeUseNavigateRouteRoute,
+ } as any)
+const RelativeLinkPathPathIndexRoute =
+ RelativeLinkPathPathIndexRouteImport.update({
+ id: '/path/$path/',
+ path: '/path/$path/',
+ getParentRoute: () => RelativeLinkRouteRoute,
+ } as any)
+const RelativeLinkNestedDeepIndexRoute =
+ RelativeLinkNestedDeepIndexRouteImport.update({
+ id: '/nested/deep/',
+ path: '/nested/deep/',
+ getParentRoute: () => RelativeLinkRouteRoute,
+ } as any)
export interface FileRoutesByFullPath {
'/': typeof groupLayoutRouteWithChildren
@@ -228,6 +343,8 @@ export interface FileRoutesByFullPath {
'/notRemountDeps': typeof NotRemountDepsRoute
'/posts': typeof PostsRouteWithChildren
'/remountDeps': typeof RemountDepsRoute
+ '/relative/link': typeof RelativeLinkRouteRouteWithChildren
+ '/relative/useNavigate': typeof RelativeUseNavigateRouteRouteWithChildren
'/onlyrouteinside': typeof anotherGroupOnlyrouteinsideRoute
'/inside': typeof groupInsideRoute
'/lazyinside': typeof groupLazyinsideRoute
@@ -236,6 +353,7 @@ export interface FileRoutesByFullPath {
'/search-params/default': typeof SearchParamsDefaultRoute
'/posts/': typeof PostsIndexRoute
'/redirect': typeof RedirectIndexRoute
+ '/relative': typeof RelativeIndexRoute
'/search-params/': typeof SearchParamsIndexRoute
'/insidelayout': typeof groupLayoutInsidelayoutRoute
'/subfolder/inside': typeof groupSubfolderInsideRoute
@@ -248,7 +366,21 @@ export interface FileRoutesByFullPath {
'/redirect/preload/first': typeof RedirectPreloadFirstRoute
'/redirect/preload/second': typeof RedirectPreloadSecondRoute
'/redirect/preload/third': typeof RedirectPreloadThirdRoute
+ '/relative/link/relative-link-a': typeof RelativeLinkRelativeLinkARoute
+ '/relative/link/relative-link-b': typeof RelativeLinkRelativeLinkBRoute
+ '/relative/useNavigate/relative-useNavigate-a': typeof RelativeUseNavigateRelativeUseNavigateARoute
+ '/relative/useNavigate/relative-useNavigate-b': typeof RelativeUseNavigateRelativeUseNavigateBRoute
'/redirect/$target/': typeof RedirectTargetIndexRoute
+ '/relative/link/nested': typeof RelativeLinkNestedIndexRoute
+ '/relative/link/path': typeof RelativeLinkPathIndexRoute
+ '/relative/link/with-search': typeof RelativeLinkWithSearchIndexRoute
+ '/relative/useNavigate/nested': typeof RelativeUseNavigateNestedIndexRoute
+ '/relative/useNavigate/path': typeof RelativeUseNavigatePathIndexRoute
+ '/relative/useNavigate/with-search': typeof RelativeUseNavigateWithSearchIndexRoute
+ '/relative/link/nested/deep': typeof RelativeLinkNestedDeepIndexRoute
+ '/relative/link/path/$path': typeof RelativeLinkPathPathIndexRoute
+ '/relative/useNavigate/nested/deep': typeof RelativeUseNavigateNestedDeepIndexRoute
+ '/relative/useNavigate/path/$path': typeof RelativeUseNavigatePathPathIndexRoute
}
export interface FileRoutesByTo {
'/': typeof groupLayoutRouteWithChildren
@@ -258,6 +390,8 @@ export interface FileRoutesByTo {
'/editing-b': typeof EditingBRoute
'/notRemountDeps': typeof NotRemountDepsRoute
'/remountDeps': typeof RemountDepsRoute
+ '/relative/link': typeof RelativeLinkRouteRouteWithChildren
+ '/relative/useNavigate': typeof RelativeUseNavigateRouteRouteWithChildren
'/onlyrouteinside': typeof anotherGroupOnlyrouteinsideRoute
'/inside': typeof groupInsideRoute
'/lazyinside': typeof groupLazyinsideRoute
@@ -265,6 +399,7 @@ export interface FileRoutesByTo {
'/search-params/default': typeof SearchParamsDefaultRoute
'/posts': typeof PostsIndexRoute
'/redirect': typeof RedirectIndexRoute
+ '/relative': typeof RelativeIndexRoute
'/search-params': typeof SearchParamsIndexRoute
'/insidelayout': typeof groupLayoutInsidelayoutRoute
'/subfolder/inside': typeof groupSubfolderInsideRoute
@@ -277,7 +412,21 @@ export interface FileRoutesByTo {
'/redirect/preload/first': typeof RedirectPreloadFirstRoute
'/redirect/preload/second': typeof RedirectPreloadSecondRoute
'/redirect/preload/third': typeof RedirectPreloadThirdRoute
+ '/relative/link/relative-link-a': typeof RelativeLinkRelativeLinkARoute
+ '/relative/link/relative-link-b': typeof RelativeLinkRelativeLinkBRoute
+ '/relative/useNavigate/relative-useNavigate-a': typeof RelativeUseNavigateRelativeUseNavigateARoute
+ '/relative/useNavigate/relative-useNavigate-b': typeof RelativeUseNavigateRelativeUseNavigateBRoute
'/redirect/$target': typeof RedirectTargetIndexRoute
+ '/relative/link/nested': typeof RelativeLinkNestedIndexRoute
+ '/relative/link/path': typeof RelativeLinkPathIndexRoute
+ '/relative/link/with-search': typeof RelativeLinkWithSearchIndexRoute
+ '/relative/useNavigate/nested': typeof RelativeUseNavigateNestedIndexRoute
+ '/relative/useNavigate/path': typeof RelativeUseNavigatePathIndexRoute
+ '/relative/useNavigate/with-search': typeof RelativeUseNavigateWithSearchIndexRoute
+ '/relative/link/nested/deep': typeof RelativeLinkNestedDeepIndexRoute
+ '/relative/link/path/$path': typeof RelativeLinkPathPathIndexRoute
+ '/relative/useNavigate/nested/deep': typeof RelativeUseNavigateNestedDeepIndexRoute
+ '/relative/useNavigate/path/$path': typeof RelativeUseNavigatePathPathIndexRoute
}
export interface FileRoutesById {
__root__: typeof rootRouteImport
@@ -291,6 +440,8 @@ export interface FileRoutesById {
'/notRemountDeps': typeof NotRemountDepsRoute
'/posts': typeof PostsRouteWithChildren
'/remountDeps': typeof RemountDepsRoute
+ '/relative/link': typeof RelativeLinkRouteRouteWithChildren
+ '/relative/useNavigate': typeof RelativeUseNavigateRouteRouteWithChildren
'/(another-group)/onlyrouteinside': typeof anotherGroupOnlyrouteinsideRoute
'/(group)': typeof groupRouteWithChildren
'/(group)/_layout': typeof groupLayoutRouteWithChildren
@@ -302,6 +453,7 @@ export interface FileRoutesById {
'/search-params/default': typeof SearchParamsDefaultRoute
'/posts/': typeof PostsIndexRoute
'/redirect/': typeof RedirectIndexRoute
+ '/relative/': typeof RelativeIndexRoute
'/search-params/': typeof SearchParamsIndexRoute
'/(group)/_layout/insidelayout': typeof groupLayoutInsidelayoutRoute
'/(group)/subfolder/inside': typeof groupSubfolderInsideRoute
@@ -314,7 +466,21 @@ export interface FileRoutesById {
'/redirect/preload/first': typeof RedirectPreloadFirstRoute
'/redirect/preload/second': typeof RedirectPreloadSecondRoute
'/redirect/preload/third': typeof RedirectPreloadThirdRoute
+ '/relative/link/relative-link-a': typeof RelativeLinkRelativeLinkARoute
+ '/relative/link/relative-link-b': typeof RelativeLinkRelativeLinkBRoute
+ '/relative/useNavigate/relative-useNavigate-a': typeof RelativeUseNavigateRelativeUseNavigateARoute
+ '/relative/useNavigate/relative-useNavigate-b': typeof RelativeUseNavigateRelativeUseNavigateBRoute
'/redirect/$target/': typeof RedirectTargetIndexRoute
+ '/relative/link/nested/': typeof RelativeLinkNestedIndexRoute
+ '/relative/link/path/': typeof RelativeLinkPathIndexRoute
+ '/relative/link/with-search/': typeof RelativeLinkWithSearchIndexRoute
+ '/relative/useNavigate/nested/': typeof RelativeUseNavigateNestedIndexRoute
+ '/relative/useNavigate/path/': typeof RelativeUseNavigatePathIndexRoute
+ '/relative/useNavigate/with-search/': typeof RelativeUseNavigateWithSearchIndexRoute
+ '/relative/link/nested/deep/': typeof RelativeLinkNestedDeepIndexRoute
+ '/relative/link/path/$path/': typeof RelativeLinkPathPathIndexRoute
+ '/relative/useNavigate/nested/deep/': typeof RelativeUseNavigateNestedDeepIndexRoute
+ '/relative/useNavigate/path/$path/': typeof RelativeUseNavigatePathPathIndexRoute
}
export interface FileRouteTypes {
fileRoutesByFullPath: FileRoutesByFullPath
@@ -328,6 +494,8 @@ export interface FileRouteTypes {
| '/notRemountDeps'
| '/posts'
| '/remountDeps'
+ | '/relative/link'
+ | '/relative/useNavigate'
| '/onlyrouteinside'
| '/inside'
| '/lazyinside'
@@ -336,6 +504,7 @@ export interface FileRouteTypes {
| '/search-params/default'
| '/posts/'
| '/redirect'
+ | '/relative'
| '/search-params/'
| '/insidelayout'
| '/subfolder/inside'
@@ -348,7 +517,21 @@ export interface FileRouteTypes {
| '/redirect/preload/first'
| '/redirect/preload/second'
| '/redirect/preload/third'
+ | '/relative/link/relative-link-a'
+ | '/relative/link/relative-link-b'
+ | '/relative/useNavigate/relative-useNavigate-a'
+ | '/relative/useNavigate/relative-useNavigate-b'
| '/redirect/$target/'
+ | '/relative/link/nested'
+ | '/relative/link/path'
+ | '/relative/link/with-search'
+ | '/relative/useNavigate/nested'
+ | '/relative/useNavigate/path'
+ | '/relative/useNavigate/with-search'
+ | '/relative/link/nested/deep'
+ | '/relative/link/path/$path'
+ | '/relative/useNavigate/nested/deep'
+ | '/relative/useNavigate/path/$path'
fileRoutesByTo: FileRoutesByTo
to:
| '/'
@@ -358,6 +541,8 @@ export interface FileRouteTypes {
| '/editing-b'
| '/notRemountDeps'
| '/remountDeps'
+ | '/relative/link'
+ | '/relative/useNavigate'
| '/onlyrouteinside'
| '/inside'
| '/lazyinside'
@@ -365,6 +550,7 @@ export interface FileRouteTypes {
| '/search-params/default'
| '/posts'
| '/redirect'
+ | '/relative'
| '/search-params'
| '/insidelayout'
| '/subfolder/inside'
@@ -377,7 +563,21 @@ export interface FileRouteTypes {
| '/redirect/preload/first'
| '/redirect/preload/second'
| '/redirect/preload/third'
+ | '/relative/link/relative-link-a'
+ | '/relative/link/relative-link-b'
+ | '/relative/useNavigate/relative-useNavigate-a'
+ | '/relative/useNavigate/relative-useNavigate-b'
| '/redirect/$target'
+ | '/relative/link/nested'
+ | '/relative/link/path'
+ | '/relative/link/with-search'
+ | '/relative/useNavigate/nested'
+ | '/relative/useNavigate/path'
+ | '/relative/useNavigate/with-search'
+ | '/relative/link/nested/deep'
+ | '/relative/link/path/$path'
+ | '/relative/useNavigate/nested/deep'
+ | '/relative/useNavigate/path/$path'
id:
| '__root__'
| '/'
@@ -390,6 +590,8 @@ export interface FileRouteTypes {
| '/notRemountDeps'
| '/posts'
| '/remountDeps'
+ | '/relative/link'
+ | '/relative/useNavigate'
| '/(another-group)/onlyrouteinside'
| '/(group)'
| '/(group)/_layout'
@@ -401,6 +603,7 @@ export interface FileRouteTypes {
| '/search-params/default'
| '/posts/'
| '/redirect/'
+ | '/relative/'
| '/search-params/'
| '/(group)/_layout/insidelayout'
| '/(group)/subfolder/inside'
@@ -413,7 +616,21 @@ export interface FileRouteTypes {
| '/redirect/preload/first'
| '/redirect/preload/second'
| '/redirect/preload/third'
+ | '/relative/link/relative-link-a'
+ | '/relative/link/relative-link-b'
+ | '/relative/useNavigate/relative-useNavigate-a'
+ | '/relative/useNavigate/relative-useNavigate-b'
| '/redirect/$target/'
+ | '/relative/link/nested/'
+ | '/relative/link/path/'
+ | '/relative/link/with-search/'
+ | '/relative/useNavigate/nested/'
+ | '/relative/useNavigate/path/'
+ | '/relative/useNavigate/with-search/'
+ | '/relative/link/nested/deep/'
+ | '/relative/link/path/$path/'
+ | '/relative/useNavigate/nested/deep/'
+ | '/relative/useNavigate/path/$path/'
fileRoutesById: FileRoutesById
}
export interface RootRouteChildren {
@@ -427,10 +644,13 @@ export interface RootRouteChildren {
NotRemountDepsRoute: typeof NotRemountDepsRoute
PostsRoute: typeof PostsRouteWithChildren
RemountDepsRoute: typeof RemountDepsRoute
+ RelativeLinkRouteRoute: typeof RelativeLinkRouteRouteWithChildren
+ RelativeUseNavigateRouteRoute: typeof RelativeUseNavigateRouteRouteWithChildren
anotherGroupOnlyrouteinsideRoute: typeof anotherGroupOnlyrouteinsideRoute
groupRoute: typeof groupRouteWithChildren
RedirectTargetRoute: typeof RedirectTargetRouteWithChildren
RedirectIndexRoute: typeof RedirectIndexRoute
+ RelativeIndexRoute: typeof RelativeIndexRoute
ParamsSingleValueRoute: typeof ParamsSingleValueRoute
PostsPostIdEditRoute: typeof PostsPostIdEditRoute
RedirectPreloadFirstRoute: typeof RedirectPreloadFirstRoute
@@ -524,6 +744,13 @@ declare module '@tanstack/solid-router' {
preLoaderRoute: typeof SearchParamsIndexRouteImport
parentRoute: typeof SearchParamsRouteRoute
}
+ '/relative/': {
+ id: '/relative/'
+ path: '/relative'
+ fullPath: '/relative'
+ preLoaderRoute: typeof RelativeIndexRouteImport
+ parentRoute: typeof rootRouteImport
+ }
'/redirect/': {
id: '/redirect/'
path: '/redirect'
@@ -594,6 +821,20 @@ declare module '@tanstack/solid-router' {
preLoaderRoute: typeof anotherGroupOnlyrouteinsideRouteImport
parentRoute: typeof rootRouteImport
}
+ '/relative/useNavigate': {
+ id: '/relative/useNavigate'
+ path: '/relative/useNavigate'
+ fullPath: '/relative/useNavigate'
+ preLoaderRoute: typeof RelativeUseNavigateRouteRouteImport
+ parentRoute: typeof rootRouteImport
+ }
+ '/relative/link': {
+ id: '/relative/link'
+ path: '/relative/link'
+ fullPath: '/relative/link'
+ preLoaderRoute: typeof RelativeLinkRouteRouteImport
+ parentRoute: typeof rootRouteImport
+ }
'/redirect/$target/': {
id: '/redirect/$target/'
path: '/'
@@ -601,6 +842,34 @@ declare module '@tanstack/solid-router' {
preLoaderRoute: typeof RedirectTargetIndexRouteImport
parentRoute: typeof RedirectTargetRoute
}
+ '/relative/useNavigate/relative-useNavigate-b': {
+ id: '/relative/useNavigate/relative-useNavigate-b'
+ path: '/relative-useNavigate-b'
+ fullPath: '/relative/useNavigate/relative-useNavigate-b'
+ preLoaderRoute: typeof RelativeUseNavigateRelativeUseNavigateBRouteImport
+ parentRoute: typeof RelativeUseNavigateRouteRoute
+ }
+ '/relative/useNavigate/relative-useNavigate-a': {
+ id: '/relative/useNavigate/relative-useNavigate-a'
+ path: '/relative-useNavigate-a'
+ fullPath: '/relative/useNavigate/relative-useNavigate-a'
+ preLoaderRoute: typeof RelativeUseNavigateRelativeUseNavigateARouteImport
+ parentRoute: typeof RelativeUseNavigateRouteRoute
+ }
+ '/relative/link/relative-link-b': {
+ id: '/relative/link/relative-link-b'
+ path: '/relative-link-b'
+ fullPath: '/relative/link/relative-link-b'
+ preLoaderRoute: typeof RelativeLinkRelativeLinkBRouteImport
+ parentRoute: typeof RelativeLinkRouteRoute
+ }
+ '/relative/link/relative-link-a': {
+ id: '/relative/link/relative-link-a'
+ path: '/relative-link-a'
+ fullPath: '/relative/link/relative-link-a'
+ preLoaderRoute: typeof RelativeLinkRelativeLinkARouteImport
+ parentRoute: typeof RelativeLinkRouteRoute
+ }
'/redirect/preload/third': {
id: '/redirect/preload/third'
path: '/redirect/preload/third'
@@ -678,6 +947,76 @@ declare module '@tanstack/solid-router' {
preLoaderRoute: typeof groupLayoutInsidelayoutRouteImport
parentRoute: typeof groupLayoutRoute
}
+ '/relative/useNavigate/with-search/': {
+ id: '/relative/useNavigate/with-search/'
+ path: '/with-search'
+ fullPath: '/relative/useNavigate/with-search'
+ preLoaderRoute: typeof RelativeUseNavigateWithSearchIndexRouteImport
+ parentRoute: typeof RelativeUseNavigateRouteRoute
+ }
+ '/relative/useNavigate/path/': {
+ id: '/relative/useNavigate/path/'
+ path: '/path'
+ fullPath: '/relative/useNavigate/path'
+ preLoaderRoute: typeof RelativeUseNavigatePathIndexRouteImport
+ parentRoute: typeof RelativeUseNavigateRouteRoute
+ }
+ '/relative/useNavigate/nested/': {
+ id: '/relative/useNavigate/nested/'
+ path: '/nested'
+ fullPath: '/relative/useNavigate/nested'
+ preLoaderRoute: typeof RelativeUseNavigateNestedIndexRouteImport
+ parentRoute: typeof RelativeUseNavigateRouteRoute
+ }
+ '/relative/link/with-search/': {
+ id: '/relative/link/with-search/'
+ path: '/with-search'
+ fullPath: '/relative/link/with-search'
+ preLoaderRoute: typeof RelativeLinkWithSearchIndexRouteImport
+ parentRoute: typeof RelativeLinkRouteRoute
+ }
+ '/relative/link/path/': {
+ id: '/relative/link/path/'
+ path: '/path'
+ fullPath: '/relative/link/path'
+ preLoaderRoute: typeof RelativeLinkPathIndexRouteImport
+ parentRoute: typeof RelativeLinkRouteRoute
+ }
+ '/relative/link/nested/': {
+ id: '/relative/link/nested/'
+ path: '/nested'
+ fullPath: '/relative/link/nested'
+ preLoaderRoute: typeof RelativeLinkNestedIndexRouteImport
+ parentRoute: typeof RelativeLinkRouteRoute
+ }
+ '/relative/useNavigate/path/$path/': {
+ id: '/relative/useNavigate/path/$path/'
+ path: '/path/$path'
+ fullPath: '/relative/useNavigate/path/$path'
+ preLoaderRoute: typeof RelativeUseNavigatePathPathIndexRouteImport
+ parentRoute: typeof RelativeUseNavigateRouteRoute
+ }
+ '/relative/useNavigate/nested/deep/': {
+ id: '/relative/useNavigate/nested/deep/'
+ path: '/nested/deep'
+ fullPath: '/relative/useNavigate/nested/deep'
+ preLoaderRoute: typeof RelativeUseNavigateNestedDeepIndexRouteImport
+ parentRoute: typeof RelativeUseNavigateRouteRoute
+ }
+ '/relative/link/path/$path/': {
+ id: '/relative/link/path/$path/'
+ path: '/path/$path'
+ fullPath: '/relative/link/path/$path'
+ preLoaderRoute: typeof RelativeLinkPathPathIndexRouteImport
+ parentRoute: typeof RelativeLinkRouteRoute
+ }
+ '/relative/link/nested/deep/': {
+ id: '/relative/link/nested/deep/'
+ path: '/nested/deep'
+ fullPath: '/relative/link/nested/deep'
+ preLoaderRoute: typeof RelativeLinkNestedDeepIndexRouteImport
+ parentRoute: typeof RelativeLinkRouteRoute
+ }
}
}
@@ -731,6 +1070,60 @@ const PostsRouteChildren: PostsRouteChildren = {
const PostsRouteWithChildren = PostsRoute._addFileChildren(PostsRouteChildren)
+interface RelativeLinkRouteRouteChildren {
+ RelativeLinkRelativeLinkARoute: typeof RelativeLinkRelativeLinkARoute
+ RelativeLinkRelativeLinkBRoute: typeof RelativeLinkRelativeLinkBRoute
+ RelativeLinkNestedIndexRoute: typeof RelativeLinkNestedIndexRoute
+ RelativeLinkPathIndexRoute: typeof RelativeLinkPathIndexRoute
+ RelativeLinkWithSearchIndexRoute: typeof RelativeLinkWithSearchIndexRoute
+ RelativeLinkNestedDeepIndexRoute: typeof RelativeLinkNestedDeepIndexRoute
+ RelativeLinkPathPathIndexRoute: typeof RelativeLinkPathPathIndexRoute
+}
+
+const RelativeLinkRouteRouteChildren: RelativeLinkRouteRouteChildren = {
+ RelativeLinkRelativeLinkARoute: RelativeLinkRelativeLinkARoute,
+ RelativeLinkRelativeLinkBRoute: RelativeLinkRelativeLinkBRoute,
+ RelativeLinkNestedIndexRoute: RelativeLinkNestedIndexRoute,
+ RelativeLinkPathIndexRoute: RelativeLinkPathIndexRoute,
+ RelativeLinkWithSearchIndexRoute: RelativeLinkWithSearchIndexRoute,
+ RelativeLinkNestedDeepIndexRoute: RelativeLinkNestedDeepIndexRoute,
+ RelativeLinkPathPathIndexRoute: RelativeLinkPathPathIndexRoute,
+}
+
+const RelativeLinkRouteRouteWithChildren =
+ RelativeLinkRouteRoute._addFileChildren(RelativeLinkRouteRouteChildren)
+
+interface RelativeUseNavigateRouteRouteChildren {
+ RelativeUseNavigateRelativeUseNavigateARoute: typeof RelativeUseNavigateRelativeUseNavigateARoute
+ RelativeUseNavigateRelativeUseNavigateBRoute: typeof RelativeUseNavigateRelativeUseNavigateBRoute
+ RelativeUseNavigateNestedIndexRoute: typeof RelativeUseNavigateNestedIndexRoute
+ RelativeUseNavigatePathIndexRoute: typeof RelativeUseNavigatePathIndexRoute
+ RelativeUseNavigateWithSearchIndexRoute: typeof RelativeUseNavigateWithSearchIndexRoute
+ RelativeUseNavigateNestedDeepIndexRoute: typeof RelativeUseNavigateNestedDeepIndexRoute
+ RelativeUseNavigatePathPathIndexRoute: typeof RelativeUseNavigatePathPathIndexRoute
+}
+
+const RelativeUseNavigateRouteRouteChildren: RelativeUseNavigateRouteRouteChildren =
+ {
+ RelativeUseNavigateRelativeUseNavigateARoute:
+ RelativeUseNavigateRelativeUseNavigateARoute,
+ RelativeUseNavigateRelativeUseNavigateBRoute:
+ RelativeUseNavigateRelativeUseNavigateBRoute,
+ RelativeUseNavigateNestedIndexRoute: RelativeUseNavigateNestedIndexRoute,
+ RelativeUseNavigatePathIndexRoute: RelativeUseNavigatePathIndexRoute,
+ RelativeUseNavigateWithSearchIndexRoute:
+ RelativeUseNavigateWithSearchIndexRoute,
+ RelativeUseNavigateNestedDeepIndexRoute:
+ RelativeUseNavigateNestedDeepIndexRoute,
+ RelativeUseNavigatePathPathIndexRoute:
+ RelativeUseNavigatePathPathIndexRoute,
+ }
+
+const RelativeUseNavigateRouteRouteWithChildren =
+ RelativeUseNavigateRouteRoute._addFileChildren(
+ RelativeUseNavigateRouteRouteChildren,
+ )
+
interface groupLayoutRouteChildren {
groupLayoutInsidelayoutRoute: typeof groupLayoutInsidelayoutRoute
}
@@ -786,10 +1179,13 @@ const rootRouteChildren: RootRouteChildren = {
NotRemountDepsRoute: NotRemountDepsRoute,
PostsRoute: PostsRouteWithChildren,
RemountDepsRoute: RemountDepsRoute,
+ RelativeLinkRouteRoute: RelativeLinkRouteRouteWithChildren,
+ RelativeUseNavigateRouteRoute: RelativeUseNavigateRouteRouteWithChildren,
anotherGroupOnlyrouteinsideRoute: anotherGroupOnlyrouteinsideRoute,
groupRoute: groupRouteWithChildren,
RedirectTargetRoute: RedirectTargetRouteWithChildren,
RedirectIndexRoute: RedirectIndexRoute,
+ RelativeIndexRoute: RelativeIndexRoute,
ParamsSingleValueRoute: ParamsSingleValueRoute,
PostsPostIdEditRoute: PostsPostIdEditRoute,
RedirectPreloadFirstRoute: RedirectPreloadFirstRoute,
diff --git a/e2e/solid-router/basic-file-based/src/routes/__root.tsx b/e2e/solid-router/basic-file-based/src/routes/__root.tsx
index c9ff803463..0997c45b37 100644
--- a/e2e/solid-router/basic-file-based/src/routes/__root.tsx
+++ b/e2e/solid-router/basic-file-based/src/routes/__root.tsx
@@ -122,6 +122,14 @@ function RootComponent() {
>
redirect
{' '}
+
+ relative routing
+ {' '}
+
+ Relative Routing Tests - Home
+
+
+ Using Links
+ Using useNavigate
+
+
+
+
+
+ )
+}
diff --git a/e2e/solid-router/basic-file-based/src/routes/relative/link/nested/deep/index.tsx b/e2e/solid-router/basic-file-based/src/routes/relative/link/nested/deep/index.tsx
new file mode 100644
index 0000000000..d92d2b5e7c
--- /dev/null
+++ b/e2e/solid-router/basic-file-based/src/routes/relative/link/nested/deep/index.tsx
@@ -0,0 +1,13 @@
+import { createFileRoute } from '@tanstack/solid-router'
+
+export const Route = createFileRoute('/relative/link/nested/deep/')({
+ component: RouteComponent,
+})
+
+function RouteComponent() {
+ return (
+
+ Hello "/relative/link/nested/deep/"!
+
+ )
+}
diff --git a/e2e/solid-router/basic-file-based/src/routes/relative/link/nested/index.tsx b/e2e/solid-router/basic-file-based/src/routes/relative/link/nested/index.tsx
new file mode 100644
index 0000000000..5ddaa68d75
--- /dev/null
+++ b/e2e/solid-router/basic-file-based/src/routes/relative/link/nested/index.tsx
@@ -0,0 +1,13 @@
+import { createFileRoute } from '@tanstack/solid-router'
+
+export const Route = createFileRoute('/relative/link/nested/')({
+ component: RouteComponent,
+})
+
+function RouteComponent() {
+ return (
+
+ Hello "/relative/link/nested/"!
+
+ )
+}
diff --git a/e2e/solid-router/basic-file-based/src/routes/relative/link/path/$path/index.tsx b/e2e/solid-router/basic-file-based/src/routes/relative/link/path/$path/index.tsx
new file mode 100644
index 0000000000..1cf079d4b8
--- /dev/null
+++ b/e2e/solid-router/basic-file-based/src/routes/relative/link/path/$path/index.tsx
@@ -0,0 +1,31 @@
+import { Link, createFileRoute } from '@tanstack/solid-router'
+
+export const Route = createFileRoute('/relative/link/path/$path/')({
+ component: RouteComponent,
+ loader: ({ params }) => {
+ return params
+ },
+})
+
+function RouteComponent() {
+ const params = Route.useParams()
+
+ return (
+
+
+ Hello from "/relative/links/path/{params().path}"!
+
+
+
+ To {params().path === 'a' ? 'b' : 'a'}
+
+
+
+ )
+}
diff --git a/e2e/solid-router/basic-file-based/src/routes/relative/link/path/index.tsx b/e2e/solid-router/basic-file-based/src/routes/relative/link/path/index.tsx
new file mode 100644
index 0000000000..36bf3f5cde
--- /dev/null
+++ b/e2e/solid-router/basic-file-based/src/routes/relative/link/path/index.tsx
@@ -0,0 +1,18 @@
+import { Outlet, createFileRoute } from '@tanstack/solid-router'
+
+export const Route = createFileRoute('/relative/link/path/')({
+ component: RouteComponent,
+})
+
+function RouteComponent() {
+ return (
+
+
+ Relative Routing Tests - Path Params
+
+
+
+
+
+ )
+}
diff --git a/e2e/solid-router/basic-file-based/src/routes/relative/link/relative-link-a.tsx b/e2e/solid-router/basic-file-based/src/routes/relative/link/relative-link-a.tsx
new file mode 100644
index 0000000000..daa2cea064
--- /dev/null
+++ b/e2e/solid-router/basic-file-based/src/routes/relative/link/relative-link-a.tsx
@@ -0,0 +1,13 @@
+import { createFileRoute } from '@tanstack/solid-router'
+
+export const Route = createFileRoute('/relative/link/relative-link-a')({
+ component: RouteComponent,
+})
+
+function RouteComponent() {
+ return (
+
+ Hello "/relative/link/relative-link-a"!
+
+ )
+}
diff --git a/e2e/solid-router/basic-file-based/src/routes/relative/link/relative-link-b.tsx b/e2e/solid-router/basic-file-based/src/routes/relative/link/relative-link-b.tsx
new file mode 100644
index 0000000000..9f80899b73
--- /dev/null
+++ b/e2e/solid-router/basic-file-based/src/routes/relative/link/relative-link-b.tsx
@@ -0,0 +1,13 @@
+import { createFileRoute } from '@tanstack/solid-router'
+
+export const Route = createFileRoute('/relative/link/relative-link-b')({
+ component: RouteComponent,
+})
+
+function RouteComponent() {
+ return (
+
+ Hello "/relative/link/relative-link-b"!
+
+ )
+}
diff --git a/e2e/solid-router/basic-file-based/src/routes/relative/link/route.tsx b/e2e/solid-router/basic-file-based/src/routes/relative/link/route.tsx
new file mode 100644
index 0000000000..5d6934442b
--- /dev/null
+++ b/e2e/solid-router/basic-file-based/src/routes/relative/link/route.tsx
@@ -0,0 +1,93 @@
+import {
+ Link,
+ Outlet,
+ createFileRoute,
+ useNavigate,
+} from '@tanstack/solid-router'
+import { createEffect } from 'solid-js'
+
+export const Route = createFileRoute('/relative/link')({
+ component: RouteComponent,
+})
+
+function RouteComponent() {
+ createEffect(() => {
+ console.log('navigate')
+ })
+
+ return (
+
+
+ Relative Routing - Links - Index
+
+
+
+ Return To Home
+
+
+ Return To Index
+
+
+ Reload
+
+
+ Back
+
+
+ To Relative Link A
+
+
+ To Relative Link B
+
+
+ To Deeply Nested
+
+
+ To Path Param A
+
+
+ To With Search Params
+
+
+
+
+
+
+ )
+}
diff --git a/e2e/solid-router/basic-file-based/src/routes/relative/link/with-search/index.tsx b/e2e/solid-router/basic-file-based/src/routes/relative/link/with-search/index.tsx
new file mode 100644
index 0000000000..f571340a56
--- /dev/null
+++ b/e2e/solid-router/basic-file-based/src/routes/relative/link/with-search/index.tsx
@@ -0,0 +1,29 @@
+import { Link, createFileRoute } from '@tanstack/solid-router'
+import { z } from 'zod'
+
+export const Route = createFileRoute('/relative/link/with-search/')({
+ component: RouteComponent,
+ validateSearch: z.object({
+ searchParam: z.string().default('1'),
+ }),
+})
+
+function RouteComponent() {
+ const searchParams = Route.useSearch()
+ return (
+ <>
+
+ Hello "/relative/link/with-search/" searchParam:{' '}
+ {searchParams().searchParam}!
+
+
+
+ Update Search
+
+ >
+ )
+}
diff --git a/e2e/solid-router/basic-file-based/src/routes/relative/useNavigate/nested/deep/index.tsx b/e2e/solid-router/basic-file-based/src/routes/relative/useNavigate/nested/deep/index.tsx
new file mode 100644
index 0000000000..a373967b11
--- /dev/null
+++ b/e2e/solid-router/basic-file-based/src/routes/relative/useNavigate/nested/deep/index.tsx
@@ -0,0 +1,13 @@
+import { createFileRoute } from '@tanstack/solid-router'
+
+export const Route = createFileRoute('/relative/useNavigate/nested/deep/')({
+ component: RouteComponent,
+})
+
+function RouteComponent() {
+ return (
+
+ Hello "/relative/useNavigate/nested/deep/"!
+
+ )
+}
diff --git a/e2e/solid-router/basic-file-based/src/routes/relative/useNavigate/nested/index.tsx b/e2e/solid-router/basic-file-based/src/routes/relative/useNavigate/nested/index.tsx
new file mode 100644
index 0000000000..5e41c4c6db
--- /dev/null
+++ b/e2e/solid-router/basic-file-based/src/routes/relative/useNavigate/nested/index.tsx
@@ -0,0 +1,13 @@
+import { createFileRoute } from '@tanstack/solid-router'
+
+export const Route = createFileRoute('/relative/useNavigate/nested/')({
+ component: RouteComponent,
+})
+
+function RouteComponent() {
+ return (
+
+ Hello "/relative/useNavigate/nested/"!
+
+ )
+}
diff --git a/e2e/solid-router/basic-file-based/src/routes/relative/useNavigate/path/$path/index.tsx b/e2e/solid-router/basic-file-based/src/routes/relative/useNavigate/path/$path/index.tsx
new file mode 100644
index 0000000000..167aca58d7
--- /dev/null
+++ b/e2e/solid-router/basic-file-based/src/routes/relative/useNavigate/path/$path/index.tsx
@@ -0,0 +1,40 @@
+import { createFileRoute, useNavigate } from '@tanstack/solid-router'
+
+export const Route = createFileRoute('/relative/useNavigate/path/$path/')({
+ component: RouteComponent,
+ loader: ({ params }) => {
+ return params
+ },
+})
+
+function RouteComponent() {
+ const navigate = useNavigate()
+
+ const params = Route.useParams()
+
+ return (
+
+
+ Hello from "/relative/useNavigate/path/{params().path}"!
+
+
+
+ navigate({
+ from: '/relative/useNavigate/path',
+ to: './$path',
+ params: { path: params().path === 'a' ? 'b' : 'a' },
+ })
+ }
+ class="mr-2"
+ data-testid="relative-useNavigate-path-param-switchAB"
+ >
+ To {params().path === 'a' ? 'b' : 'a'}
+
+
+
+ )
+}
diff --git a/e2e/solid-router/basic-file-based/src/routes/relative/useNavigate/path/index.tsx b/e2e/solid-router/basic-file-based/src/routes/relative/useNavigate/path/index.tsx
new file mode 100644
index 0000000000..6734648ae5
--- /dev/null
+++ b/e2e/solid-router/basic-file-based/src/routes/relative/useNavigate/path/index.tsx
@@ -0,0 +1,18 @@
+import { Outlet, createFileRoute } from '@tanstack/solid-router'
+
+export const Route = createFileRoute('/relative/useNavigate/path/')({
+ component: RouteComponent,
+})
+
+function RouteComponent() {
+ return (
+
+
+ Relative Routing Tests - Path Params
+
+
+
+
+
+ )
+}
diff --git a/e2e/solid-router/basic-file-based/src/routes/relative/useNavigate/relative-useNavigate-a.tsx b/e2e/solid-router/basic-file-based/src/routes/relative/useNavigate/relative-useNavigate-a.tsx
new file mode 100644
index 0000000000..bbe5625a62
--- /dev/null
+++ b/e2e/solid-router/basic-file-based/src/routes/relative/useNavigate/relative-useNavigate-a.tsx
@@ -0,0 +1,15 @@
+import { createFileRoute } from '@tanstack/solid-router'
+
+export const Route = createFileRoute(
+ '/relative/useNavigate/relative-useNavigate-a',
+)({
+ component: RouteComponent,
+})
+
+function RouteComponent() {
+ return (
+
+ Hello "/relative/useNavigate/relative-useNavigate-a"!
+
+ )
+}
diff --git a/e2e/solid-router/basic-file-based/src/routes/relative/useNavigate/relative-useNavigate-b.tsx b/e2e/solid-router/basic-file-based/src/routes/relative/useNavigate/relative-useNavigate-b.tsx
new file mode 100644
index 0000000000..9be49cfcdc
--- /dev/null
+++ b/e2e/solid-router/basic-file-based/src/routes/relative/useNavigate/relative-useNavigate-b.tsx
@@ -0,0 +1,15 @@
+import { createFileRoute } from '@tanstack/solid-router'
+
+export const Route = createFileRoute(
+ '/relative/useNavigate/relative-useNavigate-b',
+)({
+ component: RouteComponent,
+})
+
+function RouteComponent() {
+ return (
+
+ Hello "/relative/useNavigate/relative-useNavigate-b"!
+
+ )
+}
diff --git a/e2e/solid-router/basic-file-based/src/routes/relative/useNavigate/route.tsx b/e2e/solid-router/basic-file-based/src/routes/relative/useNavigate/route.tsx
new file mode 100644
index 0000000000..7bdaeaecb5
--- /dev/null
+++ b/e2e/solid-router/basic-file-based/src/routes/relative/useNavigate/route.tsx
@@ -0,0 +1,134 @@
+import { Outlet, createFileRoute, useNavigate } from '@tanstack/solid-router'
+import { createEffect } from 'solid-js'
+
+export const Route = createFileRoute('/relative/useNavigate')({
+ component: RouteComponent,
+})
+
+function RouteComponent() {
+ const navigate = useNavigate()
+
+ createEffect(() => {
+ console.log('navigate')
+ })
+
+ return (
+
+
+ Relative Routing - Links - Index
+
+
+
+ navigate({
+ from: '/relative/useNavigate',
+ to: '..',
+ })
+ }
+ data-testid="relative-useNavigate-home"
+ class="mr-2 underline"
+ >
+ Return To Home
+
+
+ navigate({
+ from: '/relative/useNavigate',
+ to: '.',
+ })
+ }
+ data-testid="relative-useNavigate-index"
+ class="mr-2 underline"
+ >
+ Return To Index
+
+
+ navigate({
+ to: '.',
+ })
+ }
+ data-testid="relative-useNavigate-reload"
+ class="mr-2 underline"
+ >
+ Reload
+
+
+ navigate({
+ to: '..',
+ })
+ }
+ data-testid="relative-useNavigate-back"
+ class="mr-2 underline"
+ >
+ Back
+
+
+ navigate({
+ from: '/relative/useNavigate',
+ to: './relative-useNavigate-a',
+ })
+ }
+ data-testid="relative-useNavigate-a"
+ class="mr-2 underline"
+ >
+ To Relative useNavigate A
+
+
+ navigate({
+ from: '/relative/useNavigate',
+ to: './relative-useNavigate-b',
+ })
+ }
+ data-testid="relative-useNavigate-b"
+ class="mr-2 underline"
+ >
+ To Relative Link B
+
+
+ navigate({
+ from: '/relative/useNavigate',
+ to: './nested/deep',
+ })
+ }
+ data-testid="relative-useNavigate-deeply-nested"
+ class="mr-2 underline"
+ >
+ To Deeply Nested
+
+
+ navigate({
+ to: '/relative/useNavigate/path/$path',
+ params: { path: 'a' },
+ })
+ }
+ data-testid="relative-useNavigate-path"
+ class="mr-2 underline"
+ >
+ To Path Param A
+
+
+ navigate({
+ from: '/relative/useNavigate',
+ to: './with-search',
+ search: { searchParam: '1' },
+ })
+ }
+ data-testid="relative-useNavigate-withSearch"
+ class="mr-2 underline"
+ >
+ To With Search Params
+
+
+
+
+
+
+ )
+}
diff --git a/e2e/solid-router/basic-file-based/src/routes/relative/useNavigate/with-search/index.tsx b/e2e/solid-router/basic-file-based/src/routes/relative/useNavigate/with-search/index.tsx
new file mode 100644
index 0000000000..524eae04a7
--- /dev/null
+++ b/e2e/solid-router/basic-file-based/src/routes/relative/useNavigate/with-search/index.tsx
@@ -0,0 +1,35 @@
+import { createFileRoute, useNavigate } from '@tanstack/solid-router'
+import { z } from 'zod'
+
+export const Route = createFileRoute('/relative/useNavigate/with-search/')({
+ component: RouteComponent,
+ validateSearch: z.object({
+ searchParam: z.string().default('1'),
+ }),
+})
+
+function RouteComponent() {
+ const navigate = useNavigate()
+ const searchParams = Route.useSearch()
+
+ return (
+ <>
+
+ Hello "/relative/useNavigate/with-search/" searchParam:{' '}
+ {searchParams().searchParam}!
+
+
+
+ navigate({
+ to: '.',
+ search: { searchParam: '2' },
+ })
+ }
+ data-testid="relative-useNavigate-withSearch-update-param"
+ >
+ Update Search
+
+ >
+ )
+}
diff --git a/e2e/solid-router/basic-file-based/tests/relative.spec.ts b/e2e/solid-router/basic-file-based/tests/relative.spec.ts
new file mode 100644
index 0000000000..4850d3630d
--- /dev/null
+++ b/e2e/solid-router/basic-file-based/tests/relative.spec.ts
@@ -0,0 +1,273 @@
+import { expect, test } from '@playwright/test'
+import combinateImport from 'combinate'
+import { getTestServerPort } from '@tanstack/router-e2e-utils'
+import packageJson from '../package.json' with { type: 'json' }
+
+// somehow playwright does not correctly import default exports
+const combinate = (combinateImport as any).default as typeof combinateImport
+
+const PORT = await getTestServerPort(packageJson.name)
+
+test.describe('relative_routing', () => {
+ const internalNavigationTestMatrix = combinate({
+ navigation: ['link', 'useNavigate'] as const,
+ })
+
+ internalNavigationTestMatrix.forEach(({ navigation }) => {
+ test(`simple relative navigation. navigation: ${navigation}`, async ({
+ page,
+ }) => {
+ await page.waitForLoadState('networkidle')
+ await page.goto(`/relative/${navigation}`)
+ await page.waitForURL(`http://localhost:${PORT}/relative/${navigation}`)
+
+ await expect(
+ page.getByTestId(`relative-${navigation}-header`),
+ ).toBeInViewport()
+
+ const indexLink = page.getByTestId(`relative-${navigation}-index`)
+ const backLink = page.getByTestId(`relative-${navigation}-back`)
+ const relativeRouteA = page.getByTestId(`relative-${navigation}-a`)
+ const relativeRouteB = page.getByTestId(`relative-${navigation}-b`)
+
+ await relativeRouteA.click()
+
+ await page.waitForURL(
+ `http://localhost:${PORT}/relative/${navigation}/relative-${navigation}-a`,
+ )
+
+ await expect(
+ page.getByTestId(`relative-${navigation}-header`),
+ ).toBeInViewport()
+
+ await expect(
+ page.getByTestId(`relative-${navigation}-a-header`),
+ ).toBeInViewport()
+
+ await relativeRouteB.click()
+
+ await page.waitForURL(
+ `http://localhost:${PORT}/relative/${navigation}/relative-${navigation}-b`,
+ )
+
+ await expect(
+ page.getByTestId(`relative-${navigation}-header`),
+ ).toBeInViewport()
+
+ await expect(
+ page.getByTestId(`relative-${navigation}-b-header`),
+ ).toBeInViewport()
+
+ await indexLink.click()
+
+ await page.waitForURL(`http://localhost:${PORT}/relative/${navigation}`)
+
+ await expect(
+ page.getByTestId(`relative-${navigation}-header`),
+ ).toBeInViewport()
+
+ await expect(
+ page.getByTestId(`relative-${navigation}-b-header`),
+ ).not.toBeInViewport()
+
+ await backLink.click()
+
+ await page.waitForURL(`http://localhost:${PORT}/relative`)
+
+ await expect(page.getByTestId(`relative-routing-home`)).toBeInViewport()
+ })
+
+ test(`nested chilren. navigation: ${navigation}`, async ({ page }) => {
+ await page.waitForLoadState('networkidle')
+ await page.goto(`/relative/${navigation}`)
+ await page.waitForURL(`http://localhost:${PORT}/relative/${navigation}`)
+
+ await expect(
+ page.getByTestId(`relative-${navigation}-header`),
+ ).toBeInViewport()
+
+ const backLink = page.getByTestId(`relative-${navigation}-back`)
+
+ const deeplyNestedChildRoute = page.getByTestId(
+ `relative-${navigation}-deeply-nested`,
+ )
+
+ await deeplyNestedChildRoute.click()
+
+ await page.waitForURL(
+ `http://localhost:${PORT}/relative/${navigation}/nested/deep`,
+ )
+
+ await expect(
+ page.getByTestId(`relative-${navigation}-nested-deep-header`),
+ ).toBeInViewport()
+
+ await backLink.click()
+
+ await page.waitForURL(
+ `http://localhost:${PORT}/relative/${navigation}/nested`,
+ )
+
+ await expect(
+ page.getByTestId(`relative-${navigation}-nested-header`),
+ ).toBeInViewport()
+ })
+
+ test(`with path params. navigation: ${navigation}`, async ({ page }) => {
+ await page.waitForLoadState('networkidle')
+ await page.goto(`/relative/${navigation}`)
+ await page.waitForURL(`http://localhost:${PORT}/relative/${navigation}`)
+
+ await expect(
+ page.getByTestId(`relative-${navigation}-header`),
+ ).toBeInViewport()
+
+ const pathParamRoute = page.getByTestId(`relative-${navigation}-path`)
+
+ await pathParamRoute.click()
+
+ await page.waitForURL(
+ `http://localhost:${PORT}/relative/${navigation}/path/a`,
+ )
+
+ expect(page.url().endsWith('/path/a')).toBe(true)
+
+ await expect(
+ page.getByTestId(`relative-${navigation}-path-param-header`),
+ ).toBeInViewport()
+
+ const switchParamLink = page.getByTestId(
+ `relative-${navigation}-path-param-switchAB`,
+ )
+
+ await switchParamLink.click()
+
+ await page.waitForURL(
+ `http://localhost:${PORT}/relative/${navigation}/path/b`,
+ )
+
+ expect(page.url().endsWith('/path/b')).toBe(true)
+
+ await expect(
+ page.getByTestId(`relative-${navigation}-path-param-header`),
+ ).toBeInViewport()
+ })
+
+ test(`with search params. navigation: ${navigation}`, async ({ page }) => {
+ await page.waitForLoadState('networkidle')
+ await page.goto(`/relative/${navigation}`)
+ await page.waitForURL(`http://localhost:${PORT}/relative/${navigation}`)
+
+ await expect(
+ page.getByTestId(`relative-${navigation}-header`),
+ ).toBeInViewport()
+
+ const searchParamRoute = page.getByTestId(
+ `relative-${navigation}-withSearch`,
+ )
+
+ await searchParamRoute.click()
+
+ let expectedUrl = new URL(
+ `http://localhost:${PORT}/relative/${navigation}/with-search?searchParam="1"`,
+ )
+
+ await page.waitForLoadState('domcontentloaded')
+
+ expect(page.url().toString()).toBe(expectedUrl.toString())
+
+ await expect(
+ page.getByTestId(`relative-${navigation}-withSearch-header`),
+ ).toBeInViewport()
+
+ await expect(
+ page.getByTestId(`relative-${navigation}-withSearch-header`),
+ ).toContainText('searchParam: 1')
+
+ const updateSearchLink = page.getByTestId(
+ `relative-${navigation}-withSearch-update-param`,
+ )
+
+ await updateSearchLink.click()
+
+ await page.waitForLoadState('domcontentloaded')
+
+ expectedUrl = new URL(
+ `http://localhost:${PORT}/relative/${navigation}/with-search?searchParam="2"`,
+ )
+
+ expect(page.url().toString()).toBe(expectedUrl.toString())
+
+ await expect(
+ page.getByTestId(`relative-${navigation}-withSearch-header`),
+ ).toContainText('searchParam: 2')
+
+ await expect(
+ page.getByTestId(`relative-${navigation}-withSearch-header`),
+ ).toBeInViewport()
+ })
+
+ test(`shouldn't cause excessive rendering. navigation: ${navigation}`, async ({
+ page,
+ }) => {
+ let navigateMsgs = 0
+
+ page.on('console', (msg) => {
+ if (msg.text() === 'navigate') {
+ navigateMsgs++
+ }
+ })
+
+ await page.waitForLoadState('networkidle')
+ await page.goto(`/relative/${navigation}`)
+ await page.waitForURL(`http://localhost:${PORT}/relative/${navigation}`)
+
+ await expect(
+ page.getByTestId(`relative-${navigation}-header`),
+ ).toBeInViewport()
+
+ expect(navigateMsgs).toBe(1)
+ const indexLink = page.getByTestId(`relative-${navigation}-index`)
+ const backLink = page.getByTestId(`relative-${navigation}-back`)
+ const relativeRouteA = page.getByTestId(`relative-${navigation}-a`)
+ const relativeRouteB = page.getByTestId(`relative-${navigation}-b`)
+ const deeplyNestedChildRoute = page.getByTestId(
+ `relative-${navigation}-deeply-nested`,
+ )
+ const pathParamRoute = page.getByTestId(`relative-${navigation}-path`)
+ const searchParamRoute = page.getByTestId(
+ `relative-${navigation}-withSearch`,
+ )
+
+ await relativeRouteA.click()
+ await page.waitForLoadState('domcontentloaded')
+ await relativeRouteB.click()
+ await page.waitForLoadState('domcontentloaded')
+ await deeplyNestedChildRoute.click()
+ await page.waitForLoadState('domcontentloaded')
+ await backLink.click()
+ await page.waitForLoadState('domcontentloaded')
+ await pathParamRoute.click()
+ await page.waitForLoadState('domcontentloaded')
+ const switchParamLink = page.getByTestId(
+ `relative-${navigation}-path-param-switchAB`,
+ )
+ await switchParamLink.click()
+ await page.waitForLoadState('domcontentloaded')
+ await searchParamRoute.click()
+ await page.waitForLoadState('domcontentloaded')
+
+ const updateSearchLink = page.getByTestId(
+ `relative-${navigation}-withSearch-update-param`,
+ )
+
+ await updateSearchLink.click()
+ await page.waitForLoadState('domcontentloaded')
+
+ await indexLink.click()
+ await page.waitForLoadState('domcontentloaded')
+
+ expect(navigateMsgs).toBe(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-file-based/src/routeTree.gen.ts b/e2e/solid-router/basic-virtual-file-based/src/routeTree.gen.ts
index abbf5c8056..0ba11d91ea 100644
--- a/e2e/solid-router/basic-virtual-file-based/src/routeTree.gen.ts
+++ b/e2e/solid-router/basic-virtual-file-based/src/routeTree.gen.ts
@@ -168,11 +168,11 @@ export interface RootRouteChildren {
declare module '@tanstack/solid-router' {
interface FileRoutesByPath {
- '/': {
- id: '/'
- path: '/'
- fullPath: '/'
- preLoaderRoute: typeof homeRouteImport
+ '/posts': {
+ id: '/posts'
+ path: '/posts'
+ fullPath: '/posts'
+ preLoaderRoute: typeof postsPostsRouteImport
parentRoute: typeof rootRouteImport
}
'/_first': {
@@ -182,25 +182,18 @@ declare module '@tanstack/solid-router' {
preLoaderRoute: typeof layoutFirstLayoutRouteImport
parentRoute: typeof rootRouteImport
}
- '/posts': {
- id: '/posts'
- path: '/posts'
- fullPath: '/posts'
- preLoaderRoute: typeof postsPostsRouteImport
- parentRoute: typeof rootRouteImport
- }
- '/classic/hello': {
- id: '/classic/hello'
- path: '/classic/hello'
- fullPath: '/classic/hello'
- preLoaderRoute: typeof ClassicHelloRouteRouteImport
- parentRoute: typeof rootRouteImport
- }
- '/posts/': {
- id: '/posts/'
+ '/': {
+ id: '/'
path: '/'
- fullPath: '/posts/'
- preLoaderRoute: typeof postsPostsHomeRouteImport
+ fullPath: '/'
+ preLoaderRoute: typeof homeRouteImport
+ parentRoute: typeof rootRouteImport
+ }
+ '/posts/$postId': {
+ id: '/posts/$postId'
+ path: '/$postId'
+ fullPath: '/posts/$postId'
+ preLoaderRoute: typeof postsPostsDetailRouteImport
parentRoute: typeof postsPostsRoute
}
'/_first/_second': {
@@ -210,32 +203,25 @@ declare module '@tanstack/solid-router' {
preLoaderRoute: typeof layoutSecondLayoutRouteImport
parentRoute: typeof layoutFirstLayoutRoute
}
- '/posts/$postId': {
- id: '/posts/$postId'
- path: '/$postId'
- fullPath: '/posts/$postId'
- preLoaderRoute: typeof postsPostsDetailRouteImport
+ '/posts/': {
+ id: '/posts/'
+ path: '/'
+ fullPath: '/posts/'
+ preLoaderRoute: typeof postsPostsHomeRouteImport
parentRoute: typeof postsPostsRoute
}
- '/_first/_second/layout-a': {
- id: '/_first/_second/layout-a'
- path: '/layout-a'
- fullPath: '/layout-a'
- preLoaderRoute: typeof aRouteImport
- parentRoute: typeof layoutSecondLayoutRoute
+ '/classic/hello': {
+ id: '/classic/hello'
+ path: '/classic/hello'
+ fullPath: '/classic/hello'
+ preLoaderRoute: typeof ClassicHelloRouteRouteImport
+ parentRoute: typeof rootRouteImport
}
- '/_first/_second/layout-b': {
- id: '/_first/_second/layout-b'
- path: '/layout-b'
- fullPath: '/layout-b'
- preLoaderRoute: typeof bRouteImport
- parentRoute: typeof layoutSecondLayoutRoute
- }
- '/classic/hello/universe': {
- id: '/classic/hello/universe'
- path: '/universe'
- fullPath: '/classic/hello/universe'
- preLoaderRoute: typeof ClassicHelloUniverseRouteImport
+ '/classic/hello/': {
+ id: '/classic/hello/'
+ path: '/'
+ fullPath: '/classic/hello/'
+ preLoaderRoute: typeof ClassicHelloIndexRouteImport
parentRoute: typeof ClassicHelloRouteRoute
}
'/classic/hello/world': {
@@ -245,13 +231,27 @@ declare module '@tanstack/solid-router' {
preLoaderRoute: typeof ClassicHelloWorldRouteImport
parentRoute: typeof ClassicHelloRouteRoute
}
- '/classic/hello/': {
- id: '/classic/hello/'
- path: '/'
- fullPath: '/classic/hello/'
- preLoaderRoute: typeof ClassicHelloIndexRouteImport
+ '/classic/hello/universe': {
+ id: '/classic/hello/universe'
+ path: '/universe'
+ fullPath: '/classic/hello/universe'
+ preLoaderRoute: typeof ClassicHelloUniverseRouteImport
parentRoute: typeof ClassicHelloRouteRoute
}
+ '/_first/_second/layout-b': {
+ id: '/_first/_second/layout-b'
+ path: '/layout-b'
+ fullPath: '/layout-b'
+ preLoaderRoute: typeof bRouteImport
+ parentRoute: typeof layoutSecondLayoutRoute
+ }
+ '/_first/_second/layout-a': {
+ id: '/_first/_second/layout-a'
+ path: '/layout-a'
+ fullPath: '/layout-a'
+ preLoaderRoute: typeof aRouteImport
+ parentRoute: typeof layoutSecondLayoutRoute
+ }
}
}
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/routeTree.gen.ts b/e2e/solid-start/basic/src/routeTree.gen.ts
index 307552541d..f3c2d594f9 100644
--- a/e2e/solid-start/basic/src/routeTree.gen.ts
+++ b/e2e/solid-start/basic/src/routeTree.gen.ts
@@ -8,8 +8,6 @@
// 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/solid-start/server'
-
import { Route as rootRouteImport } from './routes/__root'
import { Route as UsersRouteImport } from './routes/users'
import { Route as StreamRouteImport } from './routes/stream'
@@ -33,21 +31,19 @@ import { Route as RedirectTargetRouteImport } from './routes/redirect/$target'
import { Route as PostsPostIdRouteImport } from './routes/posts.$postId'
import { Route as NotFoundViaLoaderRouteImport } from './routes/not-found/via-loader'
import { Route as NotFoundViaBeforeLoadRouteImport } from './routes/not-found/via-beforeLoad'
+import { Route as ApiUsersRouteImport } from './routes/api/users'
import { Route as LayoutLayout2RouteImport } from './routes/_layout/_layout-2'
import { Route as RedirectTargetIndexRouteImport } from './routes/redirect/$target/index'
import { Route as RedirectTargetViaLoaderRouteImport } from './routes/redirect/$target/via-loader'
import { Route as RedirectTargetViaBeforeLoadRouteImport } from './routes/redirect/$target/via-beforeLoad'
import { Route as PostsPostIdDeepRouteImport } from './routes/posts_.$postId.deep'
+import { Route as ApiUsersUserIdRouteImport } from './routes/api/users.$userId'
import { Route as LayoutLayout2LayoutBRouteImport } from './routes/_layout/_layout-2/layout-b'
import { Route as LayoutLayout2LayoutARouteImport } from './routes/_layout/_layout-2/layout-a'
import { Route as RedirectTargetServerFnIndexRouteImport } from './routes/redirect/$target/serverFn/index'
import { Route as RedirectTargetServerFnViaUseServerFnRouteImport } from './routes/redirect/$target/serverFn/via-useServerFn'
import { Route as RedirectTargetServerFnViaLoaderRouteImport } from './routes/redirect/$target/serverFn/via-loader'
import { Route as RedirectTargetServerFnViaBeforeLoadRouteImport } from './routes/redirect/$target/serverFn/via-beforeLoad'
-import { ServerRoute as ApiUsersServerRouteImport } from './routes/api/users'
-import { ServerRoute as ApiUsersUserIdServerRouteImport } from './routes/api/users.$userId'
-
-const rootServerRouteImport = createServerRootRoute()
const UsersRoute = UsersRouteImport.update({
id: '/users',
@@ -159,6 +155,11 @@ const NotFoundViaBeforeLoadRoute = NotFoundViaBeforeLoadRouteImport.update({
path: '/via-beforeLoad',
getParentRoute: () => NotFoundRouteRoute,
} as any)
+const ApiUsersRoute = ApiUsersRouteImport.update({
+ id: '/api/users',
+ path: '/api/users',
+ getParentRoute: () => rootRouteImport,
+} as any)
const LayoutLayout2Route = LayoutLayout2RouteImport.update({
id: '/_layout-2',
getParentRoute: () => LayoutRoute,
@@ -184,6 +185,11 @@ const PostsPostIdDeepRoute = PostsPostIdDeepRouteImport.update({
path: '/posts/$postId/deep',
getParentRoute: () => rootRouteImport,
} as any)
+const ApiUsersUserIdRoute = ApiUsersUserIdRouteImport.update({
+ id: '/$userId',
+ path: '/$userId',
+ getParentRoute: () => ApiUsersRoute,
+} as any)
const LayoutLayout2LayoutBRoute = LayoutLayout2LayoutBRouteImport.update({
id: '/layout-b',
path: '/layout-b',
@@ -218,16 +224,6 @@ const RedirectTargetServerFnViaBeforeLoadRoute =
path: '/serverFn/via-beforeLoad',
getParentRoute: () => RedirectTargetRoute,
} as any)
-const ApiUsersServerRoute = ApiUsersServerRouteImport.update({
- id: '/api/users',
- path: '/api/users',
- getParentRoute: () => rootServerRouteImport,
-} as any)
-const ApiUsersUserIdServerRoute = ApiUsersUserIdServerRouteImport.update({
- id: '/$userId',
- path: '/$userId',
- getParentRoute: () => ApiUsersServerRoute,
-} as any)
export interface FileRoutesByFullPath {
'/': typeof IndexRoute
@@ -239,6 +235,7 @@ export interface FileRoutesByFullPath {
'/scripts': typeof ScriptsRoute
'/stream': typeof StreamRoute
'/users': typeof UsersRouteWithChildren
+ '/api/users': typeof ApiUsersRouteWithChildren
'/not-found/via-beforeLoad': typeof NotFoundViaBeforeLoadRoute
'/not-found/via-loader': typeof NotFoundViaLoaderRoute
'/posts/$postId': typeof PostsPostIdRoute
@@ -253,6 +250,7 @@ export interface FileRoutesByFullPath {
'/users/': typeof UsersIndexRoute
'/layout-a': typeof LayoutLayout2LayoutARoute
'/layout-b': typeof LayoutLayout2LayoutBRoute
+ '/api/users/$userId': typeof ApiUsersUserIdRoute
'/posts/$postId/deep': typeof PostsPostIdDeepRoute
'/redirect/$target/via-beforeLoad': typeof RedirectTargetViaBeforeLoadRoute
'/redirect/$target/via-loader': typeof RedirectTargetViaLoaderRoute
@@ -268,6 +266,7 @@ export interface FileRoutesByTo {
'/links': typeof LinksRoute
'/scripts': typeof ScriptsRoute
'/stream': typeof StreamRoute
+ '/api/users': typeof ApiUsersRouteWithChildren
'/not-found/via-beforeLoad': typeof NotFoundViaBeforeLoadRoute
'/not-found/via-loader': typeof NotFoundViaLoaderRoute
'/posts/$postId': typeof PostsPostIdRoute
@@ -281,6 +280,7 @@ export interface FileRoutesByTo {
'/users': typeof UsersIndexRoute
'/layout-a': typeof LayoutLayout2LayoutARoute
'/layout-b': typeof LayoutLayout2LayoutBRoute
+ '/api/users/$userId': typeof ApiUsersUserIdRoute
'/posts/$postId/deep': typeof PostsPostIdDeepRoute
'/redirect/$target/via-beforeLoad': typeof RedirectTargetViaBeforeLoadRoute
'/redirect/$target/via-loader': typeof RedirectTargetViaLoaderRoute
@@ -303,6 +303,7 @@ export interface FileRoutesById {
'/stream': typeof StreamRoute
'/users': typeof UsersRouteWithChildren
'/_layout/_layout-2': typeof LayoutLayout2RouteWithChildren
+ '/api/users': typeof ApiUsersRouteWithChildren
'/not-found/via-beforeLoad': typeof NotFoundViaBeforeLoadRoute
'/not-found/via-loader': typeof NotFoundViaLoaderRoute
'/posts/$postId': typeof PostsPostIdRoute
@@ -317,6 +318,7 @@ export interface FileRoutesById {
'/users/': typeof UsersIndexRoute
'/_layout/_layout-2/layout-a': typeof LayoutLayout2LayoutARoute
'/_layout/_layout-2/layout-b': typeof LayoutLayout2LayoutBRoute
+ '/api/users/$userId': typeof ApiUsersUserIdRoute
'/posts_/$postId/deep': typeof PostsPostIdDeepRoute
'/redirect/$target/via-beforeLoad': typeof RedirectTargetViaBeforeLoadRoute
'/redirect/$target/via-loader': typeof RedirectTargetViaLoaderRoute
@@ -338,6 +340,7 @@ export interface FileRouteTypes {
| '/scripts'
| '/stream'
| '/users'
+ | '/api/users'
| '/not-found/via-beforeLoad'
| '/not-found/via-loader'
| '/posts/$postId'
@@ -352,6 +355,7 @@ export interface FileRouteTypes {
| '/users/'
| '/layout-a'
| '/layout-b'
+ | '/api/users/$userId'
| '/posts/$postId/deep'
| '/redirect/$target/via-beforeLoad'
| '/redirect/$target/via-loader'
@@ -367,6 +371,7 @@ export interface FileRouteTypes {
| '/links'
| '/scripts'
| '/stream'
+ | '/api/users'
| '/not-found/via-beforeLoad'
| '/not-found/via-loader'
| '/posts/$postId'
@@ -380,6 +385,7 @@ export interface FileRouteTypes {
| '/users'
| '/layout-a'
| '/layout-b'
+ | '/api/users/$userId'
| '/posts/$postId/deep'
| '/redirect/$target/via-beforeLoad'
| '/redirect/$target/via-loader'
@@ -401,6 +407,7 @@ export interface FileRouteTypes {
| '/stream'
| '/users'
| '/_layout/_layout-2'
+ | '/api/users'
| '/not-found/via-beforeLoad'
| '/not-found/via-loader'
| '/posts/$postId'
@@ -415,6 +422,7 @@ export interface FileRouteTypes {
| '/users/'
| '/_layout/_layout-2/layout-a'
| '/_layout/_layout-2/layout-b'
+ | '/api/users/$userId'
| '/posts_/$postId/deep'
| '/redirect/$target/via-beforeLoad'
| '/redirect/$target/via-loader'
@@ -436,34 +444,11 @@ export interface RootRouteChildren {
ScriptsRoute: typeof ScriptsRoute
StreamRoute: typeof StreamRoute
UsersRoute: typeof UsersRouteWithChildren
+ ApiUsersRoute: typeof ApiUsersRouteWithChildren
RedirectTargetRoute: typeof RedirectTargetRouteWithChildren
RedirectIndexRoute: typeof RedirectIndexRoute
PostsPostIdDeepRoute: typeof PostsPostIdDeepRoute
}
-export interface FileServerRoutesByFullPath {
- '/api/users': typeof ApiUsersServerRouteWithChildren
- '/api/users/$userId': typeof ApiUsersUserIdServerRoute
-}
-export interface FileServerRoutesByTo {
- '/api/users': typeof ApiUsersServerRouteWithChildren
- '/api/users/$userId': typeof ApiUsersUserIdServerRoute
-}
-export interface FileServerRoutesById {
- __root__: typeof rootServerRouteImport
- '/api/users': typeof ApiUsersServerRouteWithChildren
- '/api/users/$userId': typeof ApiUsersUserIdServerRoute
-}
-export interface FileServerRouteTypes {
- fileServerRoutesByFullPath: FileServerRoutesByFullPath
- fullPaths: '/api/users' | '/api/users/$userId'
- fileServerRoutesByTo: FileServerRoutesByTo
- to: '/api/users' | '/api/users/$userId'
- id: '__root__' | '/api/users' | '/api/users/$userId'
- fileServerRoutesById: FileServerRoutesById
-}
-export interface RootServerRouteChildren {
- ApiUsersServerRoute: typeof ApiUsersServerRouteWithChildren
-}
declare module '@tanstack/solid-router' {
interface FileRoutesByPath {
@@ -621,6 +606,13 @@ declare module '@tanstack/solid-router' {
preLoaderRoute: typeof NotFoundViaBeforeLoadRouteImport
parentRoute: typeof NotFoundRouteRoute
}
+ '/api/users': {
+ id: '/api/users'
+ path: '/api/users'
+ fullPath: '/api/users'
+ preLoaderRoute: typeof ApiUsersRouteImport
+ parentRoute: typeof rootRouteImport
+ }
'/_layout/_layout-2': {
id: '/_layout/_layout-2'
path: ''
@@ -656,6 +648,13 @@ declare module '@tanstack/solid-router' {
preLoaderRoute: typeof PostsPostIdDeepRouteImport
parentRoute: typeof rootRouteImport
}
+ '/api/users/$userId': {
+ id: '/api/users/$userId'
+ path: '/$userId'
+ fullPath: '/api/users/$userId'
+ preLoaderRoute: typeof ApiUsersUserIdRouteImport
+ parentRoute: typeof ApiUsersRoute
+ }
'/_layout/_layout-2/layout-b': {
id: '/_layout/_layout-2/layout-b'
path: '/layout-b'
@@ -700,24 +699,6 @@ declare module '@tanstack/solid-router' {
}
}
}
-declare module '@tanstack/solid-start/server' {
- interface ServerFileRoutesByPath {
- '/api/users': {
- id: '/api/users'
- path: '/api/users'
- fullPath: '/api/users'
- preLoaderRoute: typeof ApiUsersServerRouteImport
- parentRoute: typeof rootServerRouteImport
- }
- '/api/users/$userId': {
- id: '/api/users/$userId'
- path: '/$userId'
- fullPath: '/api/users/$userId'
- preLoaderRoute: typeof ApiUsersUserIdServerRouteImport
- parentRoute: typeof ApiUsersServerRoute
- }
- }
-}
interface NotFoundRouteRouteChildren {
NotFoundViaBeforeLoadRoute: typeof NotFoundViaBeforeLoadRoute
@@ -799,6 +780,18 @@ const UsersRouteChildren: UsersRouteChildren = {
const UsersRouteWithChildren = UsersRoute._addFileChildren(UsersRouteChildren)
+interface ApiUsersRouteChildren {
+ ApiUsersUserIdRoute: typeof ApiUsersUserIdRoute
+}
+
+const ApiUsersRouteChildren: ApiUsersRouteChildren = {
+ ApiUsersUserIdRoute: ApiUsersUserIdRoute,
+}
+
+const ApiUsersRouteWithChildren = ApiUsersRoute._addFileChildren(
+ ApiUsersRouteChildren,
+)
+
interface RedirectTargetRouteChildren {
RedirectTargetViaBeforeLoadRoute: typeof RedirectTargetViaBeforeLoadRoute
RedirectTargetViaLoaderRoute: typeof RedirectTargetViaLoaderRoute
@@ -825,18 +818,6 @@ const RedirectTargetRouteWithChildren = RedirectTargetRoute._addFileChildren(
RedirectTargetRouteChildren,
)
-interface ApiUsersServerRouteChildren {
- ApiUsersUserIdServerRoute: typeof ApiUsersUserIdServerRoute
-}
-
-const ApiUsersServerRouteChildren: ApiUsersServerRouteChildren = {
- ApiUsersUserIdServerRoute: ApiUsersUserIdServerRoute,
-}
-
-const ApiUsersServerRouteWithChildren = ApiUsersServerRoute._addFileChildren(
- ApiUsersServerRouteChildren,
-)
-
const rootRouteChildren: RootRouteChildren = {
IndexRoute: IndexRoute,
NotFoundRouteRoute: NotFoundRouteRouteWithChildren,
@@ -848,6 +829,7 @@ const rootRouteChildren: RootRouteChildren = {
ScriptsRoute: ScriptsRoute,
StreamRoute: StreamRoute,
UsersRoute: UsersRouteWithChildren,
+ ApiUsersRoute: ApiUsersRouteWithChildren,
RedirectTargetRoute: RedirectTargetRouteWithChildren,
RedirectIndexRoute: RedirectIndexRoute,
PostsPostIdDeepRoute: PostsPostIdDeepRoute,
@@ -855,9 +837,3 @@ const rootRouteChildren: RootRouteChildren = {
export const routeTree = rootRouteImport
._addFileChildren(rootRouteChildren)
._addFileTypes()
-const rootServerRouteChildren: RootServerRouteChildren = {
- ApiUsersServerRoute: ApiUsersServerRouteWithChildren,
-}
-export const serverRouteTree = rootServerRouteImport
- ._addFileChildren(rootServerRouteChildren)
- ._addFileTypes()
diff --git a/e2e/solid-start/basic/src/routes/api/users.$userId.ts b/e2e/solid-start/basic/src/routes/api/users.$userId.ts
index a653b39ee0..79f89ea0d0 100644
--- a/e2e/solid-start/basic/src/routes/api/users.$userId.ts
+++ b/e2e/solid-start/basic/src/routes/api/users.$userId.ts
@@ -1,4 +1,5 @@
-import { createServerFileRoute } from '@tanstack/solid-start/server'
+import { createFileRoute } from '@tanstack/solid-router'
+import { createFileRoute } from '@tanstack/react-router'
import { json } from '@tanstack/solid-start'
import type { User } from '~/utils/users'
@@ -8,25 +9,27 @@ if (import.meta.env.VITE_NODE_ENV === 'test') {
queryURL = `http://localhost:${import.meta.env.VITE_EXTERNAL_PORT}`
}
-export const ServerRoute = createServerFileRoute('/api/users/$userId').methods({
- GET: async ({ params, request }) => {
- console.info(`Fetching users by id=${params.userId}... @`, request.url)
- try {
- const res = await fetch(`${queryURL}/users/${params.userId}`)
- if (!res.ok) {
- throw new Error('Failed to fetch user')
- }
-
- const user = (await res.json()) as User
-
- return json({
- id: user.id,
- name: user.name,
- email: user.email,
- })
- } catch (e) {
- console.error(e)
- return json({ error: 'User not found' }, { status: 404 })
- }
+export const Route = createFileRoute('/api/users/$userId')({
+ server: {
+ handlers: {
+ GET: async ({ params, request }) => {
+ console.info(`Fetching users by id=${params.userId}... @`, request.url)
+ try {
+ const res = await fetch(`${queryURL}/users/${params.userId}`)
+ if (!res.ok) {
+ throw new Error('Failed to fetch user')
+ }
+ const user = (await res.json()) as User
+ return json({
+ id: user.id,
+ name: user.name,
+ email: user.email,
+ })
+ } catch (e) {
+ console.error(e)
+ return json({ error: 'User not found' }, { status: 404 })
+ }
+ },
+ },
},
})
diff --git a/e2e/solid-start/basic/src/routes/api/users.ts b/e2e/solid-start/basic/src/routes/api/users.ts
index c8d04ac2f2..5672177747 100644
--- a/e2e/solid-start/basic/src/routes/api/users.ts
+++ b/e2e/solid-start/basic/src/routes/api/users.ts
@@ -1,8 +1,9 @@
-import { createServerFileRoute } from '@tanstack/solid-start/server'
+import { createFileRoute } from '@tanstack/solid-router'
+import { createFileRoute } from '@tanstack/react-router'
import { createMiddleware, json } from '@tanstack/solid-start'
import type { User } from '~/utils/users'
-const userLoggerMiddleware = createMiddleware({ type: 'request' }).server(
+const userLoggerMiddleware = createMiddleware().server(
async ({ next, request }) => {
console.info('In: /users')
const result = await next()
@@ -12,7 +13,7 @@ const userLoggerMiddleware = createMiddleware({ type: 'request' }).server(
},
)
-const testParentMiddleware = createMiddleware({ type: 'request' }).server(
+const testParentMiddleware = createMiddleware().server(
async ({ next, request }) => {
console.info('In: testParentMiddleware')
const result = await next()
@@ -22,20 +23,18 @@ const testParentMiddleware = createMiddleware({ type: 'request' }).server(
},
)
-const testMiddleware = createMiddleware({ type: 'request' })
+const testMiddleware = createMiddleware()
.middleware([testParentMiddleware])
.server(async ({ next, request }) => {
console.info('In: testMiddleware')
const result = await next()
result.response.headers.set('x-test', 'true')
-
// if (Math.random() > 0.5) {
// throw new Response(null, {
// status: 302,
// headers: { Location: 'https://www.google.com' },
// })
// }
-
console.info('Out: testMiddleware')
return result
})
@@ -46,20 +45,22 @@ if (import.meta.env.VITE_NODE_ENV === 'test') {
queryURL = `http://localhost:${import.meta.env.VITE_EXTERNAL_PORT}`
}
-export const ServerRoute = createServerFileRoute('/api/users')
- .middleware([testMiddleware, userLoggerMiddleware, testParentMiddleware])
- .methods({
- GET: async ({ request }) => {
- console.info('Fetching users... @', request.url)
- const res = await fetch(`${queryURL}/users`)
- if (!res.ok) {
- throw new Error('Failed to fetch users')
- }
-
- const data = (await res.json()) as Array
-
- const list = data.slice(0, 10)
-
- return json(list.map((u) => ({ id: u.id, name: u.name, email: u.email })))
+export const Route = createFileRoute('/api/users')({
+ server: {
+ middleware: [testMiddleware, userLoggerMiddleware, testParentMiddleware],
+ handlers: {
+ GET: async ({ request }) => {
+ console.info('Fetching users... @', request.url)
+ const res = await fetch(`${queryURL}/users`)
+ if (!res.ok) {
+ throw new Error('Failed to fetch users')
+ }
+ const data = (await res.json()) as Array
+ const list = data.slice(0, 10)
+ return json(
+ list.map((u) => ({ id: u.id, name: u.name, email: u.email })),
+ )
+ },
},
- })
+ },
+})
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/routeTree.gen.ts b/e2e/solid-start/custom-basepath/src/routeTree.gen.ts
index 124ac4d29f..87e423e1da 100644
--- a/e2e/solid-start/custom-basepath/src/routeTree.gen.ts
+++ b/e2e/solid-start/custom-basepath/src/routeTree.gen.ts
@@ -8,8 +8,6 @@
// 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/solid-start/server'
-
import { Route as rootRouteImport } from './routes/__root'
import { Route as UsersRouteImport } from './routes/users'
import { Route as PostsRouteImport } from './routes/posts'
@@ -19,11 +17,9 @@ import { Route as UsersIndexRouteImport } from './routes/users.index'
import { Route as PostsIndexRouteImport } from './routes/posts.index'
import { Route as UsersUserIdRouteImport } from './routes/users.$userId'
import { Route as PostsPostIdRouteImport } from './routes/posts.$postId'
+import { Route as ApiUsersRouteImport } from './routes/api/users'
import { Route as PostsPostIdDeepRouteImport } from './routes/posts_.$postId.deep'
-import { ServerRoute as ApiUsersServerRouteImport } from './routes/api/users'
-import { ServerRoute as ApiUsersUserIdServerRouteImport } from './routes/api/users.$userId'
-
-const rootServerRouteImport = createServerRootRoute()
+import { Route as ApiUsersUserIdRouteImport } from './routes/api/users.$userId'
const UsersRoute = UsersRouteImport.update({
id: '/users',
@@ -65,20 +61,20 @@ const PostsPostIdRoute = PostsPostIdRouteImport.update({
path: '/$postId',
getParentRoute: () => PostsRoute,
} as any)
+const ApiUsersRoute = ApiUsersRouteImport.update({
+ id: '/api/users',
+ path: '/api/users',
+ getParentRoute: () => rootRouteImport,
+} as any)
const PostsPostIdDeepRoute = PostsPostIdDeepRouteImport.update({
id: '/posts_/$postId/deep',
path: '/posts/$postId/deep',
getParentRoute: () => rootRouteImport,
} as any)
-const ApiUsersServerRoute = ApiUsersServerRouteImport.update({
- id: '/api/users',
- path: '/api/users',
- getParentRoute: () => rootServerRouteImport,
-} as any)
-const ApiUsersUserIdServerRoute = ApiUsersUserIdServerRouteImport.update({
+const ApiUsersUserIdRoute = ApiUsersUserIdRouteImport.update({
id: '/$userId',
path: '/$userId',
- getParentRoute: () => ApiUsersServerRoute,
+ getParentRoute: () => ApiUsersRoute,
} as any)
export interface FileRoutesByFullPath {
@@ -86,19 +82,23 @@ export interface FileRoutesByFullPath {
'/deferred': typeof DeferredRoute
'/posts': typeof PostsRouteWithChildren
'/users': typeof UsersRouteWithChildren
+ '/api/users': typeof ApiUsersRouteWithChildren
'/posts/$postId': typeof PostsPostIdRoute
'/users/$userId': typeof UsersUserIdRoute
'/posts/': typeof PostsIndexRoute
'/users/': typeof UsersIndexRoute
+ '/api/users/$userId': typeof ApiUsersUserIdRoute
'/posts/$postId/deep': typeof PostsPostIdDeepRoute
}
export interface FileRoutesByTo {
'/': typeof IndexRoute
'/deferred': typeof DeferredRoute
+ '/api/users': typeof ApiUsersRouteWithChildren
'/posts/$postId': typeof PostsPostIdRoute
'/users/$userId': typeof UsersUserIdRoute
'/posts': typeof PostsIndexRoute
'/users': typeof UsersIndexRoute
+ '/api/users/$userId': typeof ApiUsersUserIdRoute
'/posts/$postId/deep': typeof PostsPostIdDeepRoute
}
export interface FileRoutesById {
@@ -107,10 +107,12 @@ export interface FileRoutesById {
'/deferred': typeof DeferredRoute
'/posts': typeof PostsRouteWithChildren
'/users': typeof UsersRouteWithChildren
+ '/api/users': typeof ApiUsersRouteWithChildren
'/posts/$postId': typeof PostsPostIdRoute
'/users/$userId': typeof UsersUserIdRoute
'/posts/': typeof PostsIndexRoute
'/users/': typeof UsersIndexRoute
+ '/api/users/$userId': typeof ApiUsersUserIdRoute
'/posts_/$postId/deep': typeof PostsPostIdDeepRoute
}
export interface FileRouteTypes {
@@ -120,19 +122,23 @@ export interface FileRouteTypes {
| '/deferred'
| '/posts'
| '/users'
+ | '/api/users'
| '/posts/$postId'
| '/users/$userId'
| '/posts/'
| '/users/'
+ | '/api/users/$userId'
| '/posts/$postId/deep'
fileRoutesByTo: FileRoutesByTo
to:
| '/'
| '/deferred'
+ | '/api/users'
| '/posts/$postId'
| '/users/$userId'
| '/posts'
| '/users'
+ | '/api/users/$userId'
| '/posts/$postId/deep'
id:
| '__root__'
@@ -140,10 +146,12 @@ export interface FileRouteTypes {
| '/deferred'
| '/posts'
| '/users'
+ | '/api/users'
| '/posts/$postId'
| '/users/$userId'
| '/posts/'
| '/users/'
+ | '/api/users/$userId'
| '/posts_/$postId/deep'
fileRoutesById: FileRoutesById
}
@@ -152,32 +160,9 @@ export interface RootRouteChildren {
DeferredRoute: typeof DeferredRoute
PostsRoute: typeof PostsRouteWithChildren
UsersRoute: typeof UsersRouteWithChildren
+ ApiUsersRoute: typeof ApiUsersRouteWithChildren
PostsPostIdDeepRoute: typeof PostsPostIdDeepRoute
}
-export interface FileServerRoutesByFullPath {
- '/api/users': typeof ApiUsersServerRouteWithChildren
- '/api/users/$userId': typeof ApiUsersUserIdServerRoute
-}
-export interface FileServerRoutesByTo {
- '/api/users': typeof ApiUsersServerRouteWithChildren
- '/api/users/$userId': typeof ApiUsersUserIdServerRoute
-}
-export interface FileServerRoutesById {
- __root__: typeof rootServerRouteImport
- '/api/users': typeof ApiUsersServerRouteWithChildren
- '/api/users/$userId': typeof ApiUsersUserIdServerRoute
-}
-export interface FileServerRouteTypes {
- fileServerRoutesByFullPath: FileServerRoutesByFullPath
- fullPaths: '/api/users' | '/api/users/$userId'
- fileServerRoutesByTo: FileServerRoutesByTo
- to: '/api/users' | '/api/users/$userId'
- id: '__root__' | '/api/users' | '/api/users/$userId'
- fileServerRoutesById: FileServerRoutesById
-}
-export interface RootServerRouteChildren {
- ApiUsersServerRoute: typeof ApiUsersServerRouteWithChildren
-}
declare module '@tanstack/solid-router' {
interface FileRoutesByPath {
@@ -237,6 +222,13 @@ declare module '@tanstack/solid-router' {
preLoaderRoute: typeof PostsPostIdRouteImport
parentRoute: typeof PostsRoute
}
+ '/api/users': {
+ id: '/api/users'
+ path: '/api/users'
+ fullPath: '/api/users'
+ preLoaderRoute: typeof ApiUsersRouteImport
+ parentRoute: typeof rootRouteImport
+ }
'/posts_/$postId/deep': {
id: '/posts_/$postId/deep'
path: '/posts/$postId/deep'
@@ -244,23 +236,12 @@ declare module '@tanstack/solid-router' {
preLoaderRoute: typeof PostsPostIdDeepRouteImport
parentRoute: typeof rootRouteImport
}
- }
-}
-declare module '@tanstack/solid-start/server' {
- interface ServerFileRoutesByPath {
- '/api/users': {
- id: '/api/users'
- path: '/api/users'
- fullPath: '/api/users'
- preLoaderRoute: typeof ApiUsersServerRouteImport
- parentRoute: typeof rootServerRouteImport
- }
'/api/users/$userId': {
id: '/api/users/$userId'
path: '/$userId'
fullPath: '/api/users/$userId'
- preLoaderRoute: typeof ApiUsersUserIdServerRouteImport
- parentRoute: typeof ApiUsersServerRoute
+ preLoaderRoute: typeof ApiUsersUserIdRouteImport
+ parentRoute: typeof ApiUsersRoute
}
}
}
@@ -289,16 +270,16 @@ const UsersRouteChildren: UsersRouteChildren = {
const UsersRouteWithChildren = UsersRoute._addFileChildren(UsersRouteChildren)
-interface ApiUsersServerRouteChildren {
- ApiUsersUserIdServerRoute: typeof ApiUsersUserIdServerRoute
+interface ApiUsersRouteChildren {
+ ApiUsersUserIdRoute: typeof ApiUsersUserIdRoute
}
-const ApiUsersServerRouteChildren: ApiUsersServerRouteChildren = {
- ApiUsersUserIdServerRoute: ApiUsersUserIdServerRoute,
+const ApiUsersRouteChildren: ApiUsersRouteChildren = {
+ ApiUsersUserIdRoute: ApiUsersUserIdRoute,
}
-const ApiUsersServerRouteWithChildren = ApiUsersServerRoute._addFileChildren(
- ApiUsersServerRouteChildren,
+const ApiUsersRouteWithChildren = ApiUsersRoute._addFileChildren(
+ ApiUsersRouteChildren,
)
const rootRouteChildren: RootRouteChildren = {
@@ -306,14 +287,9 @@ const rootRouteChildren: RootRouteChildren = {
DeferredRoute: DeferredRoute,
PostsRoute: PostsRouteWithChildren,
UsersRoute: UsersRouteWithChildren,
+ ApiUsersRoute: ApiUsersRouteWithChildren,
PostsPostIdDeepRoute: PostsPostIdDeepRoute,
}
export const routeTree = rootRouteImport
._addFileChildren(rootRouteChildren)
._addFileTypes()
-const rootServerRouteChildren: RootServerRouteChildren = {
- ApiUsersServerRoute: ApiUsersServerRouteWithChildren,
-}
-export const serverRouteTree = rootServerRouteImport
- ._addFileChildren(rootServerRouteChildren)
- ._addFileTypes()
diff --git a/e2e/solid-start/custom-basepath/src/routes/api/users.$userId.ts b/e2e/solid-start/custom-basepath/src/routes/api/users.$userId.ts
index a653b39ee0..79f89ea0d0 100644
--- a/e2e/solid-start/custom-basepath/src/routes/api/users.$userId.ts
+++ b/e2e/solid-start/custom-basepath/src/routes/api/users.$userId.ts
@@ -1,4 +1,5 @@
-import { createServerFileRoute } from '@tanstack/solid-start/server'
+import { createFileRoute } from '@tanstack/solid-router'
+import { createFileRoute } from '@tanstack/react-router'
import { json } from '@tanstack/solid-start'
import type { User } from '~/utils/users'
@@ -8,25 +9,27 @@ if (import.meta.env.VITE_NODE_ENV === 'test') {
queryURL = `http://localhost:${import.meta.env.VITE_EXTERNAL_PORT}`
}
-export const ServerRoute = createServerFileRoute('/api/users/$userId').methods({
- GET: async ({ params, request }) => {
- console.info(`Fetching users by id=${params.userId}... @`, request.url)
- try {
- const res = await fetch(`${queryURL}/users/${params.userId}`)
- if (!res.ok) {
- throw new Error('Failed to fetch user')
- }
-
- const user = (await res.json()) as User
-
- return json({
- id: user.id,
- name: user.name,
- email: user.email,
- })
- } catch (e) {
- console.error(e)
- return json({ error: 'User not found' }, { status: 404 })
- }
+export const Route = createFileRoute('/api/users/$userId')({
+ server: {
+ handlers: {
+ GET: async ({ params, request }) => {
+ console.info(`Fetching users by id=${params.userId}... @`, request.url)
+ try {
+ const res = await fetch(`${queryURL}/users/${params.userId}`)
+ if (!res.ok) {
+ throw new Error('Failed to fetch user')
+ }
+ const user = (await res.json()) as User
+ return json({
+ id: user.id,
+ name: user.name,
+ email: user.email,
+ })
+ } catch (e) {
+ console.error(e)
+ return json({ error: 'User not found' }, { status: 404 })
+ }
+ },
+ },
},
})
diff --git a/e2e/solid-start/custom-basepath/src/routes/api/users.ts b/e2e/solid-start/custom-basepath/src/routes/api/users.ts
index c8d04ac2f2..04aec562e1 100644
--- a/e2e/solid-start/custom-basepath/src/routes/api/users.ts
+++ b/e2e/solid-start/custom-basepath/src/routes/api/users.ts
@@ -1,8 +1,8 @@
-import { createServerFileRoute } from '@tanstack/solid-start/server'
+import { createFileRoute } from '@tanstack/solid-router'
import { createMiddleware, json } from '@tanstack/solid-start'
import type { User } from '~/utils/users'
-const userLoggerMiddleware = createMiddleware({ type: 'request' }).server(
+const userLoggerMiddleware = createMiddleware().server(
async ({ next, request }) => {
console.info('In: /users')
const result = await next()
@@ -12,7 +12,7 @@ const userLoggerMiddleware = createMiddleware({ type: 'request' }).server(
},
)
-const testParentMiddleware = createMiddleware({ type: 'request' }).server(
+const testParentMiddleware = createMiddleware().server(
async ({ next, request }) => {
console.info('In: testParentMiddleware')
const result = await next()
@@ -22,20 +22,18 @@ const testParentMiddleware = createMiddleware({ type: 'request' }).server(
},
)
-const testMiddleware = createMiddleware({ type: 'request' })
+const testMiddleware = createMiddleware()
.middleware([testParentMiddleware])
.server(async ({ next, request }) => {
console.info('In: testMiddleware')
const result = await next()
result.response.headers.set('x-test', 'true')
-
// if (Math.random() > 0.5) {
// throw new Response(null, {
// status: 302,
// headers: { Location: 'https://www.google.com' },
// })
// }
-
console.info('Out: testMiddleware')
return result
})
@@ -46,20 +44,22 @@ if (import.meta.env.VITE_NODE_ENV === 'test') {
queryURL = `http://localhost:${import.meta.env.VITE_EXTERNAL_PORT}`
}
-export const ServerRoute = createServerFileRoute('/api/users')
- .middleware([testMiddleware, userLoggerMiddleware, testParentMiddleware])
- .methods({
- GET: async ({ request }) => {
- console.info('Fetching users... @', request.url)
- const res = await fetch(`${queryURL}/users`)
- if (!res.ok) {
- throw new Error('Failed to fetch users')
- }
-
- const data = (await res.json()) as Array
-
- const list = data.slice(0, 10)
-
- return json(list.map((u) => ({ id: u.id, name: u.name, email: u.email })))
+export const Route = createFileRoute('/api/users')({
+ server: {
+ middleware: [testMiddleware, userLoggerMiddleware, testParentMiddleware],
+ handlers: {
+ GET: async ({ request }) => {
+ console.info('Fetching users... @', request.url)
+ const res = await fetch(`${queryURL}/users`)
+ if (!res.ok) {
+ throw new Error('Failed to fetch users')
+ }
+ const data = (await res.json()) as Array
+ const list = data.slice(0, 10)
+ return json(
+ list.map((u) => ({ id: u.id, name: u.name, email: u.email })),
+ )
+ },
},
- })
+ },
+})
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/src/routeTree.gen.ts b/e2e/solid-start/server-routes/src/routeTree.gen.ts
index 17ffa3450c..36410e9bf9 100644
--- a/e2e/solid-start/server-routes/src/routeTree.gen.ts
+++ b/e2e/solid-start/server-routes/src/routeTree.gen.ts
@@ -8,14 +8,10 @@
// 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/solid-start/server'
-
import { Route as rootRouteImport } from './routes/__root'
import { Route as MergeServerFnMiddlewareContextRouteImport } from './routes/merge-server-fn-middleware-context'
import { Route as IndexRouteImport } from './routes/index'
-import { ServerRoute as ApiMiddlewareContextServerRouteImport } from './routes/api/middleware-context'
-
-const rootServerRouteImport = createServerRootRoute()
+import { Route as ApiMiddlewareContextRouteImport } from './routes/api/middleware-context'
const MergeServerFnMiddlewareContextRoute =
MergeServerFnMiddlewareContextRouteImport.update({
@@ -28,58 +24,47 @@ const IndexRoute = IndexRouteImport.update({
path: '/',
getParentRoute: () => rootRouteImport,
} as any)
-const ApiMiddlewareContextServerRoute =
- ApiMiddlewareContextServerRouteImport.update({
- id: '/api/middleware-context',
- path: '/api/middleware-context',
- getParentRoute: () => rootServerRouteImport,
- } as any)
+const ApiMiddlewareContextRoute = ApiMiddlewareContextRouteImport.update({
+ id: '/api/middleware-context',
+ path: '/api/middleware-context',
+ getParentRoute: () => rootRouteImport,
+} as any)
export interface FileRoutesByFullPath {
'/': typeof IndexRoute
'/merge-server-fn-middleware-context': typeof MergeServerFnMiddlewareContextRoute
+ '/api/middleware-context': typeof ApiMiddlewareContextRoute
}
export interface FileRoutesByTo {
'/': typeof IndexRoute
'/merge-server-fn-middleware-context': typeof MergeServerFnMiddlewareContextRoute
+ '/api/middleware-context': typeof ApiMiddlewareContextRoute
}
export interface FileRoutesById {
__root__: typeof rootRouteImport
'/': typeof IndexRoute
'/merge-server-fn-middleware-context': typeof MergeServerFnMiddlewareContextRoute
+ '/api/middleware-context': typeof ApiMiddlewareContextRoute
}
export interface FileRouteTypes {
fileRoutesByFullPath: FileRoutesByFullPath
- fullPaths: '/' | '/merge-server-fn-middleware-context'
+ fullPaths:
+ | '/'
+ | '/merge-server-fn-middleware-context'
+ | '/api/middleware-context'
fileRoutesByTo: FileRoutesByTo
- to: '/' | '/merge-server-fn-middleware-context'
- id: '__root__' | '/' | '/merge-server-fn-middleware-context'
+ to: '/' | '/merge-server-fn-middleware-context' | '/api/middleware-context'
+ id:
+ | '__root__'
+ | '/'
+ | '/merge-server-fn-middleware-context'
+ | '/api/middleware-context'
fileRoutesById: FileRoutesById
}
export interface RootRouteChildren {
IndexRoute: typeof IndexRoute
MergeServerFnMiddlewareContextRoute: typeof MergeServerFnMiddlewareContextRoute
-}
-export interface FileServerRoutesByFullPath {
- '/api/middleware-context': typeof ApiMiddlewareContextServerRoute
-}
-export interface FileServerRoutesByTo {
- '/api/middleware-context': typeof ApiMiddlewareContextServerRoute
-}
-export interface FileServerRoutesById {
- __root__: typeof rootServerRouteImport
- '/api/middleware-context': typeof ApiMiddlewareContextServerRoute
-}
-export interface FileServerRouteTypes {
- fileServerRoutesByFullPath: FileServerRoutesByFullPath
- fullPaths: '/api/middleware-context'
- fileServerRoutesByTo: FileServerRoutesByTo
- to: '/api/middleware-context'
- id: '__root__' | '/api/middleware-context'
- fileServerRoutesById: FileServerRoutesById
-}
-export interface RootServerRouteChildren {
- ApiMiddlewareContextServerRoute: typeof ApiMiddlewareContextServerRoute
+ ApiMiddlewareContextRoute: typeof ApiMiddlewareContextRoute
}
declare module '@tanstack/solid-router' {
@@ -98,16 +83,12 @@ declare module '@tanstack/solid-router' {
preLoaderRoute: typeof IndexRouteImport
parentRoute: typeof rootRouteImport
}
- }
-}
-declare module '@tanstack/solid-start/server' {
- interface ServerFileRoutesByPath {
'/api/middleware-context': {
id: '/api/middleware-context'
path: '/api/middleware-context'
fullPath: '/api/middleware-context'
- preLoaderRoute: typeof ApiMiddlewareContextServerRouteImport
- parentRoute: typeof rootServerRouteImport
+ preLoaderRoute: typeof ApiMiddlewareContextRouteImport
+ parentRoute: typeof rootRouteImport
}
}
}
@@ -115,13 +96,8 @@ declare module '@tanstack/solid-start/server' {
const rootRouteChildren: RootRouteChildren = {
IndexRoute: IndexRoute,
MergeServerFnMiddlewareContextRoute: MergeServerFnMiddlewareContextRoute,
+ ApiMiddlewareContextRoute: ApiMiddlewareContextRoute,
}
export const routeTree = rootRouteImport
._addFileChildren(rootRouteChildren)
._addFileTypes()
-const rootServerRouteChildren: RootServerRouteChildren = {
- ApiMiddlewareContextServerRoute: ApiMiddlewareContextServerRoute,
-}
-export const serverRouteTree = rootServerRouteImport
- ._addFileChildren(rootServerRouteChildren)
- ._addFileTypes()
diff --git a/e2e/solid-start/server-routes/src/routes/api/middleware-context.ts b/e2e/solid-start/server-routes/src/routes/api/middleware-context.ts
index ef33834594..eba284cf19 100644
--- a/e2e/solid-start/server-routes/src/routes/api/middleware-context.ts
+++ b/e2e/solid-start/server-routes/src/routes/api/middleware-context.ts
@@ -1,28 +1,30 @@
-import { createServerFileRoute } from '@tanstack/solid-start/server'
+import { createFileRoute } from '@tanstack/solid-router'
+import { createFileRoute } from '@tanstack/react-router'
import { createMiddleware, json } from '@tanstack/solid-start'
-const testParentMiddleware = createMiddleware({ type: 'request' }).server(
- async ({ next }) => {
- const result = await next({ context: { testParent: true } })
- return result
- },
-)
+const testParentMiddleware = createMiddleware().server(async ({ next }) => {
+ const result = await next({ context: { testParent: true } })
+ return result
+})
-const testMiddleware = createMiddleware({ type: 'request' })
+const testMiddleware = createMiddleware()
.middleware([testParentMiddleware])
.server(async ({ next }) => {
const result = await next({ context: { test: true } })
return result
})
-export const ServerRoute = createServerFileRoute('/api/middleware-context')
- .middleware([testMiddleware])
- .methods({
- GET: ({ request, context }) => {
- return json({
- url: request.url,
- context: context,
- expectedContext: { testParent: true, test: true },
- })
+export const Route = createFileRoute('/api/middleware-context')({
+ server: {
+ middleware: [testMiddleware],
+ handlers: {
+ GET: ({ request, context }) => {
+ return json({
+ url: request.url,
+ context: context,
+ expectedContext: { testParent: true, test: true },
+ })
+ },
},
- })
+ },
+})
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..cca364824c 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.16",
+ "@tanstack/react-router-devtools": "^1.132.0-alpha.16",
+ "@tanstack/router-plugin": "^1.132.0-alpha.16",
"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..5c0b1691fa 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.16",
+ "@tanstack/react-router-devtools": "^1.132.0-alpha.16",
+ "@tanstack/router-plugin": "^1.132.0-alpha.16",
"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..c22dc6fa37 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.16",
+ "@tanstack/react-router-devtools": "^1.132.0-alpha.16",
"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..5e064b3caa 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.16",
+ "@tanstack/react-router-devtools": "^1.132.0-alpha.16",
"@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..9277927bca 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.16",
+ "@tanstack/react-router-devtools": "^1.132.0-alpha.16",
+ "@tanstack/router-plugin": "^1.132.0-alpha.16",
"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..9a75fdaf3d 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.16",
+ "@tanstack/react-router-devtools": "^1.132.0-alpha.16",
"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..1280ad7401 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.16",
+ "@tanstack/react-router-devtools": "^1.132.0-alpha.16",
+ "@tanstack/router-plugin": "^1.132.0-alpha.16",
"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..9c09531281 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.16",
+ "@tanstack/react-router-devtools": "^1.132.0-alpha.16",
"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..0ec7a2312d 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.16",
+ "@tanstack/router-plugin": "^1.132.0-alpha.16",
"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.16",
"@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..2265755ae9 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.16",
+ "@tanstack/router-plugin": "^1.132.0-alpha.16",
"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.16",
"@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..c416011889 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.16",
+ "@tanstack/react-router-devtools": "^1.132.0-alpha.16",
+ "@tanstack/router-plugin": "^1.132.0-alpha.16",
+ "@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-file-based/src/routeTree.gen.ts b/examples/react/basic-virtual-file-based/src/routeTree.gen.ts
index b016b0f33f..dc243ae857 100644
--- a/examples/react/basic-virtual-file-based/src/routeTree.gen.ts
+++ b/examples/react/basic-virtual-file-based/src/routeTree.gen.ts
@@ -168,11 +168,11 @@ export interface RootRouteChildren {
declare module '@tanstack/react-router' {
interface FileRoutesByPath {
- '/': {
- id: '/'
- path: '/'
- fullPath: '/'
- preLoaderRoute: typeof homeRouteImport
+ '/posts': {
+ id: '/posts'
+ path: '/posts'
+ fullPath: '/posts'
+ preLoaderRoute: typeof postsPostsRouteImport
parentRoute: typeof rootRouteImport
}
'/_first': {
@@ -182,25 +182,18 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof layoutFirstLayoutRouteImport
parentRoute: typeof rootRouteImport
}
- '/posts': {
- id: '/posts'
- path: '/posts'
- fullPath: '/posts'
- preLoaderRoute: typeof postsPostsRouteImport
- parentRoute: typeof rootRouteImport
- }
- '/classic/hello': {
- id: '/classic/hello'
- path: '/classic/hello'
- fullPath: '/classic/hello'
- preLoaderRoute: typeof ClassicHelloRouteRouteImport
- parentRoute: typeof rootRouteImport
- }
- '/posts/': {
- id: '/posts/'
+ '/': {
+ id: '/'
path: '/'
- fullPath: '/posts/'
- preLoaderRoute: typeof postsPostsHomeRouteImport
+ fullPath: '/'
+ preLoaderRoute: typeof homeRouteImport
+ parentRoute: typeof rootRouteImport
+ }
+ '/posts/$postId': {
+ id: '/posts/$postId'
+ path: '/$postId'
+ fullPath: '/posts/$postId'
+ preLoaderRoute: typeof postsPostsDetailRouteImport
parentRoute: typeof postsPostsRoute
}
'/_first/_second-layout': {
@@ -210,18 +203,25 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof layoutSecondLayoutRouteImport
parentRoute: typeof layoutFirstLayoutRoute
}
- '/posts/$postId': {
- id: '/posts/$postId'
- path: '/$postId'
- fullPath: '/posts/$postId'
- preLoaderRoute: typeof postsPostsDetailRouteImport
+ '/posts/': {
+ id: '/posts/'
+ path: '/'
+ fullPath: '/posts/'
+ preLoaderRoute: typeof postsPostsHomeRouteImport
parentRoute: typeof postsPostsRoute
}
- '/classic/hello/universe': {
- id: '/classic/hello/universe'
- path: '/universe'
- fullPath: '/classic/hello/universe'
- preLoaderRoute: typeof ClassicHelloUniverseRouteImport
+ '/classic/hello': {
+ id: '/classic/hello'
+ path: '/classic/hello'
+ fullPath: '/classic/hello'
+ preLoaderRoute: typeof ClassicHelloRouteRouteImport
+ parentRoute: typeof rootRouteImport
+ }
+ '/classic/hello/': {
+ id: '/classic/hello/'
+ path: '/'
+ fullPath: '/classic/hello/'
+ preLoaderRoute: typeof ClassicHelloIndexRouteImport
parentRoute: typeof ClassicHelloRouteRoute
}
'/classic/hello/world': {
@@ -231,20 +231,13 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof ClassicHelloWorldRouteImport
parentRoute: typeof ClassicHelloRouteRoute
}
- '/classic/hello/': {
- id: '/classic/hello/'
- path: '/'
- fullPath: '/classic/hello/'
- preLoaderRoute: typeof ClassicHelloIndexRouteImport
+ '/classic/hello/universe': {
+ id: '/classic/hello/universe'
+ path: '/universe'
+ fullPath: '/classic/hello/universe'
+ preLoaderRoute: typeof ClassicHelloUniverseRouteImport
parentRoute: typeof ClassicHelloRouteRoute
}
- '/_first/_second-layout/route-without-file/layout-a': {
- id: '/_first/_second-layout/route-without-file/layout-a'
- path: '/route-without-file/layout-a'
- fullPath: '/route-without-file/layout-a'
- preLoaderRoute: typeof aRouteImport
- parentRoute: typeof layoutSecondLayoutRoute
- }
'/_first/_second-layout/route-without-file/layout-b': {
id: '/_first/_second-layout/route-without-file/layout-b'
path: '/route-without-file/layout-b'
@@ -252,6 +245,13 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof bRouteImport
parentRoute: typeof layoutSecondLayoutRoute
}
+ '/_first/_second-layout/route-without-file/layout-a': {
+ id: '/_first/_second-layout/route-without-file/layout-a'
+ path: '/route-without-file/layout-a'
+ fullPath: '/route-without-file/layout-a'
+ preLoaderRoute: typeof aRouteImport
+ parentRoute: typeof layoutSecondLayoutRoute
+ }
}
}
diff --git a/examples/react/basic-virtual-inside-file-based/package.json b/examples/react/basic-virtual-inside-file-based/package.json
index 2bea5afad5..67ef89992d 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.16",
+ "@tanstack/react-router-devtools": "^1.132.0-alpha.16",
+ "@tanstack/router-plugin": "^1.132.0-alpha.16",
+ "@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/src/routeTree.gen.ts b/examples/react/basic-virtual-inside-file-based/src/routeTree.gen.ts
index 861887e7db..2d3afb4983 100644
--- a/examples/react/basic-virtual-inside-file-based/src/routeTree.gen.ts
+++ b/examples/react/basic-virtual-inside-file-based/src/routeTree.gen.ts
@@ -145,11 +145,11 @@ export interface RootRouteChildren {
declare module '@tanstack/react-router' {
interface FileRoutesByPath {
- '/': {
- id: '/'
- path: '/'
- fullPath: '/'
- preLoaderRoute: typeof IndexRouteImport
+ '/posts': {
+ id: '/posts'
+ path: '/posts'
+ fullPath: '/posts'
+ preLoaderRoute: typeof PostsRouteImport
parentRoute: typeof rootRouteImport
}
'/_layout': {
@@ -159,18 +159,18 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof LayoutRouteImport
parentRoute: typeof rootRouteImport
}
- '/posts': {
- id: '/posts'
- path: '/posts'
- fullPath: '/posts'
- preLoaderRoute: typeof PostsRouteImport
+ '/': {
+ id: '/'
+ path: '/'
+ fullPath: '/'
+ preLoaderRoute: typeof IndexRouteImport
parentRoute: typeof rootRouteImport
}
- '/posts/': {
- id: '/posts/'
- path: '/'
- fullPath: '/posts/'
- preLoaderRoute: typeof postsHomeRouteImport
+ '/posts/$postId': {
+ id: '/posts/$postId'
+ path: '/$postId'
+ fullPath: '/posts/$postId'
+ preLoaderRoute: typeof postsDetailsRouteImport
parentRoute: typeof PostsRoute
}
'/_layout/_layout-2': {
@@ -180,19 +180,19 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof LayoutLayout2RouteImport
parentRoute: typeof LayoutRoute
}
- '/posts/$postId': {
- id: '/posts/$postId'
- path: '/$postId'
- fullPath: '/posts/$postId'
- preLoaderRoute: typeof postsDetailsRouteImport
+ '/posts/': {
+ id: '/posts/'
+ path: '/'
+ fullPath: '/posts/'
+ preLoaderRoute: typeof postsHomeRouteImport
parentRoute: typeof PostsRoute
}
- '/_layout/_layout-2/layout-a': {
- id: '/_layout/_layout-2/layout-a'
- path: '/layout-a'
- fullPath: '/layout-a'
- preLoaderRoute: typeof LayoutLayout2LayoutARouteImport
- parentRoute: typeof LayoutLayout2Route
+ '/posts/inception/': {
+ id: '/posts/inception/'
+ path: '/inception'
+ fullPath: '/posts/inception'
+ preLoaderRoute: typeof postsLetsGoIndexRouteImport
+ parentRoute: typeof PostsRoute
}
'/_layout/_layout-2/layout-b': {
id: '/_layout/_layout-2/layout-b'
@@ -201,12 +201,12 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof LayoutLayout2LayoutBRouteImport
parentRoute: typeof LayoutLayout2Route
}
- '/posts/inception/': {
- id: '/posts/inception/'
- path: '/inception'
- fullPath: '/posts/inception'
- preLoaderRoute: typeof postsLetsGoIndexRouteImport
- parentRoute: typeof PostsRoute
+ '/_layout/_layout-2/layout-a': {
+ id: '/_layout/_layout-2/layout-a'
+ path: '/layout-a'
+ fullPath: '/layout-a'
+ preLoaderRoute: typeof LayoutLayout2LayoutARouteImport
+ parentRoute: typeof LayoutLayout2Route
}
'/posts/inception/deeper/': {
id: '/posts/inception/deeper/'
diff --git a/examples/react/basic/package.json b/examples/react/basic/package.json
index 17e33d6a3b..c0694bea00 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.16",
+ "@tanstack/react-router-devtools": "^1.132.0-alpha.16",
"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..f676e6a04b 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.16",
+ "@tanstack/react-router-devtools": "^1.132.0-alpha.16",
"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..561162308c 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.16",
+ "@tanstack/react-router-devtools": "^1.132.0-alpha.16",
+ "@tanstack/router-plugin": "^1.132.0-alpha.16",
"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..d008d3974d 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.16",
+ "@tanstack/react-router-devtools": "^1.132.0-alpha.16",
+ "@tanstack/router-plugin": "^1.132.0-alpha.16",
"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..15f9688e9e 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.16",
+ "@tanstack/react-router-devtools": "^1.132.0-alpha.16",
"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..796b22d57e 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.16",
+ "@tanstack/react-router-devtools": "^1.132.0-alpha.16",
"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..c1e71e4510 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.16",
+ "@tanstack/react-router-devtools": "^1.132.0-alpha.16",
+ "@tanstack/router-plugin": "^1.132.0-alpha.16",
"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..1193092774 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.16",
+ "@tanstack/react-router-devtools": "^1.132.0-alpha.16",
"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..790ceda0a5 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.16",
+ "@tanstack/react-router-devtools": "^1.132.0-alpha.16",
"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..9edd98b7d6 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.16",
+ "@tanstack/react-router-devtools": "^1.132.0-alpha.16",
+ "@tanstack/router-plugin": "^1.132.0-alpha.16",
"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..143049b62f 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.16",
+ "@tanstack/react-router-devtools": "^1.132.0-alpha.16",
+ "@tanstack/router-plugin": "^1.132.0-alpha.16",
"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..31ef142e76 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.16",
+ "@tanstack/react-router-devtools": "^1.132.0-alpha.16",
"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.16",
"@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..9e31afc36a 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.16",
+ "@tanstack/react-router-devtools": "^1.132.0-alpha.16",
"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.16",
"@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..5a1b753e8e 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.16",
+ "@tanstack/react-router-devtools": "^1.132.0-alpha.16",
"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..b7ef5299ed 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.16",
+ "@tanstack/react-router-devtools": "^1.132.0-alpha.16",
+ "@tanstack/router-plugin": "^1.132.0-alpha.16",
"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..05c292bb52 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.16",
"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..439d7ffd5c 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.16",
+ "@tanstack/router-plugin": "^1.132.0-alpha.16",
"@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..bc4f28ea3e 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.16",
+ "@tanstack/react-router-devtools": "^1.132.0-alpha.16",
+ "@tanstack/router-plugin": "^1.132.0-alpha.16",
"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..0bd7168af1 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.16",
"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..dd220b64bf 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.16",
+ "@tanstack/router-plugin": "^1.132.0-alpha.16",
"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..24c72be5c6 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.16",
+ "@tanstack/react-router-devtools": "^1.132.0-alpha.16",
+ "@tanstack/router-plugin": "^1.132.0-alpha.16",
"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..5f9fdce472 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.16",
+ "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..06b4e659b0 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.16",
+ "@tanstack/router-plugin": "^1.132.0-alpha.16",
"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..730fcfbdbf 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.16",
"@tanstack/react-virtual": "^3.13.0",
- "@tanstack/react-router-devtools": "^1.131.27",
+ "@tanstack/react-router-devtools": "^1.132.0-alpha.16",
"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..d87bb0e321 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.16",
"@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.16",
+ "@tanstack/react-router-devtools": "^1.132.0-alpha.16",
+ "@tanstack/router-plugin": "^1.132.0-alpha.16",
+ "@tanstack/valibot-adapter": "^1.132.0-alpha.16",
+ "@tanstack/zod-adapter": "^1.132.0-alpha.16",
"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/search-validator-adapters/src/routeTree.gen.ts b/examples/react/search-validator-adapters/src/routeTree.gen.ts
index da0a7b2118..3312abe25e 100644
--- a/examples/react/search-validator-adapters/src/routeTree.gen.ts
+++ b/examples/react/search-validator-adapters/src/routeTree.gen.ts
@@ -80,11 +80,11 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof IndexRouteImport
parentRoute: typeof rootRouteImport
}
- '/users/arktype/': {
- id: '/users/arktype/'
- path: '/users/arktype'
- fullPath: '/users/arktype'
- preLoaderRoute: typeof UsersArktypeIndexRouteImport
+ '/users/zod/': {
+ id: '/users/zod/'
+ path: '/users/zod'
+ fullPath: '/users/zod'
+ preLoaderRoute: typeof UsersZodIndexRouteImport
parentRoute: typeof rootRouteImport
}
'/users/valibot/': {
@@ -94,11 +94,11 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof UsersValibotIndexRouteImport
parentRoute: typeof rootRouteImport
}
- '/users/zod/': {
- id: '/users/zod/'
- path: '/users/zod'
- fullPath: '/users/zod'
- preLoaderRoute: typeof UsersZodIndexRouteImport
+ '/users/arktype/': {
+ id: '/users/arktype/'
+ path: '/users/arktype'
+ fullPath: '/users/arktype'
+ preLoaderRoute: typeof UsersArktypeIndexRouteImport
parentRoute: typeof rootRouteImport
}
}
diff --git a/examples/react/start-bare/package.json b/examples/react/start-bare/package.json
index 08e46031e5..8c7cf0292b 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.16",
+ "@tanstack/react-router-devtools": "^1.132.0-alpha.16",
+ "@tanstack/react-start": "^1.132.0-alpha.17",
"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..af5d59ff95 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.16",
+ "@tanstack/react-router-devtools": "^1.132.0-alpha.16",
+ "@tanstack/react-start": "^1.132.0-alpha.17",
"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..248ff3b79e 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.16",
+ "@tanstack/react-router-ssr-query": "^1.132.0-alpha.16",
+ "@tanstack/react-router-devtools": "^1.132.0-alpha.16",
+ "@tanstack/react-start": "^1.132.0-alpha.17",
"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/src/routeTree.gen.ts b/examples/react/start-basic-react-query/src/routeTree.gen.ts
index a16228badb..a94ae0ade8 100644
--- a/examples/react/start-basic-react-query/src/routeTree.gen.ts
+++ b/examples/react/start-basic-react-query/src/routeTree.gen.ts
@@ -8,8 +8,6 @@
// 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 RedirectRouteImport } from './routes/redirect'
import { Route as DeferredRouteImport } from './routes/deferred'
@@ -21,14 +19,12 @@ import { Route as UsersIndexRouteImport } from './routes/users.index'
import { Route as PostsIndexRouteImport } from './routes/posts.index'
import { Route as UsersUserIdRouteImport } from './routes/users.$userId'
import { Route as PostsPostIdRouteImport } from './routes/posts.$postId'
+import { Route as ApiUsersRouteImport } from './routes/api/users'
import { Route as PathlessLayoutNestedLayoutRouteImport } from './routes/_pathlessLayout/_nested-layout'
import { Route as PostsPostIdDeepRouteImport } from './routes/posts_.$postId.deep'
+import { Route as ApiUsersIdRouteImport } from './routes/api/users.$id'
import { Route as PathlessLayoutNestedLayoutRouteBRouteImport } from './routes/_pathlessLayout/_nested-layout/route-b'
import { Route as PathlessLayoutNestedLayoutRouteARouteImport } from './routes/_pathlessLayout/_nested-layout/route-a'
-import { ServerRoute as ApiUsersServerRouteImport } from './routes/api.users'
-import { ServerRoute as ApiUsersIdServerRouteImport } from './routes/api/users.$id'
-
-const rootServerRouteImport = createServerRootRoute()
const RedirectRoute = RedirectRouteImport.update({
id: '/redirect',
@@ -79,6 +75,11 @@ const PostsPostIdRoute = PostsPostIdRouteImport.update({
path: '/$postId',
getParentRoute: () => PostsRouteRoute,
} as any)
+const ApiUsersRoute = ApiUsersRouteImport.update({
+ id: '/api/users',
+ path: '/api/users',
+ getParentRoute: () => rootRouteImport,
+} as any)
const PathlessLayoutNestedLayoutRoute =
PathlessLayoutNestedLayoutRouteImport.update({
id: '/_nested-layout',
@@ -89,6 +90,11 @@ const PostsPostIdDeepRoute = PostsPostIdDeepRouteImport.update({
path: '/posts/$postId/deep',
getParentRoute: () => rootRouteImport,
} as any)
+const ApiUsersIdRoute = ApiUsersIdRouteImport.update({
+ id: '/$id',
+ path: '/$id',
+ getParentRoute: () => ApiUsersRoute,
+} as any)
const PathlessLayoutNestedLayoutRouteBRoute =
PathlessLayoutNestedLayoutRouteBRouteImport.update({
id: '/route-b',
@@ -101,16 +107,6 @@ const PathlessLayoutNestedLayoutRouteARoute =
path: '/route-a',
getParentRoute: () => PathlessLayoutNestedLayoutRoute,
} as any)
-const ApiUsersServerRoute = ApiUsersServerRouteImport.update({
- id: '/api/users',
- path: '/api/users',
- getParentRoute: () => rootServerRouteImport,
-} as any)
-const ApiUsersIdServerRoute = ApiUsersIdServerRouteImport.update({
- id: '/$id',
- path: '/$id',
- getParentRoute: () => ApiUsersServerRoute,
-} as any)
export interface FileRoutesByFullPath {
'/': typeof IndexRoute
@@ -118,24 +114,28 @@ export interface FileRoutesByFullPath {
'/users': typeof UsersRouteRouteWithChildren
'/deferred': typeof DeferredRoute
'/redirect': typeof RedirectRoute
+ '/api/users': typeof ApiUsersRouteWithChildren
'/posts/$postId': typeof PostsPostIdRoute
'/users/$userId': typeof UsersUserIdRoute
'/posts/': typeof PostsIndexRoute
'/users/': typeof UsersIndexRoute
'/route-a': typeof PathlessLayoutNestedLayoutRouteARoute
'/route-b': typeof PathlessLayoutNestedLayoutRouteBRoute
+ '/api/users/$id': typeof ApiUsersIdRoute
'/posts/$postId/deep': typeof PostsPostIdDeepRoute
}
export interface FileRoutesByTo {
'/': typeof IndexRoute
'/deferred': typeof DeferredRoute
'/redirect': typeof RedirectRoute
+ '/api/users': typeof ApiUsersRouteWithChildren
'/posts/$postId': typeof PostsPostIdRoute
'/users/$userId': typeof UsersUserIdRoute
'/posts': typeof PostsIndexRoute
'/users': typeof UsersIndexRoute
'/route-a': typeof PathlessLayoutNestedLayoutRouteARoute
'/route-b': typeof PathlessLayoutNestedLayoutRouteBRoute
+ '/api/users/$id': typeof ApiUsersIdRoute
'/posts/$postId/deep': typeof PostsPostIdDeepRoute
}
export interface FileRoutesById {
@@ -147,12 +147,14 @@ export interface FileRoutesById {
'/deferred': typeof DeferredRoute
'/redirect': typeof RedirectRoute
'/_pathlessLayout/_nested-layout': typeof PathlessLayoutNestedLayoutRouteWithChildren
+ '/api/users': typeof ApiUsersRouteWithChildren
'/posts/$postId': typeof PostsPostIdRoute
'/users/$userId': typeof UsersUserIdRoute
'/posts/': typeof PostsIndexRoute
'/users/': typeof UsersIndexRoute
'/_pathlessLayout/_nested-layout/route-a': typeof PathlessLayoutNestedLayoutRouteARoute
'/_pathlessLayout/_nested-layout/route-b': typeof PathlessLayoutNestedLayoutRouteBRoute
+ '/api/users/$id': typeof ApiUsersIdRoute
'/posts_/$postId/deep': typeof PostsPostIdDeepRoute
}
export interface FileRouteTypes {
@@ -163,24 +165,28 @@ export interface FileRouteTypes {
| '/users'
| '/deferred'
| '/redirect'
+ | '/api/users'
| '/posts/$postId'
| '/users/$userId'
| '/posts/'
| '/users/'
| '/route-a'
| '/route-b'
+ | '/api/users/$id'
| '/posts/$postId/deep'
fileRoutesByTo: FileRoutesByTo
to:
| '/'
| '/deferred'
| '/redirect'
+ | '/api/users'
| '/posts/$postId'
| '/users/$userId'
| '/posts'
| '/users'
| '/route-a'
| '/route-b'
+ | '/api/users/$id'
| '/posts/$postId/deep'
id:
| '__root__'
@@ -191,12 +197,14 @@ export interface FileRouteTypes {
| '/deferred'
| '/redirect'
| '/_pathlessLayout/_nested-layout'
+ | '/api/users'
| '/posts/$postId'
| '/users/$userId'
| '/posts/'
| '/users/'
| '/_pathlessLayout/_nested-layout/route-a'
| '/_pathlessLayout/_nested-layout/route-b'
+ | '/api/users/$id'
| '/posts_/$postId/deep'
fileRoutesById: FileRoutesById
}
@@ -207,32 +215,9 @@ export interface RootRouteChildren {
PathlessLayoutRoute: typeof PathlessLayoutRouteWithChildren
DeferredRoute: typeof DeferredRoute
RedirectRoute: typeof RedirectRoute
+ ApiUsersRoute: typeof ApiUsersRouteWithChildren
PostsPostIdDeepRoute: typeof PostsPostIdDeepRoute
}
-export interface FileServerRoutesByFullPath {
- '/api/users': typeof ApiUsersServerRouteWithChildren
- '/api/users/$id': typeof ApiUsersIdServerRoute
-}
-export interface FileServerRoutesByTo {
- '/api/users': typeof ApiUsersServerRouteWithChildren
- '/api/users/$id': typeof ApiUsersIdServerRoute
-}
-export interface FileServerRoutesById {
- __root__: typeof rootServerRouteImport
- '/api/users': typeof ApiUsersServerRouteWithChildren
- '/api/users/$id': typeof ApiUsersIdServerRoute
-}
-export interface FileServerRouteTypes {
- fileServerRoutesByFullPath: FileServerRoutesByFullPath
- fullPaths: '/api/users' | '/api/users/$id'
- fileServerRoutesByTo: FileServerRoutesByTo
- to: '/api/users' | '/api/users/$id'
- id: '__root__' | '/api/users' | '/api/users/$id'
- fileServerRoutesById: FileServerRoutesById
-}
-export interface RootServerRouteChildren {
- ApiUsersServerRoute: typeof ApiUsersServerRouteWithChildren
-}
declare module '@tanstack/react-router' {
interface FileRoutesByPath {
@@ -306,6 +291,13 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof PostsPostIdRouteImport
parentRoute: typeof PostsRouteRoute
}
+ '/api/users': {
+ id: '/api/users'
+ path: '/api/users'
+ fullPath: '/api/users'
+ preLoaderRoute: typeof ApiUsersRouteImport
+ parentRoute: typeof rootRouteImport
+ }
'/_pathlessLayout/_nested-layout': {
id: '/_pathlessLayout/_nested-layout'
path: ''
@@ -320,6 +312,13 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof PostsPostIdDeepRouteImport
parentRoute: typeof rootRouteImport
}
+ '/api/users/$id': {
+ id: '/api/users/$id'
+ path: '/$id'
+ fullPath: '/api/users/$id'
+ preLoaderRoute: typeof ApiUsersIdRouteImport
+ parentRoute: typeof ApiUsersRoute
+ }
'/_pathlessLayout/_nested-layout/route-b': {
id: '/_pathlessLayout/_nested-layout/route-b'
path: '/route-b'
@@ -336,24 +335,6 @@ declare module '@tanstack/react-router' {
}
}
}
-declare module '@tanstack/react-start/server' {
- interface ServerFileRoutesByPath {
- '/api/users': {
- id: '/api/users'
- path: '/api/users'
- fullPath: '/api/users'
- preLoaderRoute: typeof ApiUsersServerRouteImport
- parentRoute: typeof rootServerRouteImport
- }
- '/api/users/$id': {
- id: '/api/users/$id'
- path: '/$id'
- fullPath: '/api/users/$id'
- preLoaderRoute: typeof ApiUsersIdServerRouteImport
- parentRoute: typeof ApiUsersServerRoute
- }
- }
-}
interface PostsRouteRouteChildren {
PostsPostIdRoute: typeof PostsPostIdRoute
@@ -413,16 +394,16 @@ const PathlessLayoutRouteWithChildren = PathlessLayoutRoute._addFileChildren(
PathlessLayoutRouteChildren,
)
-interface ApiUsersServerRouteChildren {
- ApiUsersIdServerRoute: typeof ApiUsersIdServerRoute
+interface ApiUsersRouteChildren {
+ ApiUsersIdRoute: typeof ApiUsersIdRoute
}
-const ApiUsersServerRouteChildren: ApiUsersServerRouteChildren = {
- ApiUsersIdServerRoute: ApiUsersIdServerRoute,
+const ApiUsersRouteChildren: ApiUsersRouteChildren = {
+ ApiUsersIdRoute: ApiUsersIdRoute,
}
-const ApiUsersServerRouteWithChildren = ApiUsersServerRoute._addFileChildren(
- ApiUsersServerRouteChildren,
+const ApiUsersRouteWithChildren = ApiUsersRoute._addFileChildren(
+ ApiUsersRouteChildren,
)
const rootRouteChildren: RootRouteChildren = {
@@ -432,14 +413,9 @@ const rootRouteChildren: RootRouteChildren = {
PathlessLayoutRoute: PathlessLayoutRouteWithChildren,
DeferredRoute: DeferredRoute,
RedirectRoute: RedirectRoute,
+ ApiUsersRoute: ApiUsersRouteWithChildren,
PostsPostIdDeepRoute: PostsPostIdDeepRoute,
}
export const routeTree = rootRouteImport
._addFileChildren(rootRouteChildren)
._addFileTypes()
-const rootServerRouteChildren: RootServerRouteChildren = {
- ApiUsersServerRoute: ApiUsersServerRouteWithChildren,
-}
-export const serverRouteTree = rootServerRouteImport
- ._addFileChildren(rootServerRouteChildren)
- ._addFileTypes()
diff --git a/examples/react/start-basic-react-query/src/routes/api.users.ts b/examples/react/start-basic-react-query/src/routes/api.users.ts
deleted file mode 100644
index 8cdcaf76e1..0000000000
--- a/examples/react/start-basic-react-query/src/routes/api.users.ts
+++ /dev/null
@@ -1,17 +0,0 @@
-import { json } from '@tanstack/react-start'
-import { createServerFileRoute } from '@tanstack/react-start/server'
-import axios from 'redaxios'
-import type { User } from '../utils/users'
-
-export const ServerRoute = createServerFileRoute('/api/users').methods({
- GET: async ({ request }) => {
- console.info('Fetching users... @', request.url)
- const res = await axios.get>(
- 'https://jsonplaceholder.typicode.com/users',
- )
-
- const list = res.data.slice(0, 10)
-
- return json(list.map((u) => ({ id: u.id, name: u.name, email: u.email })))
- },
-})
diff --git a/examples/react/start-basic-react-query/src/routes/api/users.$id.ts b/examples/react/start-basic-react-query/src/routes/api/users.$id.ts
index eef27752df..79c38d41a6 100644
--- a/examples/react/start-basic-react-query/src/routes/api/users.$id.ts
+++ b/examples/react/start-basic-react-query/src/routes/api/users.$id.ts
@@ -1,25 +1,27 @@
import { createFileRoute } from '@tanstack/react-router'
import { json } from '@tanstack/react-start'
-import { createServerFileRoute } from '@tanstack/react-start/server'
import axios from 'redaxios'
import type { User } from '../../utils/users'
-export const ServerRoute = createServerFileRoute('/api/users/$id').methods({
- GET: async ({ request, params }) => {
- console.info(`Fetching users by id=${params.id}... @`, request.url)
- try {
- const res = await axios.get(
- 'https://jsonplaceholder.typicode.com/users/' + params.id,
- )
-
- return json({
- id: res.data.id,
- name: res.data.name,
- email: res.data.email,
- })
- } catch (e) {
- console.error(e)
- return json({ error: 'User not found' }, { status: 404 })
- }
+export const Route = createFileRoute('/api/users/$id')({
+ server: {
+ handlers: {
+ GET: async ({ request, params }) => {
+ console.info(`Fetching users by id=${params.id}... @`, request.url)
+ try {
+ const res = await axios.get(
+ 'https://jsonplaceholder.typicode.com/users/' + params.id,
+ )
+ return json({
+ id: res.data.id,
+ name: res.data.name,
+ email: res.data.email,
+ })
+ } catch (e) {
+ console.error(e)
+ return json({ error: 'User not found' }, { status: 404 })
+ }
+ },
+ },
},
})
diff --git a/examples/react/start-basic-react-query/src/routes/api/users.ts b/examples/react/start-basic-react-query/src/routes/api/users.ts
new file mode 100644
index 0000000000..0e290833bb
--- /dev/null
+++ b/examples/react/start-basic-react-query/src/routes/api/users.ts
@@ -0,0 +1,21 @@
+import { createFileRoute } from '@tanstack/react-router'
+import { json } from '@tanstack/react-start'
+import axios from 'redaxios'
+import type { User } from '../../utils/users'
+
+export const Route = createFileRoute('/api/users')({
+ server: {
+ handlers: {
+ GET: async ({ request }) => {
+ console.info('Fetching users... @', request.url)
+ const res = await axios.get>(
+ 'https://jsonplaceholder.typicode.com/users',
+ )
+ const list = res.data.slice(0, 10)
+ return json(
+ list.map((u) => ({ id: u.id, name: u.name, email: u.email })),
+ )
+ },
+ },
+ },
+})
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..9449a8d4f2 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.16",
+ "@tanstack/react-router-devtools": "^1.132.0-alpha.16",
+ "@tanstack/react-start": "^1.132.0-alpha.17",
"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..d484f74420 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.16",
+ "@tanstack/react-router-devtools": "^1.132.0-alpha.16",
+ "@tanstack/react-start": "^1.132.0-alpha.17",
+ "@tanstack/start-static-server-functions": "^1.132.0-alpha.16",
"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..4b699a95c2 100644
--- a/examples/react/start-basic/package.json
+++ b/examples/react/start-basic/package.json
@@ -9,13 +9,14 @@
"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.16",
+ "@tanstack/react-router-devtools": "^1.132.0-alpha.16",
+ "@tanstack/react-start": "^1.132.0-alpha.17",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"tailwind-merge": "^2.6.0",
- "zod": "^3.24.2"
+ "zod": "^3.24.2",
+ "@tanstack/router-core": "^1.132.0-alpha.16"
},
"devDependencies": {
"@types/node": "^22.5.4",
@@ -26,7 +27,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/Foo.ts b/examples/react/start-basic/src/Foo.ts
new file mode 100644
index 0000000000..735151ebe5
--- /dev/null
+++ b/examples/react/start-basic/src/Foo.ts
@@ -0,0 +1,7 @@
+export class Foo {
+ test = 'hello'
+ constructor() {}
+ sayHi() {
+ console.log('hi')
+ }
+}
diff --git a/examples/react/start-basic/src/routeTree.gen.ts b/examples/react/start-basic/src/routeTree.gen.ts
index 9f7ccda018..066ddd4863 100644
--- a/examples/react/start-basic/src/routeTree.gen.ts
+++ b/examples/react/start-basic/src/routeTree.gen.ts
@@ -8,28 +8,24 @@
// 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 UsersRouteImport } from './routes/users'
import { Route as RedirectRouteImport } from './routes/redirect'
import { Route as PostsRouteImport } from './routes/posts'
import { Route as DeferredRouteImport } from './routes/deferred'
+import { Route as CustomScriptDotjsRouteImport } from './routes/customScript[.]js'
import { Route as PathlessLayoutRouteImport } from './routes/_pathlessLayout'
import { Route as IndexRouteImport } from './routes/index'
import { Route as UsersIndexRouteImport } from './routes/users.index'
import { Route as PostsIndexRouteImport } from './routes/posts.index'
import { Route as UsersUserIdRouteImport } from './routes/users.$userId'
import { Route as PostsPostIdRouteImport } from './routes/posts.$postId'
+import { Route as ApiUsersRouteImport } from './routes/api/users'
import { Route as PathlessLayoutNestedLayoutRouteImport } from './routes/_pathlessLayout/_nested-layout'
import { Route as PostsPostIdDeepRouteImport } from './routes/posts_.$postId.deep'
+import { Route as ApiUsersUserIdRouteImport } from './routes/api/users.$userId'
import { Route as PathlessLayoutNestedLayoutRouteBRouteImport } from './routes/_pathlessLayout/_nested-layout/route-b'
import { Route as PathlessLayoutNestedLayoutRouteARouteImport } from './routes/_pathlessLayout/_nested-layout/route-a'
-import { ServerRoute as CustomScriptDotjsServerRouteImport } from './routes/customScript[.]js'
-import { ServerRoute as ApiUsersServerRouteImport } from './routes/api/users'
-import { ServerRoute as ApiUsersUserIdServerRouteImport } from './routes/api/users.$userId'
-
-const rootServerRouteImport = createServerRootRoute()
const UsersRoute = UsersRouteImport.update({
id: '/users',
@@ -51,6 +47,11 @@ const DeferredRoute = DeferredRouteImport.update({
path: '/deferred',
getParentRoute: () => rootRouteImport,
} as any)
+const CustomScriptDotjsRoute = CustomScriptDotjsRouteImport.update({
+ id: '/customScript.js',
+ path: '/customScript.js',
+ getParentRoute: () => rootRouteImport,
+} as any)
const PathlessLayoutRoute = PathlessLayoutRouteImport.update({
id: '/_pathlessLayout',
getParentRoute: () => rootRouteImport,
@@ -80,6 +81,11 @@ const PostsPostIdRoute = PostsPostIdRouteImport.update({
path: '/$postId',
getParentRoute: () => PostsRoute,
} as any)
+const ApiUsersRoute = ApiUsersRouteImport.update({
+ id: '/api/users',
+ path: '/api/users',
+ getParentRoute: () => rootRouteImport,
+} as any)
const PathlessLayoutNestedLayoutRoute =
PathlessLayoutNestedLayoutRouteImport.update({
id: '/_nested-layout',
@@ -90,6 +96,11 @@ const PostsPostIdDeepRoute = PostsPostIdDeepRouteImport.update({
path: '/posts/$postId/deep',
getParentRoute: () => rootRouteImport,
} as any)
+const ApiUsersUserIdRoute = ApiUsersUserIdRouteImport.update({
+ id: '/$userId',
+ path: '/$userId',
+ getParentRoute: () => ApiUsersRoute,
+} as any)
const PathlessLayoutNestedLayoutRouteBRoute =
PathlessLayoutNestedLayoutRouteBRouteImport.update({
id: '/route-b',
@@ -102,147 +113,124 @@ const PathlessLayoutNestedLayoutRouteARoute =
path: '/route-a',
getParentRoute: () => PathlessLayoutNestedLayoutRoute,
} as any)
-const CustomScriptDotjsServerRoute = CustomScriptDotjsServerRouteImport.update({
- id: '/customScript.js',
- path: '/customScript.js',
- getParentRoute: () => rootServerRouteImport,
-} as any)
-const ApiUsersServerRoute = ApiUsersServerRouteImport.update({
- id: '/api/users',
- path: '/api/users',
- getParentRoute: () => rootServerRouteImport,
-} as any)
-const ApiUsersUserIdServerRoute = ApiUsersUserIdServerRouteImport.update({
- id: '/$userId',
- path: '/$userId',
- getParentRoute: () => ApiUsersServerRoute,
-} as any)
export interface FileRoutesByFullPath {
'/': typeof IndexRoute
+ '/customScript.js': typeof CustomScriptDotjsRoute
'/deferred': typeof DeferredRoute
'/posts': typeof PostsRouteWithChildren
'/redirect': typeof RedirectRoute
'/users': typeof UsersRouteWithChildren
+ '/api/users': typeof ApiUsersRouteWithChildren
'/posts/$postId': typeof PostsPostIdRoute
'/users/$userId': typeof UsersUserIdRoute
'/posts/': typeof PostsIndexRoute
'/users/': typeof UsersIndexRoute
'/route-a': typeof PathlessLayoutNestedLayoutRouteARoute
'/route-b': typeof PathlessLayoutNestedLayoutRouteBRoute
+ '/api/users/$userId': typeof ApiUsersUserIdRoute
'/posts/$postId/deep': typeof PostsPostIdDeepRoute
}
export interface FileRoutesByTo {
'/': typeof IndexRoute
+ '/customScript.js': typeof CustomScriptDotjsRoute
'/deferred': typeof DeferredRoute
'/redirect': typeof RedirectRoute
+ '/api/users': typeof ApiUsersRouteWithChildren
'/posts/$postId': typeof PostsPostIdRoute
'/users/$userId': typeof UsersUserIdRoute
'/posts': typeof PostsIndexRoute
'/users': typeof UsersIndexRoute
'/route-a': typeof PathlessLayoutNestedLayoutRouteARoute
'/route-b': typeof PathlessLayoutNestedLayoutRouteBRoute
+ '/api/users/$userId': typeof ApiUsersUserIdRoute
'/posts/$postId/deep': typeof PostsPostIdDeepRoute
}
export interface FileRoutesById {
__root__: typeof rootRouteImport
'/': typeof IndexRoute
'/_pathlessLayout': typeof PathlessLayoutRouteWithChildren
+ '/customScript.js': typeof CustomScriptDotjsRoute
'/deferred': typeof DeferredRoute
'/posts': typeof PostsRouteWithChildren
'/redirect': typeof RedirectRoute
'/users': typeof UsersRouteWithChildren
'/_pathlessLayout/_nested-layout': typeof PathlessLayoutNestedLayoutRouteWithChildren
+ '/api/users': typeof ApiUsersRouteWithChildren
'/posts/$postId': typeof PostsPostIdRoute
'/users/$userId': typeof UsersUserIdRoute
'/posts/': typeof PostsIndexRoute
'/users/': typeof UsersIndexRoute
'/_pathlessLayout/_nested-layout/route-a': typeof PathlessLayoutNestedLayoutRouteARoute
'/_pathlessLayout/_nested-layout/route-b': typeof PathlessLayoutNestedLayoutRouteBRoute
+ '/api/users/$userId': typeof ApiUsersUserIdRoute
'/posts_/$postId/deep': typeof PostsPostIdDeepRoute
}
export interface FileRouteTypes {
fileRoutesByFullPath: FileRoutesByFullPath
fullPaths:
| '/'
+ | '/customScript.js'
| '/deferred'
| '/posts'
| '/redirect'
| '/users'
+ | '/api/users'
| '/posts/$postId'
| '/users/$userId'
| '/posts/'
| '/users/'
| '/route-a'
| '/route-b'
+ | '/api/users/$userId'
| '/posts/$postId/deep'
fileRoutesByTo: FileRoutesByTo
to:
| '/'
+ | '/customScript.js'
| '/deferred'
| '/redirect'
+ | '/api/users'
| '/posts/$postId'
| '/users/$userId'
| '/posts'
| '/users'
| '/route-a'
| '/route-b'
+ | '/api/users/$userId'
| '/posts/$postId/deep'
id:
| '__root__'
| '/'
| '/_pathlessLayout'
+ | '/customScript.js'
| '/deferred'
| '/posts'
| '/redirect'
| '/users'
| '/_pathlessLayout/_nested-layout'
+ | '/api/users'
| '/posts/$postId'
| '/users/$userId'
| '/posts/'
| '/users/'
| '/_pathlessLayout/_nested-layout/route-a'
| '/_pathlessLayout/_nested-layout/route-b'
+ | '/api/users/$userId'
| '/posts_/$postId/deep'
fileRoutesById: FileRoutesById
}
export interface RootRouteChildren {
IndexRoute: typeof IndexRoute
PathlessLayoutRoute: typeof PathlessLayoutRouteWithChildren
+ CustomScriptDotjsRoute: typeof CustomScriptDotjsRoute
DeferredRoute: typeof DeferredRoute
PostsRoute: typeof PostsRouteWithChildren
RedirectRoute: typeof RedirectRoute
UsersRoute: typeof UsersRouteWithChildren
+ ApiUsersRoute: typeof ApiUsersRouteWithChildren
PostsPostIdDeepRoute: typeof PostsPostIdDeepRoute
}
-export interface FileServerRoutesByFullPath {
- '/customScript.js': typeof CustomScriptDotjsServerRoute
- '/api/users': typeof ApiUsersServerRouteWithChildren
- '/api/users/$userId': typeof ApiUsersUserIdServerRoute
-}
-export interface FileServerRoutesByTo {
- '/customScript.js': typeof CustomScriptDotjsServerRoute
- '/api/users': typeof ApiUsersServerRouteWithChildren
- '/api/users/$userId': typeof ApiUsersUserIdServerRoute
-}
-export interface FileServerRoutesById {
- __root__: typeof rootServerRouteImport
- '/customScript.js': typeof CustomScriptDotjsServerRoute
- '/api/users': typeof ApiUsersServerRouteWithChildren
- '/api/users/$userId': typeof ApiUsersUserIdServerRoute
-}
-export interface FileServerRouteTypes {
- fileServerRoutesByFullPath: FileServerRoutesByFullPath
- fullPaths: '/customScript.js' | '/api/users' | '/api/users/$userId'
- fileServerRoutesByTo: FileServerRoutesByTo
- to: '/customScript.js' | '/api/users' | '/api/users/$userId'
- id: '__root__' | '/customScript.js' | '/api/users' | '/api/users/$userId'
- fileServerRoutesById: FileServerRoutesById
-}
-export interface RootServerRouteChildren {
- CustomScriptDotjsServerRoute: typeof CustomScriptDotjsServerRoute
- ApiUsersServerRoute: typeof ApiUsersServerRouteWithChildren
-}
declare module '@tanstack/react-router' {
interface FileRoutesByPath {
@@ -274,6 +262,13 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof DeferredRouteImport
parentRoute: typeof rootRouteImport
}
+ '/customScript.js': {
+ id: '/customScript.js'
+ path: '/customScript.js'
+ fullPath: '/customScript.js'
+ preLoaderRoute: typeof CustomScriptDotjsRouteImport
+ parentRoute: typeof rootRouteImport
+ }
'/_pathlessLayout': {
id: '/_pathlessLayout'
path: ''
@@ -316,6 +311,13 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof PostsPostIdRouteImport
parentRoute: typeof PostsRoute
}
+ '/api/users': {
+ id: '/api/users'
+ path: '/api/users'
+ fullPath: '/api/users'
+ preLoaderRoute: typeof ApiUsersRouteImport
+ parentRoute: typeof rootRouteImport
+ }
'/_pathlessLayout/_nested-layout': {
id: '/_pathlessLayout/_nested-layout'
path: ''
@@ -330,6 +332,13 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof PostsPostIdDeepRouteImport
parentRoute: typeof rootRouteImport
}
+ '/api/users/$userId': {
+ id: '/api/users/$userId'
+ path: '/$userId'
+ fullPath: '/api/users/$userId'
+ preLoaderRoute: typeof ApiUsersUserIdRouteImport
+ parentRoute: typeof ApiUsersRoute
+ }
'/_pathlessLayout/_nested-layout/route-b': {
id: '/_pathlessLayout/_nested-layout/route-b'
path: '/route-b'
@@ -346,31 +355,6 @@ declare module '@tanstack/react-router' {
}
}
}
-declare module '@tanstack/react-start/server' {
- interface ServerFileRoutesByPath {
- '/customScript.js': {
- id: '/customScript.js'
- path: '/customScript.js'
- fullPath: '/customScript.js'
- preLoaderRoute: typeof CustomScriptDotjsServerRouteImport
- parentRoute: typeof rootServerRouteImport
- }
- '/api/users': {
- id: '/api/users'
- path: '/api/users'
- fullPath: '/api/users'
- preLoaderRoute: typeof ApiUsersServerRouteImport
- parentRoute: typeof rootServerRouteImport
- }
- '/api/users/$userId': {
- id: '/api/users/$userId'
- path: '/$userId'
- fullPath: '/api/users/$userId'
- preLoaderRoute: typeof ApiUsersUserIdServerRouteImport
- parentRoute: typeof ApiUsersServerRoute
- }
- }
-}
interface PathlessLayoutNestedLayoutRouteChildren {
PathlessLayoutNestedLayoutRouteARoute: typeof PathlessLayoutNestedLayoutRouteARoute
@@ -426,34 +410,29 @@ const UsersRouteChildren: UsersRouteChildren = {
const UsersRouteWithChildren = UsersRoute._addFileChildren(UsersRouteChildren)
-interface ApiUsersServerRouteChildren {
- ApiUsersUserIdServerRoute: typeof ApiUsersUserIdServerRoute
+interface ApiUsersRouteChildren {
+ ApiUsersUserIdRoute: typeof ApiUsersUserIdRoute
}
-const ApiUsersServerRouteChildren: ApiUsersServerRouteChildren = {
- ApiUsersUserIdServerRoute: ApiUsersUserIdServerRoute,
+const ApiUsersRouteChildren: ApiUsersRouteChildren = {
+ ApiUsersUserIdRoute: ApiUsersUserIdRoute,
}
-const ApiUsersServerRouteWithChildren = ApiUsersServerRoute._addFileChildren(
- ApiUsersServerRouteChildren,
+const ApiUsersRouteWithChildren = ApiUsersRoute._addFileChildren(
+ ApiUsersRouteChildren,
)
const rootRouteChildren: RootRouteChildren = {
IndexRoute: IndexRoute,
PathlessLayoutRoute: PathlessLayoutRouteWithChildren,
+ CustomScriptDotjsRoute: CustomScriptDotjsRoute,
DeferredRoute: DeferredRoute,
PostsRoute: PostsRouteWithChildren,
RedirectRoute: RedirectRoute,
UsersRoute: UsersRouteWithChildren,
+ ApiUsersRoute: ApiUsersRouteWithChildren,
PostsPostIdDeepRoute: PostsPostIdDeepRoute,
}
export const routeTree = rootRouteImport
._addFileChildren(rootRouteChildren)
._addFileTypes()
-const rootServerRouteChildren: RootServerRouteChildren = {
- CustomScriptDotjsServerRoute: CustomScriptDotjsServerRoute,
- ApiUsersServerRoute: ApiUsersServerRouteWithChildren,
-}
-export const serverRouteTree = rootServerRouteImport
- ._addFileChildren(rootServerRouteChildren)
- ._addFileTypes()
diff --git a/examples/react/start-basic/src/router.tsx b/examples/react/start-basic/src/router.tsx
index c76eb0210c..5e5d5ce68e 100644
--- a/examples/react/start-basic/src/router.tsx
+++ b/examples/react/start-basic/src/router.tsx
@@ -1,6 +1,9 @@
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() {
@@ -14,9 +17,3 @@ export function createRouter() {
return router
}
-
-declare module '@tanstack/react-router' {
- interface Register {
- router: ReturnType
- }
-}
diff --git a/examples/react/start-basic/src/routes/api/users.$userId.ts b/examples/react/start-basic/src/routes/api/users.$userId.ts
index c5c2539932..2ae7eb9c04 100644
--- a/examples/react/start-basic/src/routes/api/users.$userId.ts
+++ b/examples/react/start-basic/src/routes/api/users.$userId.ts
@@ -1,28 +1,32 @@
-import { createServerFileRoute } from '@tanstack/react-start/server'
+import { createFileRoute } from '@tanstack/react-router'
import { json } from '@tanstack/react-start'
import type { User } from '~/utils/users'
-export const ServerRoute = createServerFileRoute('/api/users/$userId').methods({
- GET: async ({ params, request }) => {
- console.info(`Fetching users by id=${params.userId}... @`, request.url)
- try {
- const res = await fetch(
- 'https://jsonplaceholder.typicode.com/users/' + params.userId,
- )
- if (!res.ok) {
- throw new Error('Failed to fetch user')
- }
+export const Route = createFileRoute('/api/users/$userId')({
+ server: {
+ handlers: {
+ GET: async ({ params, request }) => {
+ console.info(`Fetching users by id=${params.userId}... @`, request.url)
+ try {
+ const res = await fetch(
+ 'https://jsonplaceholder.typicode.com/users/' + params.userId,
+ )
+ if (!res.ok) {
+ throw new Error('Failed to fetch user')
+ }
- const user = (await res.json()) as User
+ const user = (await res.json()) as User
- return json({
- id: user.id,
- name: user.name,
- email: user.email,
- })
- } catch (e) {
- console.error(e)
- return json({ error: 'User not found' }, { status: 404 })
- }
+ return json({
+ id: user.id,
+ name: user.name,
+ email: user.email,
+ })
+ } catch (e) {
+ console.error(e)
+ return json({ error: 'User not found' }, { status: 404 })
+ }
+ },
+ },
},
})
diff --git a/examples/react/start-basic/src/routes/api/users.ts b/examples/react/start-basic/src/routes/api/users.ts
index cb7f9e97b0..473a42e293 100644
--- a/examples/react/start-basic/src/routes/api/users.ts
+++ b/examples/react/start-basic/src/routes/api/users.ts
@@ -1,9 +1,9 @@
-import { createServerFileRoute } from '@tanstack/react-start/server'
+import { createFileRoute } from '@tanstack/react-router'
import { getRequestHeaders } from '@tanstack/react-start/server'
import { createMiddleware, json } from '@tanstack/react-start'
import type { User } from '~/utils/users'
-const userLoggerMiddleware = createMiddleware({ type: 'request' }).server(
+const userLoggerMiddleware = createMiddleware().server(
async ({ next, request }) => {
console.info('In: /users')
console.info('Request Headers:', getRequestHeaders())
@@ -14,7 +14,7 @@ const userLoggerMiddleware = createMiddleware({ type: 'request' }).server(
},
)
-const testParentMiddleware = createMiddleware({ type: 'request' }).server(
+const testParentMiddleware = createMiddleware().server(
async ({ next, request }) => {
console.info('In: testParentMiddleware')
const result = await next()
@@ -24,7 +24,7 @@ const testParentMiddleware = createMiddleware({ type: 'request' }).server(
},
)
-const testMiddleware = createMiddleware({ type: 'request' })
+const testMiddleware = createMiddleware()
.middleware([testParentMiddleware])
.server(async ({ next, request }) => {
console.info('In: testMiddleware')
@@ -42,21 +42,26 @@ const testMiddleware = createMiddleware({ type: 'request' })
return result
})
-export const ServerRoute = createServerFileRoute('/api/users')
- .middleware([testMiddleware, userLoggerMiddleware, testParentMiddleware])
- .methods({
- GET: async ({ request }) => {
- console.info('GET /api/users @', request.url)
- console.info('Fetching users... @', request.url)
- const res = await fetch('https://jsonplaceholder.typicode.com/users')
- if (!res.ok) {
- throw new Error('Failed to fetch users')
- }
+export const Route = createFileRoute('/api/users')({
+ server: {
+ middleware: [testMiddleware, userLoggerMiddleware],
+ handlers: {
+ GET: async ({ request }) => {
+ console.info('GET /api/users @', request.url)
+ console.info('Fetching users... @', request.url)
+ const res = await fetch('https://jsonplaceholder.typicode.com/users')
+ if (!res.ok) {
+ throw new Error('Failed to fetch users')
+ }
- const data = (await res.json()) as Array
+ const data = (await res.json()) as Array
- const list = data.slice(0, 10)
+ const list = data.slice(0, 10)
- return json(list.map((u) => ({ id: u.id, name: u.name, email: u.email })))
+ return json(
+ list.map((u) => ({ id: u.id, name: u.name, email: u.email })),
+ )
+ },
},
- })
+ },
+})
diff --git a/examples/react/start-basic/src/routes/customScript[.]js.ts b/examples/react/start-basic/src/routes/customScript[.]js.ts
index 92cc40dad4..811471ac15 100644
--- a/examples/react/start-basic/src/routes/customScript[.]js.ts
+++ b/examples/react/start-basic/src/routes/customScript[.]js.ts
@@ -1,10 +1,15 @@
-import { createServerFileRoute } from '@tanstack/react-start/server'
-export const ServerRoute = createServerFileRoute('/customScript.js').methods({
- GET: async ({ request }) => {
- return new Response('console.log("Hello from customScript.js!")', {
- headers: {
- 'Content-Type': 'application/javascript',
+import { createFileRoute } from '@tanstack/react-router'
+
+export const Route = createFileRoute('/customScript.js')({
+ server: {
+ handlers: {
+ GET: () => {
+ return new Response('console.log("Hello from customScript.js!")', {
+ headers: {
+ 'Content-Type': 'application/javascript',
+ },
+ })
},
- })
+ },
},
})
diff --git a/examples/react/start-basic/src/routes/index.tsx b/examples/react/start-basic/src/routes/index.tsx
index 37c8d237bd..d6aee63f34 100644
--- a/examples/react/start-basic/src/routes/index.tsx
+++ b/examples/react/start-basic/src/routes/index.tsx
@@ -1,5 +1,46 @@
import { createFileRoute } from '@tanstack/react-router'
+import { Foo } from '~/Foo'
+
export const Route = createFileRoute('/')({
+ server: {
+ // handlers: ({ createHandlers }) =>
+ // createHandlers({
+ // GET: ({ next }) => {
+ // return next({
+ // context: {
+ // test: true,
+ // },
+ // })
+ // },
+ // POST: ({ next }) => {
+ // return next({
+ // context: {
+ // wrong: true,
+ // },
+ // })
+ // },
+ // }),
+ handlers: {
+ GET: ({ next }) => {
+ return next({
+ context: {
+ test: true,
+ },
+ })
+ },
+ POST: ({ next }) => {
+ return next({
+ context: {
+ wrong: true,
+ },
+ })
+ },
+ },
+ },
+ beforeLoad: (ctx) => {
+ ctx.serverContext
+ return new Foo()
+ },
component: Home,
})
diff --git a/examples/react/start-basic/src/start.tsx b/examples/react/start-basic/src/start.tsx
new file mode 100644
index 0000000000..5210aba8c0
--- /dev/null
+++ b/examples/react/start-basic/src/start.tsx
@@ -0,0 +1,59 @@
+import {
+ defineStart,
+ RegisteredStartConfig,
+ Register,
+ RegisteredRequestContext,
+} from '@tanstack/react-start'
+import { useRouter } from '@tanstack/react-router'
+import { createRouter } from './router'
+import {
+ createRouterConfig,
+ createSerializationAdapter,
+ RegisteredConfig,
+ RegisteredSerializationAdapters,
+} from '@tanstack/router-core'
+import { Register as RegisterCore } from '@tanstack/router-core'
+import { Foo } from './Foo'
+
+export const fooAdapter = createSerializationAdapter({
+ key: 'foo',
+ test: (value: any) => value instanceof Foo,
+ toSerializable: (foo) => foo.test,
+ fromSerializable: (value) => new Foo(),
+})
+
+export const createStart = defineStart(() => {
+ const router = createRouter()
+ const config = createRouterConfig({
+ // defaultSsr: false,
+ serializationAdapters: [fooAdapter],
+ })
+ return { router, config }
+})
+
+declare module '@tanstack/react-start' {
+ interface Register {
+ createStart: typeof createStart
+ server: {
+ requestContext: {
+ test: string
+ }
+ }
+ }
+}
+
+type X =
+ RegisteredStartConfig['~types']['router']['routesById']['/posts/$postId']
+// ^?
+
+// const router = useRouter()
+// router.navigate({to: '/posts/$postId', params: {postId: '123'}})
+
+type R = RegisteredRequestContext
+// ^?
+
+type A = RegisteredSerializationAdapters
+// ^?
+
+type B = RegisteredConfig['~types']['serializationAdapters']
+// ^?
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..4c663752a0 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.16",
+ "@tanstack/react-router-devtools": "^1.132.0-alpha.16",
+ "@tanstack/react-start": "^1.132.0-alpha.17",
+ "@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..c94ea2c130 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.16",
+ "@tanstack/react-router-ssr-query": "^1.132.0-alpha.16",
+ "@tanstack/react-router-devtools": "^1.132.0-alpha.16",
+ "@tanstack/react-start": "^1.132.0-alpha.17",
"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..4576b8b61b 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.16",
+ "@tanstack/react-router-devtools": "^1.132.0-alpha.16",
+ "@tanstack/react-start": "^1.132.0-alpha.17",
"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..ad9ab6dbd4 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.16",
+ "@tanstack/react-router-devtools": "^1.132.0-alpha.16",
+ "@tanstack/react-start": "^1.132.0-alpha.17",
"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/routeTree.gen.ts b/examples/react/start-large/src/routeTree.gen.ts
index 11eb0131fd..93a5be975c 100644
--- a/examples/react/start-large/src/routeTree.gen.ts
+++ b/examples/react/start-large/src/routeTree.gen.ts
@@ -8,8 +8,6 @@
// 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 RelativeRouteImport } from './routes/relative'
import { Route as LinkPropsRouteImport } from './routes/linkProps'
@@ -17,14 +15,9 @@ import { Route as AbsoluteRouteImport } from './routes/absolute'
import { Route as SearchRouteRouteImport } from './routes/search/route'
import { Route as ParamsRouteRouteImport } from './routes/params/route'
import { Route as IndexRouteImport } from './routes/index'
-import {
- Route as SearchSearchPlaceholderRouteImport,
- ServerRoute as SearchSearchPlaceholderServerRouteImport,
-} from './routes/search/searchPlaceholder'
+import { Route as SearchSearchPlaceholderRouteImport } from './routes/search/searchPlaceholder'
import { Route as ParamsParamsPlaceholderRouteImport } from './routes/params/$paramsPlaceholder'
-const rootServerRouteImport = createServerRootRoute()
-
const RelativeRoute = RelativeRouteImport.update({
id: '/relative',
path: '/relative',
@@ -65,12 +58,6 @@ const ParamsParamsPlaceholderRoute = ParamsParamsPlaceholderRouteImport.update({
path: '/$paramsPlaceholder',
getParentRoute: () => ParamsRouteRoute,
} as any)
-const SearchSearchPlaceholderServerRoute =
- SearchSearchPlaceholderServerRouteImport.update({
- id: '/searchPlaceholder',
- path: '/searchPlaceholder',
- getParentRoute: () => rootServerRouteImport,
- } as any)
export interface FileRoutesByFullPath {
'/': typeof IndexRoute
@@ -144,25 +131,6 @@ export interface RootRouteChildren {
LinkPropsRoute: typeof LinkPropsRoute
RelativeRoute: typeof RelativeRoute
}
-export interface FileServerRoutesByFullPath {
- '/search/searchPlaceholder': typeof SearchSearchPlaceholderServerRoute
-}
-export interface FileServerRoutesByTo {
- '/search/searchPlaceholder': typeof SearchSearchPlaceholderServerRoute
-}
-export interface FileServerRoutesById {
- __root__: typeof rootServerRouteImport
- '/search/searchPlaceholder': typeof SearchSearchPlaceholderServerRoute
-}
-export interface FileServerRouteTypes {
- fileServerRoutesByFullPath: FileServerRoutesByFullPath
- fullPaths: '/search/searchPlaceholder'
- fileServerRoutesByTo: FileServerRoutesByTo
- to: '/search/searchPlaceholder'
- id: '__root__' | '/search/searchPlaceholder'
- fileServerRoutesById: FileServerRoutesById
-}
-export interface RootServerRouteChildren {}
declare module '@tanstack/react-router' {
interface FileRoutesByPath {
@@ -224,17 +192,6 @@ declare module '@tanstack/react-router' {
}
}
}
-declare module '@tanstack/react-start/server' {
- interface ServerFileRoutesByPath {
- '/search/searchPlaceholder': {
- id: '/search/searchPlaceholder'
- path: '/searchPlaceholder'
- fullPath: '/search/searchPlaceholder'
- preLoaderRoute: typeof SearchSearchPlaceholderServerRouteImport
- parentRoute: typeof rootServerRouteImport
- }
- }
-}
interface ParamsRouteRouteChildren {
ParamsParamsPlaceholderRoute: typeof ParamsParamsPlaceholderRoute
@@ -271,7 +228,3 @@ const rootRouteChildren: RootRouteChildren = {
export const routeTree = rootRouteImport
._addFileChildren(rootRouteChildren)
._addFileTypes()
-const rootServerRouteChildren: RootServerRouteChildren = {}
-export const serverRouteTree = rootServerRouteImport
- ._addFileChildren(rootServerRouteChildren)
- ._addFileTypes()
diff --git a/examples/react/start-large/src/routes/search/searchPlaceholder.tsx b/examples/react/start-large/src/routes/search/searchPlaceholder.tsx
index eb7f95c39a..b8bdfbb453 100644
--- a/examples/react/start-large/src/routes/search/searchPlaceholder.tsx
+++ b/examples/react/start-large/src/routes/search/searchPlaceholder.tsx
@@ -1,6 +1,4 @@
-import { createServerFileRoute } from '@tanstack/react-start/server'
-import { Link, createFileRoute } from '@tanstack/react-router'
-
+import { createFileRoute, Link } from '@tanstack/react-router'
import * as v from 'valibot'
import { queryOptions } from '@tanstack/react-query'
import { createMiddleware, createServerFn } from '@tanstack/react-start'
@@ -39,19 +37,17 @@ const fn = createServerFn()
const result = v.parse(loaderResult, {
searchPlaceholder: 0,
})
-
return result
})
-export const ServerRoute = createServerFileRoute(
- '/search/searchPlaceholder',
-).methods((api) => ({
- GET: api.handler(() => {
- return 'searchPlaceholder'
- }),
-}))
-
export const Route = createFileRoute('/search/searchPlaceholder')({
+ server: {
+ handlers: {
+ GET: () => {
+ return new Response('searchPlaceholder')
+ },
+ },
+ },
component: SearchComponent,
validateSearch: search,
loaderDeps: ({ search }) => ({ search }),
@@ -68,7 +64,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..406f6a2a2a 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.16",
+ "@tanstack/react-start": "^1.132.0-alpha.17",
+ "@tanstack/react-router-devtools": "^1.132.0-alpha.16",
"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..e43eabe6ad 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.16",
+ "@tanstack/react-router-devtools": "^1.132.0-alpha.16",
+ "@tanstack/react-start": "^1.132.0-alpha.17",
"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..152ecb8dfb 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.16",
+ "@tanstack/react-router-devtools": "^1.132.0-alpha.16",
+ "@tanstack/react-start": "^1.132.0-alpha.17",
"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..21ef9ce804 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.16",
+ "@tanstack/react-router-ssr-query": "^1.132.0-alpha.16",
+ "@tanstack/react-router-devtools": "^1.132.0-alpha.16",
+ "@tanstack/react-start": "^1.132.0-alpha.17",
"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..5b4647ddaf 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.16",
+ "@tanstack/react-router-devtools": "^1.132.0-alpha.16",
+ "@tanstack/react-start": "^1.132.0-alpha.17",
"@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/routeTree.gen.ts b/examples/react/start-workos/src/routeTree.gen.ts
index 3032457ca5..737f4c64d0 100644
--- a/examples/react/start-workos/src/routeTree.gen.ts
+++ b/examples/react/start-workos/src/routeTree.gen.ts
@@ -8,22 +8,23 @@
// 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 LogoutRouteImport } from './routes/logout'
+import { Route as CallbackRouteImport } from './routes/callback'
import { Route as AuthenticatedRouteImport } from './routes/_authenticated'
import { Route as IndexRouteImport } from './routes/index'
import { Route as AuthenticatedAccountRouteImport } from './routes/_authenticated/account'
-import { ServerRoute as CallbackServerRouteImport } from './routes/callback'
-
-const rootServerRouteImport = createServerRootRoute()
const LogoutRoute = LogoutRouteImport.update({
id: '/logout',
path: '/logout',
getParentRoute: () => rootRouteImport,
} as any)
+const CallbackRoute = CallbackRouteImport.update({
+ id: '/callback',
+ path: '/callback',
+ getParentRoute: () => rootRouteImport,
+} as any)
const AuthenticatedRoute = AuthenticatedRouteImport.update({
id: '/_authenticated',
getParentRoute: () => rootRouteImport,
@@ -38,19 +39,16 @@ const AuthenticatedAccountRoute = AuthenticatedAccountRouteImport.update({
path: '/account',
getParentRoute: () => AuthenticatedRoute,
} as any)
-const CallbackServerRoute = CallbackServerRouteImport.update({
- id: '/callback',
- path: '/callback',
- getParentRoute: () => rootServerRouteImport,
-} as any)
export interface FileRoutesByFullPath {
'/': typeof IndexRoute
+ '/callback': typeof CallbackRoute
'/logout': typeof LogoutRoute
'/account': typeof AuthenticatedAccountRoute
}
export interface FileRoutesByTo {
'/': typeof IndexRoute
+ '/callback': typeof CallbackRoute
'/logout': typeof LogoutRoute
'/account': typeof AuthenticatedAccountRoute
}
@@ -58,18 +56,20 @@ export interface FileRoutesById {
__root__: typeof rootRouteImport
'/': typeof IndexRoute
'/_authenticated': typeof AuthenticatedRouteWithChildren
+ '/callback': typeof CallbackRoute
'/logout': typeof LogoutRoute
'/_authenticated/account': typeof AuthenticatedAccountRoute
}
export interface FileRouteTypes {
fileRoutesByFullPath: FileRoutesByFullPath
- fullPaths: '/' | '/logout' | '/account'
+ fullPaths: '/' | '/callback' | '/logout' | '/account'
fileRoutesByTo: FileRoutesByTo
- to: '/' | '/logout' | '/account'
+ to: '/' | '/callback' | '/logout' | '/account'
id:
| '__root__'
| '/'
| '/_authenticated'
+ | '/callback'
| '/logout'
| '/_authenticated/account'
fileRoutesById: FileRoutesById
@@ -77,29 +77,9 @@ export interface FileRouteTypes {
export interface RootRouteChildren {
IndexRoute: typeof IndexRoute
AuthenticatedRoute: typeof AuthenticatedRouteWithChildren
+ CallbackRoute: typeof CallbackRoute
LogoutRoute: typeof LogoutRoute
}
-export interface FileServerRoutesByFullPath {
- '/callback': typeof CallbackServerRoute
-}
-export interface FileServerRoutesByTo {
- '/callback': typeof CallbackServerRoute
-}
-export interface FileServerRoutesById {
- __root__: typeof rootServerRouteImport
- '/callback': typeof CallbackServerRoute
-}
-export interface FileServerRouteTypes {
- fileServerRoutesByFullPath: FileServerRoutesByFullPath
- fullPaths: '/callback'
- fileServerRoutesByTo: FileServerRoutesByTo
- to: '/callback'
- id: '__root__' | '/callback'
- fileServerRoutesById: FileServerRoutesById
-}
-export interface RootServerRouteChildren {
- CallbackServerRoute: typeof CallbackServerRoute
-}
declare module '@tanstack/react-router' {
interface FileRoutesByPath {
@@ -110,6 +90,13 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof LogoutRouteImport
parentRoute: typeof rootRouteImport
}
+ '/callback': {
+ id: '/callback'
+ path: '/callback'
+ fullPath: '/callback'
+ preLoaderRoute: typeof CallbackRouteImport
+ parentRoute: typeof rootRouteImport
+ }
'/_authenticated': {
id: '/_authenticated'
path: ''
@@ -133,17 +120,6 @@ declare module '@tanstack/react-router' {
}
}
}
-declare module '@tanstack/react-start/server' {
- interface ServerFileRoutesByPath {
- '/callback': {
- id: '/callback'
- path: '/callback'
- fullPath: '/callback'
- preLoaderRoute: typeof CallbackServerRouteImport
- parentRoute: typeof rootServerRouteImport
- }
- }
-}
interface AuthenticatedRouteChildren {
AuthenticatedAccountRoute: typeof AuthenticatedAccountRoute
@@ -160,14 +136,9 @@ const AuthenticatedRouteWithChildren = AuthenticatedRoute._addFileChildren(
const rootRouteChildren: RootRouteChildren = {
IndexRoute: IndexRoute,
AuthenticatedRoute: AuthenticatedRouteWithChildren,
+ CallbackRoute: CallbackRoute,
LogoutRoute: LogoutRoute,
}
export const routeTree = rootRouteImport
._addFileChildren(rootRouteChildren)
._addFileTypes()
-const rootServerRouteChildren: RootServerRouteChildren = {
- CallbackServerRoute: CallbackServerRoute,
-}
-export const serverRouteTree = rootServerRouteImport
- ._addFileChildren(rootServerRouteChildren)
- ._addFileTypes()
diff --git a/examples/react/start-workos/src/routes/callback.tsx b/examples/react/start-workos/src/routes/callback.tsx
index 3d3fc3fd8d..9d27e1cc4a 100644
--- a/examples/react/start-workos/src/routes/callback.tsx
+++ b/examples/react/start-workos/src/routes/callback.tsx
@@ -1,77 +1,81 @@
-import { createServerFileRoute } from '@tanstack/react-start/server';
+import { createFileRoute } from '@tanstack/react-router';
import { getConfig } from '../authkit/ssr/config';
import { saveSession } from '../authkit/ssr/session';
import { getWorkOS } from '../authkit/ssr/workos';
-export const ServerRoute = createServerFileRoute('/callback').methods({
- GET: async ({ request }) => {
- const url = new URL(request.url);
- const code = url.searchParams.get('code');
- const state = url.searchParams.get('state');
- let returnPathname = state && state !== 'null' ? JSON.parse(atob(state)).returnPathname : null;
-
- if (code) {
- try {
- // Use the code returned to us by AuthKit and authenticate the user with WorkOS
- const { accessToken, refreshToken, user, impersonator } = await getWorkOS().userManagement.authenticateWithCode(
- {
- clientId: getConfig('clientId'),
- code,
- },
- );
-
- // If baseURL is provided, use it instead of request.nextUrl
- // This is useful if the app is being run in a container like docker where
- // the hostname can be different from the one in the request
+export const Route = createFileRoute('/callback')({
+ server: {
+ handlers: {
+ GET: async ({ request }) => {
const url = new URL(request.url);
+ const code = url.searchParams.get('code');
+ const state = url.searchParams.get('state');
+ let returnPathname = state && state !== 'null' ? JSON.parse(atob(state)).returnPathname : null;
- // Cleanup params
- url.searchParams.delete('code');
- url.searchParams.delete('state');
+ if (code) {
+ try {
+ // Use the code returned to us by AuthKit and authenticate the user with WorkOS
+ const { accessToken, refreshToken, user, impersonator } =
+ await getWorkOS().userManagement.authenticateWithCode({
+ clientId: getConfig('clientId'),
+ code,
+ });
- // Redirect to the requested path and store the session
- returnPathname = returnPathname ?? '/';
+ // If baseURL is provided, use it instead of request.nextUrl
+ // This is useful if the app is being run in a container like docker where
+ // the hostname can be different from the one in the request
+ const url = new URL(request.url);
- // Extract the search params if they are present
- if (returnPathname.includes('?')) {
- const newUrl = new URL(returnPathname, 'https://example.com');
- url.pathname = newUrl.pathname;
+ // Cleanup params
+ url.searchParams.delete('code');
+ url.searchParams.delete('state');
- for (const [key, value] of newUrl.searchParams) {
- url.searchParams.append(key, value);
+ // Redirect to the requested path and store the session
+ returnPathname = returnPathname ?? '/';
+
+ // Extract the search params if they are present
+ if (returnPathname.includes('?')) {
+ const newUrl = new URL(returnPathname, 'https://example.com');
+ url.pathname = newUrl.pathname;
+
+ for (const [key, value] of newUrl.searchParams) {
+ url.searchParams.append(key, value);
+ }
+ } else {
+ url.pathname = returnPathname;
+ }
+
+ const response = redirectWithFallback(url.toString());
+
+ if (!accessToken || !refreshToken) throw new Error('response is missing tokens');
+
+ await saveSession({ accessToken, refreshToken, user, impersonator });
+
+ return response;
+ } catch (error) {
+ const errorRes = {
+ error: error instanceof Error ? error.message : String(error),
+ };
+
+ console.error(errorRes);
+
+ return errorResponse();
}
- } else {
- url.pathname = returnPathname;
}
- const response = redirectWithFallback(url.toString());
-
- if (!accessToken || !refreshToken) throw new Error('response is missing tokens');
-
- await saveSession({ accessToken, refreshToken, user, impersonator });
-
- return response;
- } catch (error) {
- const errorRes = {
- error: error instanceof Error ? error.message : String(error),
- };
-
- console.error(errorRes);
-
return errorResponse();
- }
- }
- return errorResponse();
-
- function errorResponse() {
- return errorResponseWithFallback({
- error: {
- message: 'Something went wrong',
- description: "Couldn't sign in. If you are not sure what happened, please contact your organization admin.",
- },
- });
- }
+ function errorResponse() {
+ return errorResponseWithFallback({
+ error: {
+ message: 'Something went wrong',
+ description:
+ "Couldn't sign in. If you are not sure what happened, please contact your organization admin.",
+ },
+ });
+ }
+ },
+ },
},
});
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..0b61ed45f7 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.16",
+ "@tanstack/react-router-devtools": "^1.132.0-alpha.16",
+ "@tanstack/router-plugin": "^1.132.0-alpha.16",
"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..aab23af817 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.16",
+ "@tanstack/react-router-devtools": "^1.132.0-alpha.16",
"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..58fcd45b08 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.16",
+ "@tanstack/react-router-devtools": "^1.132.0-alpha.16",
+ "@tanstack/router-plugin": "^1.132.0-alpha.16",
"@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..c089fa2a76 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.16",
+ "@tanstack/react-router-devtools": "^1.132.0-alpha.16",
+ "@tanstack/router-plugin": "^1.132.0-alpha.16",
"@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..ff3d3d96a6 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.16",
+ "@tanstack/solid-router-devtools": "^1.132.0-alpha.16",
"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..e6a310805c 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.16",
+ "@tanstack/solid-router-devtools": "^1.132.0-alpha.16",
"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.16",
"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..39b50aa810 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.16",
+ "@tanstack/solid-router-devtools": "^1.132.0-alpha.16",
"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..561d7694ff 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.16",
+ "@tanstack/solid-router-devtools": "^1.132.0-alpha.16",
"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.16",
"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..e2e10ff53e 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.16",
+ "@tanstack/solid-router-devtools": "^1.132.0-alpha.16",
"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.16",
"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..4ce7b6b8d8 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.16",
+ "@tanstack/solid-router-devtools": "^1.132.0-alpha.16",
"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.16",
"@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..7b9034d5a4 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.16",
+ "@tanstack/solid-router-devtools": "^1.132.0-alpha.16",
"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..a4939956a9 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.16",
+ "@tanstack/solid-router-devtools": "^1.132.0-alpha.16",
"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.16",
"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..3be0918270 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.16",
+ "@tanstack/solid-router-devtools": "^1.132.0-alpha.16",
"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.16",
"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..62e476fe69 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.16",
+ "@tanstack/solid-router-devtools": "^1.132.0-alpha.16",
+ "@tanstack/solid-start": "^1.132.0-alpha.17",
"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..f35086de31 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.16",
+ "@tanstack/solid-router-devtools": "^1.132.0-alpha.16",
+ "@tanstack/solid-start": "^1.132.0-alpha.17",
+ "@tanstack/start-static-server-functions": "^1.132.0-alpha.16",
"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..ad50e11246 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.16",
+ "@tanstack/solid-router-devtools": "^1.132.0-alpha.16",
+ "@tanstack/solid-start": "^1.132.0-alpha.17",
"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/routeTree.gen.ts b/examples/solid/start-basic/src/routeTree.gen.ts
index 16b7ef22db..7145cf8b3e 100644
--- a/examples/solid/start-basic/src/routeTree.gen.ts
+++ b/examples/solid/start-basic/src/routeTree.gen.ts
@@ -8,8 +8,6 @@
// 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/solid-start/server'
-
import { Route as rootRouteImport } from './routes/__root'
import { Route as UsersRouteImport } from './routes/users'
import { Route as RedirectRouteImport } from './routes/redirect'
@@ -21,14 +19,12 @@ import { Route as UsersIndexRouteImport } from './routes/users.index'
import { Route as PostsIndexRouteImport } from './routes/posts.index'
import { Route as UsersUserIdRouteImport } from './routes/users.$userId'
import { Route as PostsPostIdRouteImport } from './routes/posts.$postId'
+import { Route as ApiUsersRouteImport } from './routes/api/users'
import { Route as PathlessLayoutNestedLayoutRouteImport } from './routes/_pathlessLayout/_nested-layout'
import { Route as PostsPostIdDeepRouteImport } from './routes/posts_.$postId.deep'
+import { Route as ApiUsersUserIdRouteImport } from './routes/api/users.$userId'
import { Route as PathlessLayoutNestedLayoutRouteBRouteImport } from './routes/_pathlessLayout/_nested-layout/route-b'
import { Route as PathlessLayoutNestedLayoutRouteARouteImport } from './routes/_pathlessLayout/_nested-layout/route-a'
-import { ServerRoute as ApiUsersServerRouteImport } from './routes/api/users'
-import { ServerRoute as ApiUsersUserIdServerRouteImport } from './routes/api/users.$userId'
-
-const rootServerRouteImport = createServerRootRoute()
const UsersRoute = UsersRouteImport.update({
id: '/users',
@@ -79,6 +75,11 @@ const PostsPostIdRoute = PostsPostIdRouteImport.update({
path: '/$postId',
getParentRoute: () => PostsRoute,
} as any)
+const ApiUsersRoute = ApiUsersRouteImport.update({
+ id: '/api/users',
+ path: '/api/users',
+ getParentRoute: () => rootRouteImport,
+} as any)
const PathlessLayoutNestedLayoutRoute =
PathlessLayoutNestedLayoutRouteImport.update({
id: '/_nested-layout',
@@ -89,6 +90,11 @@ const PostsPostIdDeepRoute = PostsPostIdDeepRouteImport.update({
path: '/posts/$postId/deep',
getParentRoute: () => rootRouteImport,
} as any)
+const ApiUsersUserIdRoute = ApiUsersUserIdRouteImport.update({
+ id: '/$userId',
+ path: '/$userId',
+ getParentRoute: () => ApiUsersRoute,
+} as any)
const PathlessLayoutNestedLayoutRouteBRoute =
PathlessLayoutNestedLayoutRouteBRouteImport.update({
id: '/route-b',
@@ -101,16 +107,6 @@ const PathlessLayoutNestedLayoutRouteARoute =
path: '/route-a',
getParentRoute: () => PathlessLayoutNestedLayoutRoute,
} as any)
-const ApiUsersServerRoute = ApiUsersServerRouteImport.update({
- id: '/api/users',
- path: '/api/users',
- getParentRoute: () => rootServerRouteImport,
-} as any)
-const ApiUsersUserIdServerRoute = ApiUsersUserIdServerRouteImport.update({
- id: '/$userId',
- path: '/$userId',
- getParentRoute: () => ApiUsersServerRoute,
-} as any)
export interface FileRoutesByFullPath {
'/': typeof IndexRoute
@@ -118,24 +114,28 @@ export interface FileRoutesByFullPath {
'/posts': typeof PostsRouteWithChildren
'/redirect': typeof RedirectRoute
'/users': typeof UsersRouteWithChildren
+ '/api/users': typeof ApiUsersRouteWithChildren
'/posts/$postId': typeof PostsPostIdRoute
'/users/$userId': typeof UsersUserIdRoute
'/posts/': typeof PostsIndexRoute
'/users/': typeof UsersIndexRoute
'/route-a': typeof PathlessLayoutNestedLayoutRouteARoute
'/route-b': typeof PathlessLayoutNestedLayoutRouteBRoute
+ '/api/users/$userId': typeof ApiUsersUserIdRoute
'/posts/$postId/deep': typeof PostsPostIdDeepRoute
}
export interface FileRoutesByTo {
'/': typeof IndexRoute
'/deferred': typeof DeferredRoute
'/redirect': typeof RedirectRoute
+ '/api/users': typeof ApiUsersRouteWithChildren
'/posts/$postId': typeof PostsPostIdRoute
'/users/$userId': typeof UsersUserIdRoute
'/posts': typeof PostsIndexRoute
'/users': typeof UsersIndexRoute
'/route-a': typeof PathlessLayoutNestedLayoutRouteARoute
'/route-b': typeof PathlessLayoutNestedLayoutRouteBRoute
+ '/api/users/$userId': typeof ApiUsersUserIdRoute
'/posts/$postId/deep': typeof PostsPostIdDeepRoute
}
export interface FileRoutesById {
@@ -147,12 +147,14 @@ export interface FileRoutesById {
'/redirect': typeof RedirectRoute
'/users': typeof UsersRouteWithChildren
'/_pathlessLayout/_nested-layout': typeof PathlessLayoutNestedLayoutRouteWithChildren
+ '/api/users': typeof ApiUsersRouteWithChildren
'/posts/$postId': typeof PostsPostIdRoute
'/users/$userId': typeof UsersUserIdRoute
'/posts/': typeof PostsIndexRoute
'/users/': typeof UsersIndexRoute
'/_pathlessLayout/_nested-layout/route-a': typeof PathlessLayoutNestedLayoutRouteARoute
'/_pathlessLayout/_nested-layout/route-b': typeof PathlessLayoutNestedLayoutRouteBRoute
+ '/api/users/$userId': typeof ApiUsersUserIdRoute
'/posts_/$postId/deep': typeof PostsPostIdDeepRoute
}
export interface FileRouteTypes {
@@ -163,24 +165,28 @@ export interface FileRouteTypes {
| '/posts'
| '/redirect'
| '/users'
+ | '/api/users'
| '/posts/$postId'
| '/users/$userId'
| '/posts/'
| '/users/'
| '/route-a'
| '/route-b'
+ | '/api/users/$userId'
| '/posts/$postId/deep'
fileRoutesByTo: FileRoutesByTo
to:
| '/'
| '/deferred'
| '/redirect'
+ | '/api/users'
| '/posts/$postId'
| '/users/$userId'
| '/posts'
| '/users'
| '/route-a'
| '/route-b'
+ | '/api/users/$userId'
| '/posts/$postId/deep'
id:
| '__root__'
@@ -191,12 +197,14 @@ export interface FileRouteTypes {
| '/redirect'
| '/users'
| '/_pathlessLayout/_nested-layout'
+ | '/api/users'
| '/posts/$postId'
| '/users/$userId'
| '/posts/'
| '/users/'
| '/_pathlessLayout/_nested-layout/route-a'
| '/_pathlessLayout/_nested-layout/route-b'
+ | '/api/users/$userId'
| '/posts_/$postId/deep'
fileRoutesById: FileRoutesById
}
@@ -207,32 +215,9 @@ export interface RootRouteChildren {
PostsRoute: typeof PostsRouteWithChildren
RedirectRoute: typeof RedirectRoute
UsersRoute: typeof UsersRouteWithChildren
+ ApiUsersRoute: typeof ApiUsersRouteWithChildren
PostsPostIdDeepRoute: typeof PostsPostIdDeepRoute
}
-export interface FileServerRoutesByFullPath {
- '/api/users': typeof ApiUsersServerRouteWithChildren
- '/api/users/$userId': typeof ApiUsersUserIdServerRoute
-}
-export interface FileServerRoutesByTo {
- '/api/users': typeof ApiUsersServerRouteWithChildren
- '/api/users/$userId': typeof ApiUsersUserIdServerRoute
-}
-export interface FileServerRoutesById {
- __root__: typeof rootServerRouteImport
- '/api/users': typeof ApiUsersServerRouteWithChildren
- '/api/users/$userId': typeof ApiUsersUserIdServerRoute
-}
-export interface FileServerRouteTypes {
- fileServerRoutesByFullPath: FileServerRoutesByFullPath
- fullPaths: '/api/users' | '/api/users/$userId'
- fileServerRoutesByTo: FileServerRoutesByTo
- to: '/api/users' | '/api/users/$userId'
- id: '__root__' | '/api/users' | '/api/users/$userId'
- fileServerRoutesById: FileServerRoutesById
-}
-export interface RootServerRouteChildren {
- ApiUsersServerRoute: typeof ApiUsersServerRouteWithChildren
-}
declare module '@tanstack/solid-router' {
interface FileRoutesByPath {
@@ -306,6 +291,13 @@ declare module '@tanstack/solid-router' {
preLoaderRoute: typeof PostsPostIdRouteImport
parentRoute: typeof PostsRoute
}
+ '/api/users': {
+ id: '/api/users'
+ path: '/api/users'
+ fullPath: '/api/users'
+ preLoaderRoute: typeof ApiUsersRouteImport
+ parentRoute: typeof rootRouteImport
+ }
'/_pathlessLayout/_nested-layout': {
id: '/_pathlessLayout/_nested-layout'
path: ''
@@ -320,6 +312,13 @@ declare module '@tanstack/solid-router' {
preLoaderRoute: typeof PostsPostIdDeepRouteImport
parentRoute: typeof rootRouteImport
}
+ '/api/users/$userId': {
+ id: '/api/users/$userId'
+ path: '/$userId'
+ fullPath: '/api/users/$userId'
+ preLoaderRoute: typeof ApiUsersUserIdRouteImport
+ parentRoute: typeof ApiUsersRoute
+ }
'/_pathlessLayout/_nested-layout/route-b': {
id: '/_pathlessLayout/_nested-layout/route-b'
path: '/route-b'
@@ -336,24 +335,6 @@ declare module '@tanstack/solid-router' {
}
}
}
-declare module '@tanstack/solid-start/server' {
- interface ServerFileRoutesByPath {
- '/api/users': {
- id: '/api/users'
- path: '/api/users'
- fullPath: '/api/users'
- preLoaderRoute: typeof ApiUsersServerRouteImport
- parentRoute: typeof rootServerRouteImport
- }
- '/api/users/$userId': {
- id: '/api/users/$userId'
- path: '/$userId'
- fullPath: '/api/users/$userId'
- preLoaderRoute: typeof ApiUsersUserIdServerRouteImport
- parentRoute: typeof ApiUsersServerRoute
- }
- }
-}
interface PathlessLayoutNestedLayoutRouteChildren {
PathlessLayoutNestedLayoutRouteARoute: typeof PathlessLayoutNestedLayoutRouteARoute
@@ -409,16 +390,16 @@ const UsersRouteChildren: UsersRouteChildren = {
const UsersRouteWithChildren = UsersRoute._addFileChildren(UsersRouteChildren)
-interface ApiUsersServerRouteChildren {
- ApiUsersUserIdServerRoute: typeof ApiUsersUserIdServerRoute
+interface ApiUsersRouteChildren {
+ ApiUsersUserIdRoute: typeof ApiUsersUserIdRoute
}
-const ApiUsersServerRouteChildren: ApiUsersServerRouteChildren = {
- ApiUsersUserIdServerRoute: ApiUsersUserIdServerRoute,
+const ApiUsersRouteChildren: ApiUsersRouteChildren = {
+ ApiUsersUserIdRoute: ApiUsersUserIdRoute,
}
-const ApiUsersServerRouteWithChildren = ApiUsersServerRoute._addFileChildren(
- ApiUsersServerRouteChildren,
+const ApiUsersRouteWithChildren = ApiUsersRoute._addFileChildren(
+ ApiUsersRouteChildren,
)
const rootRouteChildren: RootRouteChildren = {
@@ -428,14 +409,9 @@ const rootRouteChildren: RootRouteChildren = {
PostsRoute: PostsRouteWithChildren,
RedirectRoute: RedirectRoute,
UsersRoute: UsersRouteWithChildren,
+ ApiUsersRoute: ApiUsersRouteWithChildren,
PostsPostIdDeepRoute: PostsPostIdDeepRoute,
}
export const routeTree = rootRouteImport
._addFileChildren(rootRouteChildren)
._addFileTypes()
-const rootServerRouteChildren: RootServerRouteChildren = {
- ApiUsersServerRoute: ApiUsersServerRouteWithChildren,
-}
-export const serverRouteTree = rootServerRouteImport
- ._addFileChildren(rootServerRouteChildren)
- ._addFileTypes()
diff --git a/examples/solid/start-basic/src/routes/api/users.$userId.ts b/examples/solid/start-basic/src/routes/api/users.$userId.ts
index cf539e0c0c..65e5da00fc 100644
--- a/examples/solid/start-basic/src/routes/api/users.$userId.ts
+++ b/examples/solid/start-basic/src/routes/api/users.$userId.ts
@@ -1,28 +1,30 @@
-import { createServerFileRoute } from '@tanstack/solid-start/server'
+import { createFileRoute } from '@tanstack/solid-router'
import { json } from '@tanstack/solid-start'
import type { User } from '~/utils/users'
-export const ServerRoute = createServerFileRoute('/api/users/$userId').methods({
- GET: async ({ params, request }) => {
- console.info(`Fetching users by id=${params.userId}... @`, request.url)
- try {
- const res = await fetch(
- 'https://jsonplaceholder.typicode.com/users/' + params.userId,
- )
- if (!res.ok) {
- throw new Error('Failed to fetch user')
- }
-
- const user = (await res.json()) as User
-
- return json({
- id: user.id,
- name: user.name,
- email: user.email,
- })
- } catch (e) {
- console.error(e)
- return json({ error: 'User not found' }, { status: 404 })
- }
+export const Route = createFileRoute('/api/users/$userId')({
+ server: {
+ handlers: {
+ GET: async ({ params, request }) => {
+ console.info(`Fetching users by id=${params.userId}... @`, request.url)
+ try {
+ const res = await fetch(
+ 'https://jsonplaceholder.typicode.com/users/' + params.userId,
+ )
+ if (!res.ok) {
+ throw new Error('Failed to fetch user')
+ }
+ const user = (await res.json()) as User
+ return json({
+ id: user.id,
+ name: user.name,
+ email: user.email,
+ })
+ } catch (e) {
+ console.error(e)
+ return json({ error: 'User not found' }, { status: 404 })
+ }
+ },
+ },
},
})
diff --git a/examples/solid/start-basic/src/routes/api/users.ts b/examples/solid/start-basic/src/routes/api/users.ts
index ec59c81bc0..db3977d8d8 100644
--- a/examples/solid/start-basic/src/routes/api/users.ts
+++ b/examples/solid/start-basic/src/routes/api/users.ts
@@ -1,8 +1,9 @@
-import { createServerFileRoute } from '@tanstack/solid-start/server'
+import { createFileRoute } from '@tanstack/solid-router'
+import { createFileRoute } from '@tanstack/react-router'
import { createMiddleware, json } from '@tanstack/solid-start'
import type { User } from '~/utils/users'
-const userLoggerMiddleware = createMiddleware({ type: 'request' }).server(
+const userLoggerMiddleware = createMiddleware().server(
async ({ next, request }) => {
console.info('In: /users')
const result = await next()
@@ -12,7 +13,7 @@ const userLoggerMiddleware = createMiddleware({ type: 'request' }).server(
},
)
-const testParentMiddleware = createMiddleware({ type: 'request' }).server(
+const testParentMiddleware = createMiddleware().server(
async ({ next, request }) => {
console.info('In: testParentMiddleware')
const result = await next()
@@ -22,38 +23,38 @@ const testParentMiddleware = createMiddleware({ type: 'request' }).server(
},
)
-const testMiddleware = createMiddleware({ type: 'request' })
+const testMiddleware = createMiddleware()
.middleware([testParentMiddleware])
.server(async ({ next, request }) => {
console.info('In: testMiddleware')
const result = await next()
result.response.headers.set('x-test', 'true')
-
// if (Math.random() > 0.5) {
// throw new Response(null, {
// status: 302,
// headers: { Location: 'https://www.google.com' },
// })
// }
-
console.info('Out: testMiddleware')
return result
})
-export const ServerRoute = createServerFileRoute('/api/users')
- .middleware([testMiddleware, userLoggerMiddleware, testParentMiddleware])
- .methods({
- GET: async ({ request }) => {
- console.info('Fetching users... @', request.url)
- const res = await fetch('https://jsonplaceholder.typicode.com/users')
- if (!res.ok) {
- throw new Error('Failed to fetch users')
- }
-
- const data = (await res.json()) as Array
-
- const list = data.slice(0, 10)
-
- return json(list.map((u) => ({ id: u.id, name: u.name, email: u.email })))
+export const Route = createFileRoute('/api/users')({
+ server: {
+ middleware: [testMiddleware, userLoggerMiddleware, testParentMiddleware],
+ handlers: {
+ GET: async ({ request }) => {
+ console.info('Fetching users... @', request.url)
+ const res = await fetch('https://jsonplaceholder.typicode.com/users')
+ if (!res.ok) {
+ throw new Error('Failed to fetch users')
+ }
+ const data = (await res.json()) as Array
+ const list = data.slice(0, 10)
+ return json(
+ list.map((u) => ({ id: u.id, name: u.name, email: u.email })),
+ )
+ },
},
- })
+ },
+})
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..8862a44ffe 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.16",
"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..0463cad6a7 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.16",
"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..918561540e 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.16",
"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..2e021d27ad 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.16",
"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..9eea244a0a 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,12 @@ export class FileRoute<
TLoaderDeps extends Record = {},
TLoaderFn = undefined,
TChildren = unknown,
+ TSSR = unknown,
+ const TMiddlewares = unknown,
+ THandlers = undefined,
>(
options?: FileBaseRouteOptions<
+ TRegister,
TParentRoute,
TId,
TPath,
@@ -94,7 +100,11 @@ export class FileRoute<
TLoaderFn,
AnyContext,
TRouteContextFn,
- TBeforeLoadFn
+ TBeforeLoadFn,
+ AnyContext,
+ TSSR,
+ TMiddlewares,
+ THandlers
> &
UpdatableRouteOptions<
TParentRoute,
@@ -109,6 +119,7 @@ export class FileRoute<
TBeforeLoadFn
>,
): Route<
+ TRegister,
TParentRoute,
TPath,
TFullPath,
@@ -122,7 +133,10 @@ export class FileRoute<
TLoaderDeps,
TLoaderFn,
TChildren,
- unknown
+ unknown,
+ TSSR,
+ TMiddlewares,
+ THandlers
> => {
warning(
this.silent,
diff --git a/packages/react-router/src/index.tsx b/packages/react-router/src/index.tsx
index ed78317315..acbe0833c8 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,
@@ -14,7 +11,6 @@ export {
parsePathname,
interpolatePath,
matchPathname,
- removeBasepath,
matchByPath,
rootRouteId,
defaultSerializeError,
@@ -22,16 +18,15 @@ export {
defaultStringifySearch,
parseSearchWith,
stringifySearchWith,
- escapeJSON, // SSR
functionalUpdate,
replaceEqualDeep,
isPlainObject,
isPlainArray,
deepEqual,
- shallow,
createControlledPromise,
retainSearchParams,
stripSearchParams,
+ createSerializationAdapter,
} from '@tanstack/router-core'
export type {
@@ -94,6 +89,7 @@ export type {
ResolveValidatorInput,
ResolveValidatorOutput,
Register,
+ MetaRegister,
AnyValidator,
DefaultValidator,
ValidatorFn,
@@ -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,9 @@ export { ScriptOnce } from './ScriptOnce'
export { Asset } from './Asset'
export { HeadContent } from './HeadContent'
export { Scripts } from './Scripts'
+export type * from './ssr/serializer'
+export { rewriteBasepath, composeRewrites } from '@tanstack/router-core'
+export type {
+ LocationRewrite,
+ LocationRewriteFunction,
+} from '@tanstack/router-core'
diff --git a/packages/react-router/src/link.tsx b/packages/react-router/src/link.tsx
index c72d0e8567..32d7e315a6 100644
--- a/packages/react-router/src/link.tsx
+++ b/packages/react-router/src/link.tsx
@@ -12,7 +12,6 @@ import { useRouter } from './useRouter'
import { useForwardedRef, useIntersectionObserver } from './utils'
-import { useMatch } from './useMatch'
import type {
AnyRouter,
Constrain,
@@ -79,39 +78,24 @@ export function useLinkProps<
...propsSafeToSpread
} = options
- // If this link simply reloads the current route,
- // make sure it has a new key so it will trigger a data refresh
-
- // If this `to` is a valid external URL, return
- // null for LinkUtils
-
- const type: 'internal' | 'external' = React.useMemo(() => {
- try {
- new URL(to as any)
- return 'external'
- } catch {}
- return 'internal'
- }, [to])
-
// subscribe to search params to re-build location if it changes
const currentSearch = useRouterState({
select: (s) => s.location.search,
structuralSharing: true as any,
})
- const from = useMatch({
- strict: false,
- select: (match) => options.from ?? match.fullPath,
- })
+ const from = options.from
- const next = React.useMemo(
- () => router.buildLocation({ ...options, from } as any),
+ const _options = React.useMemo(
+ () => {
+ return { ...options, from }
+ },
// eslint-disable-next-line react-hooks/exhaustive-deps
[
router,
currentSearch,
- options._fromLocation,
from,
+ options._fromLocation,
options.hash,
options.to,
options.search,
@@ -122,10 +106,41 @@ export function useLinkProps<
],
)
- const isExternal = type === 'external'
+ const next = React.useMemo(
+ () => router.buildLocation({ ..._options } as any),
+ [router, _options],
+ )
+
+ const hrefOption = React.useMemo(() => {
+ if (disabled) {
+ return undefined
+ }
+ let href = next.maskedLocation ? next.maskedLocation.url : next.url
+
+ let external = false
+ if (router.origin) {
+ if (href.startsWith(router.origin)) {
+ href = href.replace(router.origin, '') || '/'
+ } else {
+ external = true
+ }
+ }
+ return { href, external }
+ }, [disabled, next.maskedLocation, next.url, router.origin])
+
+ const externalLink = React.useMemo(() => {
+ if (hrefOption?.external) {
+ return hrefOption.href
+ }
+ try {
+ new URL(to as any)
+ return to
+ } catch {}
+ return undefined
+ }, [to, hrefOption])
const preload =
- options.reloadDocument || isExternal
+ options.reloadDocument || externalLink
? false
: (userPreload ?? router.options.defaultPreload)
const preloadDelay =
@@ -133,7 +148,7 @@ export function useLinkProps<
const isActive = useRouterState({
select: (s) => {
- if (isExternal) return false
+ if (externalLink) return false
if (activeOptions?.exact) {
const testExact = exactPathTest(
s.location.pathname,
@@ -180,34 +195,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 +228,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 +251,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 +262,24 @@ export function useLinkProps<
}
}
+ if (externalLink) {
+ return {
+ ...propsSafeToSpread,
+ ref: innerRef as React.ComponentPropsWithRef<'a'>['ref'],
+ href: externalLink,
+ ...(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
@@ -358,11 +349,7 @@ export function useLinkProps<
...propsSafeToSpread,
...resolvedActiveProps,
...resolvedInactiveProps,
- href: disabled
- ? undefined
- : next.maskedLocation
- ? router.history.createHref(next.maskedLocation.href)
- : router.history.createHref(next.href),
+ href: hrefOption?.href,
ref: innerRef as React.ComponentPropsWithRef<'a'>['ref'],
onClick: composeHandlers([onClick, handleClick]),
onFocus: composeHandlers([onFocus, handleFocus]),
diff --git a/packages/react-router/src/route.tsx b/packages/react-router/src/route.tsx
index 42fb9c388c..2d5e5048f0 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,12 @@ export class Route<
in out TLoaderFn = undefined,
in out TChildren = unknown,
in out TFileRouteTypes = unknown,
+ in out TSSR = unknown,
+ in out TServerMiddlewares = unknown,
+ in out THandlers = undefined,
>
extends BaseRoute<
+ TRegister,
TParentRoute,
TPath,
TFullPath,
@@ -194,10 +200,14 @@ export class Route<
TLoaderDeps,
TLoaderFn,
TChildren,
- TFileRouteTypes
+ TFileRouteTypes,
+ TSSR,
+ TServerMiddlewares,
+ THandlers
>
implements
RouteCore<
+ TRegister,
TParentRoute,
TPath,
TFullPath,
@@ -211,7 +221,10 @@ export class Route<
TLoaderDeps,
TLoaderFn,
TChildren,
- TFileRouteTypes
+ TFileRouteTypes,
+ TSSR,
+ TServerMiddlewares,
+ THandlers
>
{
/**
@@ -219,6 +232,7 @@ export class Route<
*/
constructor(
options?: RouteOptions<
+ TRegister,
TParentRoute,
TId,
TCustomId,
@@ -230,7 +244,10 @@ export class Route<
TLoaderFn,
TRouterContext,
TRouteContextFn,
- TBeforeLoadFn
+ TBeforeLoadFn,
+ TSSR,
+ TServerMiddlewares,
+ THandlers
>,
) {
super(options)
@@ -291,6 +308,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 +328,11 @@ export function createRoute<
TLoaderDeps extends Record = {},
TLoaderFn = undefined,
TChildren = unknown,
+ TSSR = unknown,
+ const TServerMiddlewares = unknown,
>(
options: RouteOptions<
+ TRegister,
TParentRoute,
TId,
TCustomId,
@@ -323,9 +344,12 @@ export function createRoute<
TLoaderFn,
AnyContext,
TRouteContextFn,
- TBeforeLoadFn
+ TBeforeLoadFn,
+ TSSR,
+ TServerMiddlewares
>,
): Route<
+ TRegister,
TParentRoute,
TPath,
TFullPath,
@@ -338,9 +362,12 @@ export function createRoute<
TBeforeLoadFn,
TLoaderDeps,
TLoaderFn,
- TChildren
+ TChildren,
+ TSSR,
+ TServerMiddlewares
> {
return new Route<
+ TRegister,
TParentRoute,
TPath,
TFullPath,
@@ -353,36 +380,62 @@ export function createRoute<
TBeforeLoadFn,
TLoaderDeps,
TLoaderFn,
- TChildren
- >(options)
+ TChildren,
+ TSSR,
+ TServerMiddlewares
+ >(
+ // TODO: Help us TypeChris, you're our only hope!
+ options as any,
+ )
}
-export type AnyRootRoute = RootRoute
+export type AnyRootRoute = RootRoute<
+ any,
+ 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,
+ TServerMiddlewares = unknown,
>(
options?: RootRouteOptions<
+ TRegister,
TSearchValidator,
TRouterContext,
TRouteContextFn,
TBeforeLoadFn,
TLoaderDeps,
- TLoaderFn
+ TLoaderFn,
+ TSSR,
+ TServerMiddlewares
>,
) => {
return createRootRoute<
+ TRegister,
TSearchValidator,
TRouterContext,
TRouteContextFn,
TBeforeLoadFn,
TLoaderDeps,
- TLoaderFn
+ TLoaderFn,
+ TSSR,
+ TServerMiddlewares
>(options as any)
}
}
@@ -393,6 +446,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 +455,11 @@ export class RootRoute<
in out TLoaderFn = undefined,
in out TChildren = unknown,
in out TFileRouteTypes = unknown,
+ in out TSSR = unknown,
+ in out TServerMiddlewares = unknown,
>
extends BaseRootRoute<
+ TRegister,
TSearchValidator,
TRouterContext,
TRouteContextFn,
@@ -410,10 +467,13 @@ export class RootRoute<
TLoaderDeps,
TLoaderFn,
TChildren,
- TFileRouteTypes
+ TFileRouteTypes,
+ TSSR,
+ TServerMiddlewares
>
implements
RootRouteCore<
+ TRegister,
TSearchValidator,
TRouterContext,
TRouteContextFn,
@@ -421,7 +481,9 @@ export class RootRoute<
TLoaderDeps,
TLoaderFn,
TChildren,
- TFileRouteTypes
+ TFileRouteTypes,
+ TSSR,
+ TServerMiddlewares
>
{
/**
@@ -429,12 +491,15 @@ export class RootRoute<
*/
constructor(
options?: RootRouteOptions<
+ TRegister,
TSearchValidator,
TRouterContext,
TRouteContextFn,
TBeforeLoadFn,
TLoaderDeps,
- TLoaderFn
+ TLoaderFn,
+ TSSR,
+ TServerMiddlewares
>,
) {
super(options)
@@ -495,22 +560,29 @@ export class RootRoute<
}
export function createRootRoute<
+ TRegister extends Register = Register,
TSearchValidator = undefined,
TRouterContext = {},
TRouteContextFn = AnyContext,
TBeforeLoadFn = AnyContext,
TLoaderDeps extends Record = {},
TLoaderFn = undefined,
+ TSSR = unknown,
+ const TServerMiddlewares = unknown,
>(
options?: RootRouteOptions<
+ TRegister,
TSearchValidator,
TRouterContext,
TRouteContextFn,
TBeforeLoadFn,
TLoaderDeps,
- TLoaderFn
+ TLoaderFn,
+ TSSR,
+ TServerMiddlewares
>,
): RootRoute<
+ TRegister,
TSearchValidator,
TRouterContext,
TRouteContextFn,
@@ -518,15 +590,22 @@ export function createRootRoute<
TLoaderDeps,
TLoaderFn,
unknown,
- unknown
+ unknown,
+ TSSR,
+ TServerMiddlewares
> {
return new RootRoute<
+ TRegister,
TSearchValidator,
TRouterContext,
TRouteContextFn,
TBeforeLoadFn,
TLoaderDeps,
- TLoaderFn
+ TLoaderFn,
+ unknown,
+ unknown,
+ TSSR,
+ TServerMiddlewares
>(options)
}
@@ -560,6 +639,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 +648,10 @@ export class NotFoundRoute<
TLoaderDeps extends Record = {},
TLoaderFn = undefined,
TChildren = unknown,
+ TSSR = unknown,
+ TServerMiddlewares = unknown,
> extends Route<
+ TRegister,
TParentRoute,
'/404',
'/404',
@@ -581,11 +664,14 @@ export class NotFoundRoute<
TBeforeLoadFn,
TLoaderDeps,
TLoaderFn,
- TChildren
+ TChildren,
+ TSSR,
+ TServerMiddlewares
> {
constructor(
options: Omit<
RouteOptions<
+ TRegister,
TParentRoute,
string,
string,
@@ -597,7 +683,9 @@ export class NotFoundRoute<
TLoaderFn,
TRouterContext,
TRouteContextFn,
- TBeforeLoadFn
+ TBeforeLoadFn,
+ TSSR,
+ TServerMiddlewares
>,
| '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/useNavigate.tsx b/packages/react-router/src/useNavigate.tsx
index 1fcef97967..2671aa7e4e 100644
--- a/packages/react-router/src/useNavigate.tsx
+++ b/packages/react-router/src/useNavigate.tsx
@@ -1,6 +1,5 @@
import * as React from 'react'
import { useRouter } from './useRouter'
-import { useMatch } from './useMatch'
import type {
AnyRouter,
FromPathOption,
@@ -15,29 +14,16 @@ export function useNavigate<
>(_defaultOpts?: {
from?: FromPathOption
}): UseNavigateResult {
- const { navigate, state } = 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 router = useRouter()
return React.useCallback(
(options: NavigateOptions) => {
- const from =
- options.from ??
- _defaultOpts?.from ??
- state.matches[matchIndex]!.fullPath
-
- return navigate({
+ return router.navigate({
...options,
- from,
+ from: options.from ?? _defaultOpts?.from,
})
},
- // eslint-disable-next-line react-hooks/exhaustive-deps
- [_defaultOpts?.from, navigate],
+ [_defaultOpts?.from, router],
) as UseNavigateResult
}
diff --git a/packages/react-router/tests/link.test.tsx b/packages/react-router/tests/link.test.tsx
index 80578b6f4a..1b19c3a63b 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,
@@ -67,7 +68,7 @@ const WAIT_TIME = 300
describe('Link', () => {
test('when using renderHook it returns a hook with same content to prove rerender works', async () => {
/**
- * This is the hook that will be testet.
+ * This is the hook that will be tested.
*
* @returns custom state
*/
@@ -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,791 @@ 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'))
+})
+
+describe('rewrite', () => {
+ test('renders hard link when rewrite points to different origin', async () => {
+ const rootRoute = createRootRoute()
+ const indexRoute = createRoute({
+ getParentRoute: () => rootRoute,
+ path: '/',
+ component: () => {
+ return (
+ <>
+ Index
+
+ Index
+
+
+ Info
+
+
+ App
+
+ >
+ )
+ },
+ })
+
+ const infoRoute = createRoute({
+ getParentRoute: () => rootRoute,
+ path: '/info',
+ component: () => {
+ return (
+ <>
+ Info
+ >
+ )
+ },
+ })
+
+ const appRoute = createRoute({
+ getParentRoute: () => rootRoute,
+ path: '/app',
+ component: () => {
+ return (
+ <>
+ App
+ >
+ )
+ },
+ })
+
+ const router = createRouter({
+ routeTree: rootRoute.addChildren([indexRoute, infoRoute, appRoute]),
+ history,
+ origin: 'http://example.com',
+ rewrite: {
+ input: ({ url }) => {
+ if (url.href.startsWith('http://app.example.com')) {
+ return url.href.replace('http://example.com/ap', '')
+ }
+ return undefined
+ },
+ output: ({ url }) => {
+ if (url.pathname.startsWith('/app')) {
+ ;((url.hostname = 'app.example.com'),
+ (url.pathname = url.pathname.replace(/^\/app/, '')))
+ }
+ return url
+ },
+ },
+ })
+
+ render( )
+
+ const infoLink = await screen.findByTestId('link-to-info')
+ expect(infoLink).toHaveAttribute('href', '/info')
+
+ const appLink = await screen.findByTestId('link-to-app')
+ expect(appLink).toHaveAttribute('href', 'http://app.example.com/')
+ })
+})
diff --git a/packages/react-router/tests/redirect.test.tsx b/packages/react-router/tests/redirect.test.tsx
index 3009c9ddd1..3308c76a36 100644
--- a/packages/react-router/tests/redirect.test.tsx
+++ b/packages/react-router/tests/redirect.test.tsx
@@ -359,6 +359,7 @@ describe('redirect', () => {
_fromLocation: {
hash: '',
href: '/',
+ publicHref: '/',
pathname: '/',
search: {},
searchStr: '',
@@ -367,6 +368,7 @@ describe('redirect', () => {
__TSR_key: currentRedirect.options._fromLocation!.state.__TSR_key,
key: currentRedirect.options._fromLocation!.state.key,
},
+ url: 'http://localhost/',
},
href: '/about',
to: '/about',
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..69d9b2df8e 100644
--- a/packages/react-router/tests/router.test.tsx
+++ b/packages/react-router/tests/router.test.tsx
@@ -8,6 +8,7 @@ import {
waitFor,
} from '@testing-library/react'
import { z } from 'zod'
+import { composeRewrites } from '@tanstack/router-core'
import {
Link,
Outlet,
@@ -18,6 +19,7 @@ import {
createRootRoute,
createRoute,
createRouter,
+ rewriteBasepath,
useNavigate,
} from '../src'
import type { StandardSchemaValidator } from '@tanstack/router-core'
@@ -59,7 +61,7 @@ export function validateSearchParams<
}
function createTestRouter(
- options: RouterOptions &
+ options: RouterOptions &
Required, 'history'>>,
) {
const rootRoute = createRootRoute({
@@ -343,7 +345,7 @@ describe('encoding: URL param segment for /posts/$slug', () => {
await act(() => router.load())
- expect(router.state.location.pathname).toBe('/posts/🚀')
+ expect(router.state.location.pathname).toBe('/posts/%F0%9F%9A%80')
})
it('state.location.pathname, should have the params.slug value of "100%25"', async () => {
@@ -592,7 +594,7 @@ describe('encoding: URL splat segment for /$', () => {
await router.load()
- expect(router.state.location.pathname).toBe('/🚀')
+ expect(router.state.location.pathname).toBe('/%F0%9F%9A%80')
})
it('state.location.pathname, should have the params._splat value of "100%25"', async () => {
@@ -636,7 +638,7 @@ describe('encoding: URL splat segment for /$', () => {
await router.load()
- expect(router.state.location.pathname).toBe(
+ expect(router.state.location.href).toBe(
'/framework%2Freact%2Fguide%2Ffile-based-routing%20tanstack',
)
})
@@ -650,8 +652,8 @@ describe('encoding: URL splat segment for /$', () => {
await router.load()
- expect(router.state.location.pathname).toBe(
- '/framework/react/guide/file-based-routing tanstack',
+ expect(router.state.location.href).toBe(
+ '/framework/react/guide/file-based-routing%20tanstack',
)
})
@@ -736,12 +738,11 @@ describe('encoding: URL path segment', () => {
it.each([
{
input: '/path-segment/%C3%A9',
- output: '/path-segment/é',
- type: 'encoded',
+ output: '/path-segment/%C3%A9',
},
{
input: '/path-segment/é',
- output: '/path-segment/é',
+ output: '/path-segment/%C3%A9',
type: 'not encoded',
},
{
@@ -761,53 +762,46 @@ describe('encoding: URL path segment', () => {
},
{
input: '/path-segment/%F0%9F%9A%80',
- output: '/path-segment/🚀',
- type: 'encoded',
+ output: '/path-segment/%F0%9F%9A%80',
},
{
input: '/path-segment/%F0%9F%9A%80to%2Fthe%2Fmoon',
- output: '/path-segment/🚀to%2Fthe%2Fmoon',
- type: 'encoded',
+ output: '/path-segment/%F0%9F%9A%80to%2Fthe%2Fmoon',
},
{
input: '/path-segment/%25%F0%9F%9A%80to%2Fthe%2Fmoon',
- output: '/path-segment/%25🚀to%2Fthe%2Fmoon',
- type: 'encoded',
+ output: '/path-segment/%25%F0%9F%9A%80to%2Fthe%2Fmoon',
},
{
input: '/path-segment/%F0%9F%9A%80to%2Fthe%2Fmoon%25',
- output: '/path-segment/🚀to%2Fthe%2Fmoon%25',
- type: 'encoded',
+ output: '/path-segment/%F0%9F%9A%80to%2Fthe%2Fmoon%25',
},
{
input:
'/path-segment/%F0%9F%9A%80to%2Fthe%2Fmoon%25%F0%9F%9A%80to%2Fthe%2Fmoon',
- output: '/path-segment/🚀to%2Fthe%2Fmoon%25🚀to%2Fthe%2Fmoon',
- type: 'encoded',
+ output:
+ '/path-segment/%F0%9F%9A%80to%2Fthe%2Fmoon%25%F0%9F%9A%80to%2Fthe%2Fmoon',
},
{
input: '/path-segment/🚀',
- output: '/path-segment/🚀',
+ output: '/path-segment/%F0%9F%9A%80',
type: 'not encoded',
},
{
input: '/path-segment/🚀to%2Fthe%2Fmoon',
- output: '/path-segment/🚀to%2Fthe%2Fmoon',
+ output: '/path-segment/%F0%9F%9A%80to%2Fthe%2Fmoon',
type: 'not encoded',
},
- ])(
- 'should resolve $input to $output when the path segment is $type',
- async ({ input, output }) => {
- const { router } = createTestRouter({
- history: createMemoryHistory({ initialEntries: [input] }),
- })
+ ])('should resolve $input to $output', async ({ input, output }) => {
+ const { router } = createTestRouter({
+ history: createMemoryHistory({ initialEntries: [input] }),
+ })
- render( )
- await act(() => router.load())
+ render( )
+ await act(() => router.load())
- expect(router.state.location.pathname).toBe(output)
- },
- )
+ expect(new URL(router.state.location.url).pathname).toBe(output)
+ })
})
describe('router emits events during rendering', () => {
@@ -1857,3 +1851,958 @@ describe('statusCode reset on navigation', () => {
expect(router.state.statusCode).toBe(404)
})
})
+
+describe('Router rewrite functionality', () => {
+ it('should rewrite URLs using input before router interprets them', async () => {
+ const rootRoute = createRootRoute({
+ component: () => ,
+ })
+
+ const newPathRoute = createRoute({
+ getParentRoute: () => rootRoute,
+ path: '/new-path',
+ component: () => New Path Content
,
+ })
+
+ const routeTree = rootRoute.addChildren([newPathRoute])
+
+ const router = createRouter({
+ routeTree,
+ history: createMemoryHistory({ initialEntries: ['/old-path'] }),
+ rewrite: {
+ input: ({ url }) => {
+ // Rewrite /old-path to /new-path
+
+ if (url.pathname === '/old-path') {
+ url.pathname = `/new-path`
+ }
+ return url
+ },
+ },
+ })
+
+ render( )
+
+ await waitFor(() => {
+ expect(screen.getByTestId('new-path')).toBeInTheDocument()
+ })
+
+ // Router should have interpreted the rewritten URL
+ expect(router.state.location.pathname).toBe('/new-path')
+ })
+
+ it('should handle input rewrite with complex URL transformations', async () => {
+ const rootRoute = createRootRoute({
+ component: () => ,
+ })
+
+ const usersRoute = createRoute({
+ getParentRoute: () => rootRoute,
+ path: '/users',
+ component: () => Users Content
,
+ })
+
+ const routeTree = rootRoute.addChildren([usersRoute])
+
+ const router = createRouter({
+ routeTree,
+ history: createMemoryHistory({
+ initialEntries: ['/legacy/users?page=1#top'],
+ }),
+ rewrite: {
+ input: ({ url }) => {
+ // Rewrite legacy URLs to new format
+ if (url.pathname === '/legacy/users') {
+ url.pathname = `/users`
+ }
+ return url
+ },
+ },
+ })
+
+ render( )
+
+ await waitFor(() => {
+ expect(screen.getByTestId('users')).toBeInTheDocument()
+ })
+
+ // Router should have interpreted the rewritten URL
+ expect(router.state.location.pathname).toBe('/users')
+ expect(router.state.location.search).toEqual({ page: 1 })
+ expect(router.state.location.hash).toBe('top')
+ })
+
+ it('should handle multiple input rewrite conditions', async () => {
+ const rootRoute = createRootRoute({
+ component: () => ,
+ })
+
+ const homeRoute = createRoute({
+ getParentRoute: () => rootRoute,
+ path: '/',
+ component: () => Home Content
,
+ })
+
+ const aboutRoute = createRoute({
+ getParentRoute: () => rootRoute,
+ path: '/about',
+ component: () => About Content
,
+ })
+
+ const routeTree = rootRoute.addChildren([homeRoute, aboutRoute])
+
+ const router = createRouter({
+ routeTree,
+ history: createMemoryHistory({ initialEntries: ['/old-about'] }),
+ rewrite: {
+ input: ({ url }) => {
+ // Multiple rewrite rules
+ if (url.pathname === '/old-home' || url.pathname === '/home') {
+ url.pathname = '/'
+ }
+ if (url.pathname === '/old-about' || url.pathname === '/info') {
+ url.pathname = '/about'
+ }
+ return url
+ },
+ },
+ })
+
+ render( )
+
+ await waitFor(() => {
+ expect(screen.getByTestId('about')).toBeInTheDocument()
+ })
+
+ expect(router.state.location.pathname).toBe('/about')
+ })
+
+ it('should handle input rewrite with search params and hash preservation', async () => {
+ const rootRoute = createRootRoute({
+ component: () => ,
+ })
+
+ const docsRoute = createRoute({
+ getParentRoute: () => rootRoute,
+ path: '/docs',
+ component: () => Documentation
,
+ })
+
+ const routeTree = rootRoute.addChildren([docsRoute])
+
+ const router = createRouter({
+ routeTree,
+ history: createMemoryHistory({
+ initialEntries: ['/old/documentation?version=v2&lang=en#installation'],
+ }),
+ rewrite: {
+ input: ({ url }) => {
+ // Rewrite old docs URL structure
+ if (url.pathname === '/old/documentation') {
+ url.pathname = `/docs`
+ return url
+ }
+ return undefined
+ },
+ },
+ })
+
+ render( )
+
+ await waitFor(() => {
+ expect(screen.getByTestId('docs')).toBeInTheDocument()
+ })
+
+ // Verify the URL was rewritten correctly with search params and hash preserved
+ expect(router.state.location.pathname).toBe('/docs')
+ expect(router.state.location.search).toEqual({
+ version: 'v2',
+ lang: 'en',
+ })
+ expect(router.state.location.hash).toBe('installation')
+ })
+
+ it('should handle subdomain to path rewriting with input', async () => {
+ const rootRoute = createRootRoute({
+ component: () => ,
+ })
+
+ const apiRoute = createRoute({
+ getParentRoute: () => rootRoute,
+ path: '/$stage/users',
+ component: () => (
+ {apiRoute.useParams().stage} Users
+ ),
+ })
+
+ const routeTree = rootRoute.addChildren([apiRoute])
+
+ const router = createRouter({
+ routeTree,
+ history: createMemoryHistory({
+ initialEntries: ['https://test.domain.com/users'],
+ }),
+ rewrite: {
+ input: ({ url }) => {
+ // Rewrite test.domain.com/path to /test/path (subdomain becomes path segment)
+ if (url.hostname.startsWith('test.domain.com')) {
+ url.pathname = `/test${url.pathname}`
+ return url
+ }
+ return undefined
+ },
+ },
+ })
+ render( )
+ await router.latestLoadPromise
+ await waitFor(() => {
+ expect(screen.getByTestId('component')).toHaveTextContent('test Users')
+ })
+
+ // Router should have interpreted the rewritten URL
+ expect(router.state.location.pathname).toBe('/test/users')
+ })
+
+ it('should handle hostname-based routing with input rewrite', async () => {
+ const rootRoute = createRootRoute({
+ component: () => ,
+ })
+
+ const appRoute = createRoute({
+ getParentRoute: () => rootRoute,
+ path: '/app',
+ component: () => App Content
,
+ })
+
+ const adminRoute = createRoute({
+ getParentRoute: () => rootRoute,
+ path: '/admin',
+ component: () => Admin Content
,
+ })
+
+ const routeTree = rootRoute.addChildren([appRoute, adminRoute])
+
+ const router = createRouter({
+ routeTree,
+ history: createMemoryHistory({
+ initialEntries: ['https://admin.example.com/dashboard'],
+ }),
+ rewrite: {
+ input: ({ url }) => {
+ // Route based on subdomain
+ if (url.hostname === 'admin.example.com') {
+ url.pathname = '/admin'
+ }
+ if (url.hostname === 'app.example.com') {
+ url.pathname = '/app'
+ }
+ return url
+ },
+ },
+ })
+
+ render( )
+
+ await waitFor(() => {
+ expect(screen.getByTestId('admin')).toBeInTheDocument()
+ })
+
+ expect(router.state.location.pathname).toBe('/admin')
+ })
+
+ it('should handle multiple URL transformation patterns', async () => {
+ const rootRoute = createRootRoute({
+ component: () => ,
+ })
+
+ const productsRoute = createRoute({
+ getParentRoute: () => rootRoute,
+ path: '/products',
+ component: () => Products
,
+ })
+
+ const blogRoute = createRoute({
+ getParentRoute: () => rootRoute,
+ path: '/blog',
+ component: () => Blog
,
+ })
+
+ const routeTree = rootRoute.addChildren([productsRoute, blogRoute])
+
+ const router = createRouter({
+ routeTree,
+ history: createMemoryHistory({
+ initialEntries: ['/old/shop/items?category=electronics'],
+ }),
+ rewrite: {
+ input: ({ url }) => {
+ // Multiple transformation patterns
+ if (url.pathname === '/old/shop/items') {
+ url.pathname = `/products`
+ }
+ if (url.pathname.startsWith('/legacy/')) {
+ url.pathname = url.pathname.replace('/legacy/', '/blog/')
+ }
+ if (url.pathname.startsWith('/v1/')) {
+ url.pathname = url.pathname.replace('/v1/', '/')
+ }
+ return url
+ },
+ },
+ })
+
+ render( )
+
+ await waitFor(() => {
+ expect(screen.getByTestId('products')).toBeInTheDocument()
+ })
+
+ expect(router.state.location.pathname).toBe('/products')
+ expect(router.state.location.search).toEqual({ category: 'electronics' })
+ })
+
+ it('should handle rewriting subdomain and path', async () => {
+ const rootRoute = createRootRoute({
+ component: () => ,
+ })
+
+ const apiRoute = createRoute({
+ getParentRoute: () => rootRoute,
+ path: '/api/v2',
+ component: () => API v2
,
+ })
+
+ const routeTree = rootRoute.addChildren([apiRoute])
+
+ const router = createRouter({
+ routeTree,
+ history: createMemoryHistory({
+ initialEntries: ['https://legacy.example.com/api/v1'],
+ }),
+ rewrite: {
+ input: ({ url }) => {
+ if (
+ url.hostname === 'legacy.example.com' &&
+ url.pathname === '/api/v1'
+ ) {
+ return 'https://api.example.com/api/v2'
+ }
+ return undefined
+ },
+ },
+ })
+
+ render( )
+
+ await waitFor(() => {
+ expect(screen.getByTestId('api-v2')).toBeInTheDocument()
+ })
+
+ expect(router.state.location.pathname).toBe('/api/v2')
+ })
+
+ it('should handle rewriting subdomain, path and search', async () => {
+ const rootRoute = createRootRoute({
+ component: () => ,
+ })
+
+ const newApiRoute = createRoute({
+ getParentRoute: () => rootRoute,
+ path: '/api/v3/users',
+ component: () => API v3 Users
,
+ })
+
+ const routeTree = rootRoute.addChildren([newApiRoute])
+
+ const router = createRouter({
+ routeTree,
+ history: createMemoryHistory({
+ initialEntries: [
+ 'https://old-api.company.com/users?limit=10&offset=20',
+ ],
+ }),
+ rewrite: {
+ input: ({ url }) => {
+ if (
+ url.hostname === 'old-api.company.com' &&
+ url.pathname === '/users'
+ ) {
+ url.hostname = 'api.company.com'
+ url.pathname = '/api/v3/users'
+ url.searchParams.set('version', '3')
+ return url
+ }
+ return undefined
+ },
+ },
+ })
+
+ render( )
+
+ await waitFor(() => {
+ expect(screen.getByTestId('api-v3')).toBeInTheDocument()
+ })
+
+ expect(router.state.location.pathname).toBe('/api/v3/users')
+ expect(router.state.location.search).toEqual({
+ limit: 10,
+ offset: 20,
+ version: 3,
+ })
+ })
+
+ it('should handle complex URL mutations with hostname and search params', async () => {
+ const rootRoute = createRootRoute({
+ component: () => ,
+ })
+
+ const blogRoute = createRoute({
+ getParentRoute: () => rootRoute,
+ path: '/content/blog',
+ component: () => Blog Content
,
+ })
+
+ const routeTree = rootRoute.addChildren([blogRoute])
+
+ const router = createRouter({
+ routeTree,
+ history: createMemoryHistory({
+ initialEntries: [
+ 'https://blog.oldsite.com/posts?category=tech&year=2024#top',
+ ],
+ }),
+ rewrite: {
+ input: ({ url }) => {
+ // Mutate URL: change subdomain to path, preserve params and hash
+ if (url.hostname === 'blog.oldsite.com') {
+ url.hostname = 'newsite.com'
+ url.pathname = '/content/blog'
+ url.searchParams.set('source', 'migration')
+ // Keep existing search params and hash
+ return url.href
+ }
+ return undefined
+ },
+ },
+ })
+
+ render( )
+
+ await waitFor(() => {
+ expect(screen.getByTestId('blog')).toBeInTheDocument()
+ })
+
+ expect(router.state.location.pathname).toBe('/content/blog')
+ expect(router.state.location.search).toEqual({
+ category: 'tech',
+ year: 2024,
+ source: 'migration',
+ })
+ expect(router.state.location.hash).toBe('top')
+ })
+
+ it('should handle returning new URL instance vs mutating existing one', async () => {
+ const rootRoute = createRootRoute({
+ component: () => ,
+ })
+
+ const shopRoute = createRoute({
+ getParentRoute: () => rootRoute,
+ path: '/shop/products',
+ component: () => Shop Products
,
+ })
+
+ const routeTree = rootRoute.addChildren([shopRoute])
+
+ const router = createRouter({
+ routeTree,
+ history: createMemoryHistory({
+ initialEntries: ['https://store.example.com/items?id=123'],
+ }),
+ rewrite: {
+ input: ({ url }) => {
+ // Alternative pattern: create new URL instance and return it
+
+ if (
+ url.hostname === 'store.example.com' &&
+ url.pathname === '/items'
+ ) {
+ const newUrl = new URL('https://example.com/shop/products')
+ newUrl.searchParams.set(
+ 'productId',
+ url.searchParams.get('id') || '',
+ )
+ newUrl.searchParams.set('migrated', 'true')
+ return newUrl
+ }
+ return undefined
+ },
+ },
+ })
+
+ render( )
+
+ await waitFor(() => {
+ expect(screen.getByTestId('shop')).toBeInTheDocument()
+ })
+
+ expect(router.state.location.pathname).toBe('/shop/products')
+ expect(router.state.location.search).toEqual({
+ productId: 123,
+ migrated: true,
+ })
+ })
+
+ it('should handle output rewrite when navigating', async () => {
+ // This test demonstrates expected output behavior for programmatic navigation
+ const Navigate = () => {
+ const navigate = useNavigate()
+ return (
+ navigate({ to: '/dashboard' })}
+ >
+ Navigate to Dashboard
+
+ )
+ }
+
+ const rootRoute = createRootRoute()
+
+ const indexRoute = createRoute({
+ getParentRoute: () => rootRoute,
+ path: '/',
+ component: Navigate,
+ })
+
+ const dashboardRoute = createRoute({
+ getParentRoute: () => rootRoute,
+ path: '/dashboard',
+ component: () => Dashboard
,
+ })
+
+ const routeTree = rootRoute.addChildren([indexRoute, dashboardRoute])
+
+ const history = createMemoryHistory({ initialEntries: ['/'] })
+ const router = createRouter({
+ routeTree,
+ history,
+ rewrite: {
+ output: ({ url }) => {
+ if (url.pathname === '/dashboard') {
+ url.pathname = '/admin/panel'
+ return url
+ }
+ return undefined
+ },
+ input: ({ url }) => {
+ if (url.pathname === '/admin/panel') {
+ url.pathname = '/dashboard'
+ return url
+ }
+ return undefined
+ },
+ },
+ })
+
+ render( )
+
+ const navigateBtn = await screen.findByTestId('navigate-btn')
+
+ fireEvent.click(navigateBtn)
+ await router.latestLoadPromise
+
+ await screen.findByTestId('dashboard')
+
+ // Router internal state should show the internal path
+ expect(router.state.location.pathname).toBe('/dashboard')
+
+ // History should be updated with the rewritten path due to output
+ expect(history.location.pathname).toBe('/admin/panel')
+ })
+
+ it('should handle output rewrite with Link navigation', async () => {
+ // This test demonstrates expected output behavior for Link-based navigation
+ const rootRoute = createRootRoute({
+ component: () => ,
+ })
+
+ const indexRoute = createRoute({
+ getParentRoute: () => rootRoute,
+ path: '/',
+ component: () => (
+
+
+ Go to Profile
+
+
+ ),
+ })
+
+ const profileRoute = createRoute({
+ getParentRoute: () => rootRoute,
+ path: '/profile',
+ component: () => User Profile
,
+ })
+
+ const routeTree = rootRoute.addChildren([indexRoute, profileRoute])
+
+ const history = createMemoryHistory({ initialEntries: ['/'] })
+ const router = createRouter({
+ routeTree,
+ history,
+ rewrite: {
+ output: ({ url }) => {
+ if (url.pathname === '/profile') {
+ url.pathname = '/user'
+ return url
+ }
+ return undefined
+ },
+ input: ({ url }) => {
+ if (url.pathname === '/user') {
+ url.pathname = '/profile'
+ return url
+ }
+ return undefined
+ },
+ },
+ })
+
+ render( )
+
+ const profileLink = await screen.findByTestId('profile-link')
+
+ fireEvent.click(profileLink)
+
+ expect(await screen.findByTestId('profile')).toBeInTheDocument()
+
+ expect(router.state.location.pathname).toBe('/profile')
+
+ expect(history.location.pathname).toBe('/user')
+ })
+})
+
+describe('rewriteBasepath utility', () => {
+ it('should handle basic basepath rewriting with input', async () => {
+ const rootRoute = createRootRoute({
+ component: () => ,
+ })
+
+ const homeRoute = createRoute({
+ getParentRoute: () => rootRoute,
+ path: '/',
+ component: () => Home
,
+ })
+
+ const aboutRoute = createRoute({
+ getParentRoute: () => rootRoute,
+ path: '/about',
+ component: () => About
,
+ })
+
+ const routeTree = rootRoute.addChildren([homeRoute, aboutRoute])
+
+ const router = createRouter({
+ routeTree,
+ history: createMemoryHistory({
+ initialEntries: ['/my-app/about'],
+ }),
+ rewrite: rewriteBasepath({ basepath: 'my-app' }),
+ })
+
+ render( )
+
+ await waitFor(() => {
+ expect(screen.getByTestId('about')).toBeInTheDocument()
+ })
+
+ // Router should interpret the URL without the basepath
+ expect(router.state.location.pathname).toBe('/about')
+ })
+
+ it('should handle basepath with leading and trailing slashes', async () => {
+ const rootRoute = createRootRoute({
+ component: () => ,
+ })
+
+ const usersRoute = createRoute({
+ getParentRoute: () => rootRoute,
+ path: '/users',
+ component: () => Users
,
+ })
+
+ const routeTree = rootRoute.addChildren([usersRoute])
+
+ const router = createRouter({
+ routeTree,
+ history: createMemoryHistory({
+ initialEntries: ['/api/v1/users'],
+ }),
+ rewrite: rewriteBasepath({ basepath: '/api/v1/' }), // With leading and trailing slashes
+ })
+
+ render( )
+
+ await waitFor(() => {
+ expect(screen.getByTestId('users')).toBeInTheDocument()
+ })
+
+ expect(router.state.location.pathname).toBe('/users')
+ })
+
+ it('should handle empty basepath gracefully', async () => {
+ const rootRoute = createRootRoute({
+ component: () => ,
+ })
+
+ const testRoute = createRoute({
+ getParentRoute: () => rootRoute,
+ path: '/test',
+ component: () => Test
,
+ })
+
+ const routeTree = rootRoute.addChildren([testRoute])
+
+ const router = createRouter({
+ routeTree,
+ history: createMemoryHistory({
+ initialEntries: ['/test'],
+ }),
+ rewrite: rewriteBasepath({ basepath: '' }), // Empty basepath
+ })
+
+ render( )
+
+ expect(await screen.findByTestId('test')).toBeInTheDocument()
+
+ expect(router.state.location.pathname).toBe('/test')
+ })
+
+ it('should combine basepath with additional input rewrite logic', async () => {
+ const rootRoute = createRootRoute({
+ component: () => ,
+ })
+
+ const newApiRoute = createRoute({
+ getParentRoute: () => rootRoute,
+ path: '/api/v2',
+ component: () => API v2
,
+ })
+
+ const routeTree = rootRoute.addChildren([newApiRoute])
+
+ const router = createRouter({
+ routeTree,
+ history: createMemoryHistory({
+ initialEntries: ['/my-app/legacy/api/v1'],
+ }),
+ rewrite: composeRewrites([
+ rewriteBasepath({ basepath: 'my-app' }),
+ {
+ // Additional rewrite logic after basepath removal
+ input: ({ url }) => {
+ if (url.pathname === '/legacy/api/v1') {
+ url.pathname = '/api/v2'
+ return url
+ }
+ return undefined
+ },
+ },
+ ]),
+ })
+
+ render( )
+
+ expect(await screen.findByTestId('api-v2')).toBeInTheDocument()
+
+ // Should first remove basepath (/my-app/legacy/api/v1 -> /legacy/api/v1)
+ // Then apply additional rewrite (/legacy/api/v1 -> /api/v2)
+ expect(router.state.location.pathname).toBe('/api/v2')
+ })
+
+ it('should handle complex basepath with subdomain-style paths', async () => {
+ const rootRoute = createRootRoute({
+ component: () => ,
+ })
+
+ const dashboardRoute = createRoute({
+ getParentRoute: () => rootRoute,
+ path: '/dashboard',
+ component: () => Dashboard
,
+ })
+
+ const routeTree = rootRoute.addChildren([dashboardRoute])
+
+ const router = createRouter({
+ routeTree,
+ history: createMemoryHistory({
+ initialEntries: ['/tenant-123/dashboard'],
+ }),
+ rewrite: rewriteBasepath({ basepath: 'tenant-123' }),
+ })
+
+ render( )
+
+ await waitFor(() => {
+ expect(screen.getByTestId('dashboard')).toBeInTheDocument()
+ })
+
+ expect(router.state.location.pathname).toBe('/dashboard')
+ })
+
+ it('should preserve search params and hash when rewriting basepath', async () => {
+ const rootRoute = createRootRoute({
+ component: () => ,
+ })
+
+ const searchRoute = createRoute({
+ getParentRoute: () => rootRoute,
+ path: '/search',
+ component: () => Search
,
+ })
+
+ const routeTree = rootRoute.addChildren([searchRoute])
+
+ const router = createRouter({
+ routeTree,
+ history: createMemoryHistory({
+ initialEntries: ['/app/search?q=test&filter=all#results'],
+ }),
+ rewrite: rewriteBasepath({ basepath: 'app' }),
+ })
+
+ render( )
+
+ await waitFor(() => {
+ expect(screen.getByTestId('search')).toBeInTheDocument()
+ })
+
+ expect(router.state.location.pathname).toBe('/search')
+ expect(router.state.location.search).toEqual({
+ q: 'test',
+ filter: 'all',
+ })
+ expect(router.state.location.hash).toBe('results')
+ })
+
+ it('should handle nested basepath with multiple rewrite layers', async () => {
+ const rootRoute = createRootRoute({
+ component: () => ,
+ })
+
+ const finalRoute = createRoute({
+ getParentRoute: () => rootRoute,
+ path: '/final',
+ component: () => Final
,
+ })
+
+ const routeTree = rootRoute.addChildren([finalRoute])
+
+ const router = createRouter({
+ routeTree,
+ history: createMemoryHistory({
+ initialEntries: ['/base/legacy/old/path'],
+ }),
+ rewrite: composeRewrites([
+ rewriteBasepath({ basepath: 'base' }),
+ {
+ input: ({ url }) => {
+ // First layer: convert legacy paths
+ if (url.pathname === '/legacy/old/path') {
+ url.pathname = '/new/path'
+ return url
+ }
+ return undefined
+ },
+ output: ({ url }) => {
+ // First layer: convert legacy paths
+ if (url.pathname === '/new/path') {
+ url.pathname = '/legacy/old/path'
+ return url
+ }
+ return undefined
+ },
+ },
+ ]),
+ })
+
+ // Add a second rewrite layer
+ const originalRewrite = router.options.rewrite
+ router.update({
+ rewrite: composeRewrites([
+ originalRewrite!,
+ {
+ input: ({ url }) => {
+ if (url.pathname === '/new/path') {
+ url.pathname = '/final'
+ }
+ return url
+ },
+ output: ({ url }) => {
+ if (url.pathname === '/final') {
+ url.pathname = '/new/path'
+ }
+ return url
+ },
+ },
+ ]),
+ })
+
+ render( )
+
+ expect(router.state.location.pathname).toBe('/final')
+ expect(await screen.findByTestId('final')).toBeInTheDocument()
+
+ // Should apply: /base/legacy/old/path -> /legacy/old/path -> /new/path -> /final
+ })
+
+ it('should handle basepath with output rewriting', async () => {
+ // This test verifies that basepath is added back when navigating
+
+ const rootRoute = createRootRoute({
+ component: () => ,
+ })
+
+ const indexRoute = createRoute({
+ getParentRoute: () => rootRoute,
+ path: '/',
+ component: () => (
+
+
+ About
+
+
+ ),
+ })
+
+ const aboutRoute = createRoute({
+ getParentRoute: () => rootRoute,
+ path: '/about',
+ component: () => About
,
+ })
+
+ const routeTree = rootRoute.addChildren([indexRoute, aboutRoute])
+
+ const history = createMemoryHistory({ initialEntries: ['/my-app/'] })
+
+ const router = createRouter({
+ routeTree,
+ history,
+ rewrite: rewriteBasepath({ basepath: 'my-app' }),
+ })
+
+ render( )
+
+ const aboutLink = await screen.findByTestId('about-link')
+
+ fireEvent.click(aboutLink)
+
+ await waitFor(() => {
+ expect(screen.getByTestId('about')).toBeInTheDocument()
+ })
+
+ expect(router.state.location.pathname).toBe('/about')
+ expect(history.location.pathname).toBe('/my-app/about')
+ })
+})
diff --git a/packages/react-router/tests/useNavigate.test.tsx b/packages/react-router/tests/useNavigate.test.tsx
index 8d98abdf28..9578a7a1e1 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,13 +2313,20 @@ describe.each([{ basepath: '' }, { basepath: '/basepath' }])(
return (
<>
Param Route
- navigate({ to: './a' })}>
+
+ navigate({ from: paramRoute.fullPath, to: './a' })
+ }
+ >
Link to ./a
navigate({ params: { param: 'bar' } as any })}
+ data-testid="btn-param-bar"
+ onClick={() =>
+ navigate({ to: '.', params: { param: 'bar' } as any })
+ }
>
- Link to . with param:bar
+ Navigate to to . with param:bar
>
@@ -1997,9 +2342,19 @@ describe.each([{ basepath: '' }, { basepath: '/basepath' }])(
return (
<>
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
+
>
)
@@ -2057,9 +2412,8 @@ describe.each([{ basepath: '' }, { basepath: '/basepath' }])(
const parentLink = await screen.findByText('Link to Parent')
// Click the link and ensure the new location
- await act(async () => {
- fireEvent.click(parentLink)
- })
+ fireEvent.click(parentLink)
+ await router.latestLoadPromise
expect(window.location.pathname).toBe(`${basepath}/a`)
})
@@ -2078,9 +2432,8 @@ describe.each([{ basepath: '' }, { basepath: '/basepath' }])(
const parentLink = await screen.findByText('Link to Parent')
// Click the link and ensure the new location
- await act(async () => {
- fireEvent.click(parentLink)
- })
+ fireEvent.click(parentLink)
+ await router.latestLoadPromise
expect(window.location.pathname).toBe(`${basepath}/param/foo/a`)
})
@@ -2101,9 +2454,8 @@ describe.each([{ basepath: '' }, { basepath: '/basepath' }])(
)
// Click the link and ensure the new location
- await act(async () => {
- fireEvent.click(parentLink)
- })
+ fireEvent.click(parentLink)
+ await router.latestLoadPromise
expect(window.location.pathname).toBe(`${basepath}/param/bar/a`)
})
@@ -2121,9 +2473,8 @@ describe.each([{ basepath: '' }, { basepath: '/basepath' }])(
const relativeLink = await screen.findByText('Link to ./a')
// Click the link and ensure the new location
- await act(async () => {
- fireEvent.click(relativeLink)
- })
+ fireEvent.click(relativeLink)
+ await router.latestLoadPromise
expect(window.location.pathname).toBe(`${basepath}/param/foo/a`)
})
@@ -2143,13 +2494,30 @@ describe.each([{ basepath: '' }, { basepath: '/basepath' }])(
)
// Click the link and ensure the new location
- await act(async () => {
- fireEvent.click(relativeLink)
- })
+ fireEvent.click(relativeLink)
+ await router.latestLoadPromise
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
+ fireEvent.click(relativeLink)
+ await router.latestLoadPromise
+
+ expect(window.location.pathname).toBe(`${basepath}/param/foo/a`)
+ })
+
test('should navigate to same route with different params', async () => {
const router = setupRouter()
@@ -2157,13 +2525,13 @@ describe.each([{ basepath: '' }, { basepath: '/basepath' }])(
await act(async () => {
history.push(`${basepath}/param/foo/a/b`)
+ await router.latestLoadPromise
})
+ expect(window.location.pathname).toBe(`${basepath}/param/foo/a/b`)
- const parentLink = await screen.findByText('Link to . with param:bar')
-
- await act(async () => {
- fireEvent.click(parentLink)
- })
+ const btn = screen.getByTestId('btn-param-bar')
+ fireEvent.click(btn)
+ await router.latestLoadPromise
expect(window.location.pathname).toBe(`${basepath}/param/bar/a/b`)
})
diff --git a/packages/react-start-client/package.json b/packages/react-start-client/package.json
index d7c1709c2d..18c4a8a950 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.16",
"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/StartClient.tsx b/packages/react-start-client/src/StartClient.tsx
index 7cf791aa9d..c34df4d498 100644
--- a/packages/react-start-client/src/StartClient.tsx
+++ b/packages/react-start-client/src/StartClient.tsx
@@ -1,21 +1,18 @@
import { Await, RouterProvider } from '@tanstack/react-router'
-import { hydrate } from '@tanstack/start-client-core'
+import { hydrateStart } from '@tanstack/start-client-core'
+import type { CreateStart } from '@tanstack/start-client-core'
import type { AnyRouter } from '@tanstack/router-core'
-let hydrationPromise: Promise>> | undefined
+let hydrationPromise: Promise | undefined
-export function StartClient(props: { router: AnyRouter }) {
+export function StartClient({ createStart }: { createStart: CreateStart }) {
if (!hydrationPromise) {
- if (!props.router.state.matches.length) {
- hydrationPromise = hydrate(props.router)
- } else {
- hydrationPromise = Promise.resolve()
- }
+ hydrationPromise = hydrateStart(createStart)
}
return (
}
+ children={(router) => }
/>
)
}
diff --git a/packages/react-start-client/src/index.tsx b/packages/react-start-client/src/index.tsx
index d728c17e0f..11d1e7aebd 100644
--- a/packages/react-start-client/src/index.tsx
+++ b/packages/react-start-client/src/index.tsx
@@ -1,14 +1,12 @@
export {
mergeHeaders,
- startSerializer,
createIsomorphicFn,
createServerFn,
createMiddleware,
- registerGlobalMiddleware,
- globalMiddleware,
- serverOnly,
- clientOnly,
+ createServerOnlyFn,
+ createClientOnlyFn,
json,
+ createClientRpc,
} from '@tanstack/start-client-core'
export {
type DehydratedRouter,
@@ -26,7 +24,6 @@ export {
type FetcherBaseOptions,
type ServerFn,
type ServerFnCtx,
- type ServerFnResponseType,
type JsonResponse,
type IntersectAllValidatorInputs,
type IntersectAllValidatorOutputs,
@@ -54,9 +51,8 @@ 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'
+
+export * from '@tanstack/start-client-core'
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..9157a528d1 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.16",
"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..a224cffa66 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.17",
"description": "Modern and scalable routing for React applications",
"author": "Tanner Linsley",
"license": "MIT",
@@ -27,7 +27,7 @@
"clean": "rimraf ./dist && rimraf ./coverage",
"test": "pnpm test:build",
"test:build": "exit 0; vitest",
- "build": "vite build"
+ "build": "vite build && vite build -c vite.config.server-entry.ts"
},
"type": "module",
"types": "dist/esm/client.d.ts",
@@ -36,60 +36,30 @@
"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"
+ "types": "./dist/esm/plugin/vite.d.ts",
+ "default": "./dist/esm/plugin/vite.js"
}
},
- "./server-functions-client": {
+ "./server-entry": {
"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/default-entry/esm/server.d.ts",
+ "default": "./dist/default-entry/esm/server.js"
}
},
"./package.json": "./package.json"
@@ -100,22 +70,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/default-entry/client.tsx b/packages/react-start/src/default-entry/client.tsx
new file mode 100644
index 0000000000..09dd196aae
--- /dev/null
+++ b/packages/react-start/src/default-entry/client.tsx
@@ -0,0 +1,13 @@
+import { StrictMode, startTransition } from 'react'
+import { hydrateRoot } from 'react-dom/client'
+import { StartClient } from '@tanstack/react-start'
+import { createStart } from '#tanstack-start-createStart-entry'
+
+startTransition(() => {
+ hydrateRoot(
+ document,
+
+
+ ,
+ )
+})
diff --git a/packages/react-start/src/default-entry/createStart-entry.d.ts b/packages/react-start/src/default-entry/createStart-entry.d.ts
new file mode 100644
index 0000000000..cffb4e5104
--- /dev/null
+++ b/packages/react-start/src/default-entry/createStart-entry.d.ts
@@ -0,0 +1,4 @@
+declare module '#tanstack-start-createStart-entry' {
+ // eslint-disable-next-line @typescript-eslint/consistent-type-imports
+ export const createStart: import('@tanstack/react-start-client').CreateStart
+}
diff --git a/packages/react-start/src/default-entry/server.ts b/packages/react-start/src/default-entry/server.ts
new file mode 100644
index 0000000000..ca7afa23fc
--- /dev/null
+++ b/packages/react-start/src/default-entry/server.ts
@@ -0,0 +1,16 @@
+import {
+ createStartHandler,
+ defaultStreamHandler,
+} from '@tanstack/react-start/server'
+import type { RequestHandler } from '@tanstack/react-start/server'
+
+import { createStart } from '#tanstack-start-createStart-entry'
+
+// Providing `RequestHandler` from `@tanstack/react-start/server` is required so that the output types don't import it from `@tanstack/start-server-core`
+const fetch: RequestHandler = createStartHandler({
+ createStart,
+})(defaultStreamHandler)
+
+export default {
+ fetch,
+}
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/vite.ts b/packages/react-start/src/plugin/vite.ts
new file mode 100644
index 0000000000..05a52d2dd0
--- /dev/null
+++ b/packages/react-start/src/plugin/vite.ts
@@ -0,0 +1,100 @@
+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(environmentName, options) {
+ return {
+ resolve: {
+ dedupe: [
+ 'react',
+ 'react-dom',
+ '@tanstack/react-start',
+ '@tanstack/react-router',
+ ],
+ external:
+ options.resolve?.noExternal === true || !isInsideRouterMonoRepo
+ ? undefined
+ : ['@tanstack/react-router', '@tanstack/react-router-devtools'],
+ },
+ optimizeDeps:
+ environmentName === VITE_ENVIRONMENT_NAMES.client ||
+ (environmentName === VITE_ENVIRONMENT_NAMES.server &&
+ // This indicates that the server environment has opted in to dependency optimization
+ options.optimizeDeps?.noDiscovery === false)
+ ? {
+ // As `@tanstack/react-start` depends on `@tanstack/react-router`, we should exclude both.
+ exclude: [
+ '@tanstack/react-start',
+ '@tanstack/react-router',
+ '@tanstack/react-router-devtools',
+ ],
+ include: [
+ 'react',
+ 'react/jsx-runtime',
+ 'react/jsx-dev-runtime',
+ 'react-dom',
+ ...(environmentName === VITE_ENVIRONMENT_NAMES.client
+ ? ['react-dom/client']
+ : ['react-dom/server']),
+ // `@tanstack/react-store` has a dependency on `use-sync-external-store`, which is CJS.
+ // It therefore needs to included so that it is converted to ESM.
+ '@tanstack/react-router > @tanstack/react-store',
+ ],
+ }
+ : undefined,
+ }
+ },
+ },
+ TanStackStartVitePluginCore(
+ {
+ framework: 'react',
+ defaultEntryPaths,
+ },
+ 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/tsconfig.json b/packages/react-start/tsconfig.json
index 51dda9abf2..81f8715af3 100644
--- a/packages/react-start/tsconfig.json
+++ b/packages/react-start/tsconfig.json
@@ -4,5 +4,5 @@
"jsx": "react-jsx",
"module": "esnext"
},
- "include": ["src", "vite.config.ts"]
+ "include": ["src", "vite.config.ts", "vite.config.server-entry.ts"]
}
diff --git a/packages/react-start/vite.config.server-entry.ts b/packages/react-start/vite.config.server-entry.ts
new file mode 100644
index 0000000000..ac34689fe4
--- /dev/null
+++ b/packages/react-start/vite.config.server-entry.ts
@@ -0,0 +1,13 @@
+import { tanstackViteConfig } from '@tanstack/config/vite'
+
+export default tanstackViteConfig({
+ srcDir: './src/default-entry',
+ exclude: ['./src/default-entry/client.tsx'],
+ entry: ['./src/default-entry/server.ts'],
+ externalDeps: [
+ '@tanstack/react-start/server',
+ '#tanstack-start-createStart-entry',
+ ],
+ outDir: './dist/default-entry',
+ cjs: false,
+})
diff --git a/packages/react-start/vite.config.ts b/packages/react-start/vite.config.ts
index 99fd4a8b00..8763770db7 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/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',
- ],
+ exclude: ['./src/default-entry'],
+ 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',
],
+ cjs: false,
}),
)
diff --git a/packages/router-cli/package.json b/packages/router-cli/package.json
index 0651388c19..2133bb0173 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.16",
"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..ff485d7ad0 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.16",
"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..dfd35a7d40 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,11 @@ export interface FileRouteOptions<
TBeforeLoadFn = AnyContext,
TLoaderDeps extends Record = {},
TLoaderFn = undefined,
+ TSSR = unknown,
+ TServerMiddlewares = unknown,
+ THandlers = undefined,
> extends FileBaseRouteOptions<
+ TRegister,
TParentRoute,
TId,
TPath,
@@ -54,7 +60,11 @@ export interface FileRouteOptions<
TLoaderFn,
AnyContext,
TRouteContextFn,
- TBeforeLoadFn
+ TBeforeLoadFn,
+ AnyContext,
+ TSSR,
+ TServerMiddlewares,
+ THandlers
>,
UpdatableRouteOptions<
TParentRoute,
@@ -76,14 +86,19 @@ 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,
+ TServerMiddlewares = unknown,
+ THandlers = undefined,
>(
options?: FileRouteOptions<
+ TRegister,
TFilePath,
TParentRoute,
TId,
@@ -94,9 +109,13 @@ export type CreateFileRoute<
TRouteContextFn,
TBeforeLoadFn,
TLoaderDeps,
- TLoaderFn
+ TLoaderFn,
+ TSSR,
+ TServerMiddlewares,
+ THandlers
>,
) => Route<
+ TRegister,
TParentRoute,
TPath,
TFullPath,
@@ -110,7 +129,10 @@ export type CreateFileRoute<
TLoaderDeps,
TLoaderFn,
unknown,
- unknown
+ unknown,
+ TSSR,
+ TServerMiddlewares,
+ THandlers
>
export type LazyRouteOptions = Pick<
diff --git a/packages/router-core/src/index.ts b/packages/router-core/src/index.ts
index ca34da1722..047bf1bd8b 100644
--- a/packages/router-core/src/index.ts
+++ b/packages/router-core/src/index.ts
@@ -103,7 +103,6 @@ export {
parsePathname,
interpolatePath,
matchPathname,
- removeBasepath,
matchByPath,
} from './path'
export type { Segment } from './path'
@@ -193,6 +192,7 @@ export type {
ResolveOptionalParams,
ResolveRequiredParams,
RootRoute,
+ FilebaseRouteOptionsInterface,
} from './route'
export {
@@ -210,6 +210,8 @@ export type {
ViewTransitionOptions,
TrailingSlashOption,
Register,
+ AdditionalRegister,
+ MetaRegister,
AnyRouter,
AnyRouterWithContext,
RegisteredRouter,
@@ -245,8 +247,13 @@ export type {
ClearCacheFn,
CreateRouterFn,
ProcessRouteTreeResult,
+ SSROption,
+ DefaultRegister,
+ RegisteredConfig,
} from './router'
+export * from './config'
+
export type {
MatchLocation,
CommitLocationOptions,
@@ -273,8 +280,6 @@ export {
isPlainObject,
isPlainArray,
deepEqual,
- escapeJSON,
- shallow,
createControlledPromise,
isModuleNotFoundError,
} from './utils'
@@ -412,3 +417,30 @@ export type {
ValidateUseSearchResult,
ValidateUseParamsResult,
} from './typePrimitives'
+
+export type {
+ AnySerializationAdapter,
+ SerializationAdapter,
+ ValidateSerializableInput,
+ ValidateSerializableInputResult,
+ SerializerExtensions,
+ ValidateSerializable,
+ RegisteredSerializableInput,
+ RegisteredSerializationAdapters,
+} from './ssr/serializer/transformer'
+
+export {
+ createSerializationAdapter,
+ makeSerovalPlugin,
+ makeSsrSerovalPlugin,
+} from './ssr/serializer/transformer'
+
+export { defaultSerovalPlugins } from './ssr/serializer/seroval-plugins'
+
+export {
+ rewriteBasepath,
+ composeRewrites,
+ executeRewriteInput,
+ executeRewriteOutput,
+} from './rewrite'
+export type { LocationRewrite, LocationRewriteFunction } from './router'
diff --git a/packages/router-core/src/load-matches.ts b/packages/router-core/src/load-matches.ts
index c1edd5648f..702cab4dc7 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'
}
@@ -406,23 +406,31 @@ const executeBeforeLoad = (
const { search, params, cause } = match
const preload = resolvePreload(inner, matchId)
- const beforeLoadFnContext: BeforeLoadContextOptions =
- {
- search,
- abortController,
- params,
- preload,
- context,
- location: inner.location,
- navigate: (opts: any) =>
- inner.router.navigate({
- ...opts,
- _fromLocation: inner.location,
- }),
- buildLocation: inner.router.buildLocation,
- cause: preload ? 'preload' : cause,
- matches: inner.matches,
- }
+ const beforeLoadFnContext: BeforeLoadContextOptions<
+ any,
+ any,
+ any,
+ any,
+ any,
+ any,
+ any
+ > = {
+ search,
+ abortController,
+ params,
+ preload,
+ context,
+ location: inner.location,
+ navigate: (opts: any) =>
+ inner.router.navigate({
+ ...opts,
+ _fromLocation: inner.location,
+ }),
+ buildLocation: inner.router.buildLocation,
+ cause: preload ? 'preload' : cause,
+ matches: inner.matches,
+ ...inner.router.options.additionalContext,
+ }
const updateContext = (beforeLoadContext: any) => {
if (beforeLoadContext === undefined) {
@@ -487,14 +495,14 @@ const handleBeforeLoad = (
return queueExecution()
}
+ const execute = () => executeBeforeLoad(inner, matchId, index, route)
+
const queueExecution = () => {
if (shouldSkipLoader(inner, matchId)) return
const result = preBeforeLoadSetup(inner, matchId, route)
return isPromise(result) ? result.then(execute) : execute()
}
- const execute = () => executeBeforeLoad(inner, matchId, index, route)
-
return serverSsr()
}
@@ -571,6 +579,7 @@ const getLoaderContext = (
}),
cause: preload ? 'preload' : cause,
route,
+ ...inner.router.options.additionalContext,
}
}
diff --git a/packages/router-core/src/location.ts b/packages/router-core/src/location.ts
index 4b09f7b7ff..43b11473f9 100644
--- a/packages/router-core/src/location.ts
+++ b/packages/router-core/src/location.ts
@@ -2,12 +2,50 @@ import type { ParsedHistoryState } from '@tanstack/history'
import type { AnySchema } from './validators'
export interface ParsedLocation {
+ /**
+ * The full path of the location, including pathname, search, and hash.
+ * Does not include the origin. Is the equivalent of calling
+ * `url.replace(url.origin, '')`
+ */
href: string
+ /**
+ * @description The pathname of the location, including the leading slash.
+ */
pathname: string
+ /**
+ * The parsed search parameters of the location in object form.
+ */
search: TSearchObj
+ /**
+ * The search string of the location, including the leading question mark.
+ */
searchStr: string
+ /**
+ * The in-memory state of the location as it *may* exist in the browser's history.
+ */
state: ParsedHistoryState
+ /**
+ * The hash of the location, including the leading hash character.
+ */
hash: string
+ /**
+ * The masked location of the location.
+ */
maskedLocation?: ParsedLocation
+ /**
+ * Whether to unmask the location on reload.
+ */
unmaskOnReload?: boolean
+ /**
+ * @private
+ * @description The public href of the location, including the origin before any rewrites.
+ * If a rewrite is applied, the `href` property will be the rewritten URL.
+ */
+ publicHref: string
+ /**
+ * @private
+ * @description The full URL of the location, including the origin.
+ * @private
+ */
+ url: string
}
diff --git a/packages/router-core/src/path.ts b/packages/router-core/src/path.ts
index 827f17c243..5612de37d5 100644
--- a/packages/router-core/src/path.ts
+++ b/packages/router-core/src/path.ts
@@ -97,11 +97,9 @@ export function exactPathTest(
// /a/b/c + d/ = /a/b/c/d
// /a/b/c + d/e = /a/b/c/d/e
interface ResolvePathOptions {
- basepath: string
base: string
to: string
trailingSlash?: 'always' | 'never' | 'preserve'
- caseSensitive?: boolean
parseCache?: ParsePathnameCache
}
@@ -151,16 +149,11 @@ function segmentToString(segment: Segment): string {
}
export function resolvePath({
- basepath,
base,
to,
trailingSlash = 'never',
- caseSensitive,
parseCache,
}: ResolvePathOptions) {
- base = removeBasepath(basepath, base, caseSensitive)
- to = removeBasepath(basepath, to, caseSensitive)
-
let baseSegments = parsePathname(base, parseCache).slice()
const toSegments = parsePathname(to, parseCache)
@@ -201,7 +194,8 @@ export function resolvePath({
}
const segmentValues = baseSegments.map(segmentToString)
- const joined = joinPaths([basepath, ...segmentValues])
+ // const joined = joinPaths([basepath, ...segmentValues])
+ const joined = joinPaths(segmentValues)
return joined
}
@@ -491,17 +485,11 @@ function encodePathParam(value: string, decodeCharMap?: Map) {
}
export function matchPathname(
- basepath: string,
currentPathname: string,
matchLocation: Pick,
parseCache?: ParsePathnameCache,
): AnyPathParams | undefined {
- const pathParams = matchByPath(
- basepath,
- currentPathname,
- matchLocation,
- parseCache,
- )
+ const pathParams = matchByPath(currentPathname, matchLocation, parseCache)
// const searchMatched = matchBySearch(location.search, matchLocation)
if (matchLocation.to && !pathParams) {
@@ -511,49 +499,7 @@ export function matchPathname(
return pathParams ?? {}
}
-export function removeBasepath(
- basepath: string,
- pathname: string,
- caseSensitive: boolean = false,
-) {
- // normalize basepath and pathname for case-insensitive comparison if needed
- const normalizedBasepath = caseSensitive ? basepath : basepath.toLowerCase()
- const normalizedPathname = caseSensitive ? pathname : pathname.toLowerCase()
-
- switch (true) {
- // default behaviour is to serve app from the root - pathname
- // left untouched
- case normalizedBasepath === '/':
- return pathname
-
- // shortcut for removing the basepath if it matches the pathname
- case normalizedPathname === normalizedBasepath:
- return ''
-
- // in case pathname is shorter than basepath - there is
- // nothing to remove
- case pathname.length < basepath.length:
- return pathname
-
- // avoid matching partial segments - strict equality handled
- // earlier, otherwise, basepath separated from pathname with
- // separator, therefore lack of separator means partial
- // segment match (`/app` should not match `/application`)
- case normalizedPathname[normalizedBasepath.length] !== '/':
- return pathname
-
- // remove the basepath from the pathname if it starts with it
- case normalizedPathname.startsWith(normalizedBasepath):
- return pathname.slice(basepath.length)
-
- // otherwise, return the pathname as is
- default:
- return pathname
- }
-}
-
export function matchByPath(
- basepath: string,
from: string,
{
to,
@@ -562,14 +508,7 @@ export function matchByPath(
}: Pick,
parseCache?: ParsePathnameCache,
): Record | undefined {
- // check basepath first
- if (basepath !== '/' && !from.startsWith(basepath)) {
- return undefined
- }
- // Remove the base path from the pathname
- from = removeBasepath(basepath, from, caseSensitive)
- // Default to to $ (wildcard)
- to = removeBasepath(basepath, `${to ?? '$'}`, caseSensitive)
+ const stringTo = to as string
// Parse the from and to
const baseSegments = parsePathname(
@@ -577,7 +516,7 @@ export function matchByPath(
parseCache,
)
const routeSegments = parsePathname(
- to.startsWith('/') ? to : `/${to}`,
+ stringTo.startsWith('/') ? stringTo : `/${stringTo}`,
parseCache,
)
diff --git a/packages/router-core/src/rewrite.ts b/packages/router-core/src/rewrite.ts
new file mode 100644
index 0000000000..c0cef0cc87
--- /dev/null
+++ b/packages/router-core/src/rewrite.ts
@@ -0,0 +1,70 @@
+import { joinPaths, trimPath } from './path'
+import type { LocationRewrite } from './router'
+
+export function composeRewrites(rewrites: Array) {
+ return {
+ input: ({ url }) => {
+ for (const rewrite of rewrites) {
+ url = executeRewriteInput(rewrite, url)
+ }
+ return url
+ },
+ output: ({ url }) => {
+ for (let i = rewrites.length - 1; i >= 0; i--) {
+ url = executeRewriteOutput(rewrites[i], url)
+ }
+ return url
+ },
+ } satisfies LocationRewrite
+}
+
+export function rewriteBasepath(opts: {
+ basepath: string
+ caseSensitive?: boolean
+}) {
+ const trimmedBasepath = trimPath(opts.basepath)
+ const regex = new RegExp(
+ `^/${trimmedBasepath}/`,
+ opts.caseSensitive ? '' : 'i',
+ )
+ return {
+ input: ({ url }) => {
+ url.pathname = url.pathname.replace(regex, '/')
+ return url
+ },
+ output: ({ url }) => {
+ url.pathname = joinPaths(['/', trimmedBasepath, url.pathname])
+ return url
+ },
+ } satisfies LocationRewrite
+}
+
+export function executeRewriteInput(
+ rewrite: LocationRewrite | undefined,
+ url: URL,
+): URL {
+ const res = rewrite?.input?.({ url })
+ if (res) {
+ if (typeof res === 'string') {
+ return new URL(res)
+ } else if (res instanceof URL) {
+ return res
+ }
+ }
+ return url
+}
+
+export function executeRewriteOutput(
+ rewrite: LocationRewrite | undefined,
+ url: URL,
+): URL {
+ const res = rewrite?.output?.({ url })
+ if (res) {
+ if (typeof res === 'string') {
+ return new URL(res)
+ } else if (res instanceof URL) {
+ return res
+ }
+ }
+ return url
+}
diff --git a/packages/router-core/src/route.ts b/packages/router-core/src/route.ts
index bdda040845..2e963f7c27 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,9 @@ export interface RouteTypes<
in out TLoaderFn,
in out TChildren,
in out TFileRouteTypes,
+ in out TSSR,
+ in out TServerMiddlewares,
+ in out THandlers,
> {
parentRoute: TParentRoute
path: TPath
@@ -422,8 +426,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 +459,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 +473,16 @@ export type RouteAddChildrenFn<
in out TLoaderDeps extends Record,
in out TLoaderFn,
in out TFileRouteTypes,
+ in out TSSR,
+ in out TServerMiddlewares,
+ in out THandlers,
> = (
children: Constrain<
TNewChildren,
ReadonlyArray | Record
>,
) => Route<
+ TRegister,
TParentRoute,
TPath,
TFullPath,
@@ -472,10 +496,14 @@ export type RouteAddChildrenFn<
TLoaderDeps,
TLoaderFn,
TNewChildren,
- TFileRouteTypes
+ TFileRouteTypes,
+ TSSR,
+ TServerMiddlewares,
+ THandlers
>
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 +517,13 @@ export type RouteAddFileChildrenFn<
in out TLoaderDeps extends Record,
in out TLoaderFn,
in out TFileRouteTypes,
+ in out TSSR,
+ in out TServerMiddlewares,
+ in out THandlers,
> = (
children: TNewChildren,
) => Route<
+ TRegister,
TParentRoute,
TPath,
TFullPath,
@@ -505,10 +537,14 @@ export type RouteAddFileChildrenFn<
TLoaderDeps,
TLoaderFn,
TNewChildren,
- TFileRouteTypes
+ TFileRouteTypes,
+ TSSR,
+ TServerMiddlewares,
+ THandlers
>
export type RouteAddFileTypesFn<
+ TRegister extends Register,
TParentRoute extends AnyRoute,
TPath extends string,
TFullPath extends string,
@@ -522,7 +558,11 @@ export type RouteAddFileTypesFn<
TLoaderDeps extends Record,
TLoaderFn,
TChildren,
+ TSSR,
+ TServerMiddlewares,
+ THandlers,
> = () => Route<
+ TRegister,
TParentRoute,
TPath,
TFullPath,
@@ -536,10 +576,14 @@ export type RouteAddFileTypesFn<
TLoaderDeps,
TLoaderFn,
TChildren,
- TNewFileRouteTypes
+ TNewFileRouteTypes,
+ TSSR,
+ TServerMiddlewares,
+ THandlers
>
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 +598,9 @@ export interface Route<
in out TLoaderFn,
in out TChildren,
in out TFileRouteTypes,
+ in out TSSR,
+ in out TServerMiddlewares,
+ in out THandlers,
> extends RouteExtensions {
path: TPath
parentRoute: TParentRoute
@@ -572,9 +619,13 @@ export interface Route<
TLoaderDeps,
TLoaderFn,
TChildren,
- TFileRouteTypes
+ TFileRouteTypes,
+ TSSR,
+ TServerMiddlewares,
+ THandlers
>
options: RouteOptions<
+ TRegister,
TParentRoute,
TId,
TCustomId,
@@ -586,7 +637,10 @@ export interface Route<
TLoaderFn,
TRouterContext,
TRouteContextFn,
- TBeforeLoadFn
+ TBeforeLoadFn,
+ TSSR,
+ TServerMiddlewares,
+ THandlers
>
isRoot: TParentRoute extends AnyRoute ? true : false
/** @internal */
@@ -596,6 +650,7 @@ export interface Route<
lazyFn?: () => Promise<
LazyRoute<
Route<
+ TRegister,
TParentRoute,
TPath,
TFullPath,
@@ -609,7 +664,10 @@ export interface Route<
TLoaderDeps,
TLoaderFn,
TChildren,
- TFileRouteTypes
+ TFileRouteTypes,
+ TSSR,
+ TServerMiddlewares,
+ THandlers
>
>
>
@@ -636,6 +694,7 @@ export interface Route<
) => this
lazy: RouteLazyFn<
Route<
+ TRegister,
TParentRoute,
TPath,
TFullPath,
@@ -649,10 +708,14 @@ export interface Route<
TLoaderDeps,
TLoaderFn,
TChildren,
- TFileRouteTypes
+ TFileRouteTypes,
+ TSSR,
+ TServerMiddlewares,
+ THandlers
>
>
addChildren: RouteAddChildrenFn<
+ TRegister,
TParentRoute,
TPath,
TFullPath,
@@ -665,9 +728,13 @@ export interface Route<
TBeforeLoadFn,
TLoaderDeps,
TLoaderFn,
- TFileRouteTypes
+ TFileRouteTypes,
+ TSSR,
+ TServerMiddlewares,
+ THandlers
>
_addFileChildren: RouteAddFileChildrenFn<
+ TRegister,
TParentRoute,
TPath,
TFullPath,
@@ -680,9 +747,13 @@ export interface Route<
TBeforeLoadFn,
TLoaderDeps,
TLoaderFn,
- TFileRouteTypes
+ TFileRouteTypes,
+ TSSR,
+ TServerMiddlewares,
+ THandlers
>
_addFileTypes: RouteAddFileTypesFn<
+ TRegister,
TParentRoute,
TPath,
TFullPath,
@@ -695,7 +766,10 @@ export interface Route<
TBeforeLoadFn,
TLoaderDeps,
TLoaderFn,
- TChildren
+ TChildren,
+ TSSR,
+ TServerMiddlewares,
+ THandlers
>
}
@@ -713,6 +787,10 @@ export type AnyRoute = Route<
any,
any,
any,
+ any,
+ any,
+ any,
+ any,
any
>
@@ -721,6 +799,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 +812,11 @@ export type RouteOptions<
TRouterContext = {},
TRouteContextFn = AnyContext,
TBeforeLoadFn = AnyContext,
+ TSSR = unknown,
+ TServerMiddlewares = unknown,
+ THandlers = undefined,
> = BaseRouteOptions<
+ TRegister,
TParentRoute,
TId,
TCustomId,
@@ -744,7 +827,10 @@ export type RouteOptions<
TLoaderFn,
TRouterContext,
TRouteContextFn,
- TBeforeLoadFn
+ TBeforeLoadFn,
+ TSSR,
+ TServerMiddlewares,
+ THandlers
> &
UpdatableRouteOptions<
NoInfer,
@@ -779,17 +865,22 @@ export type BeforeLoadFn<
in out TParams,
in out TRouterContext,
in out TRouteContextFn,
+ in out TServerMiddlewares,
+ in out THandlers,
> = (
ctx: BeforeLoadContextOptions<
TParentRoute,
TSearchValidator,
TParams,
TRouterContext,
- TRouteContextFn
+ TRouteContextFn,
+ TServerMiddlewares,
+ THandlers
>,
) => any
export type FileBaseRouteOptions<
+ TRegister extends Register,
TParentRoute extends AnyRoute = AnyRoute,
TId extends string = string,
TPath extends string = string,
@@ -801,7 +892,45 @@ export type FileBaseRouteOptions<
TRouteContextFn = AnyContext,
TBeforeLoadFn = AnyContext,
TRemountDepsFn = AnyContext,
-> = ParamsOptions & {
+ TSSR = unknown,
+ TServerMiddlewares = unknown,
+ THandlers = undefined,
+> = ParamsOptions &
+ FilebaseRouteOptionsInterface<
+ TRegister,
+ TParentRoute,
+ TId,
+ TPath,
+ TSearchValidator,
+ TParams,
+ TLoaderDeps,
+ TLoaderFn,
+ TRouterContext,
+ TRouteContextFn,
+ TBeforeLoadFn,
+ TRemountDepsFn,
+ TSSR,
+ TServerMiddlewares,
+ THandlers
+ >
+
+export interface FilebaseRouteOptionsInterface<
+ TRegister extends Register,
+ TParentRoute extends AnyRoute = AnyRoute,
+ TId extends string = string,
+ TPath extends string = string,
+ TSearchValidator = undefined,
+ TParams = {},
+ TLoaderDeps extends Record = {},
+ TLoaderFn = undefined,
+ TRouterContext = {},
+ TRouteContextFn = AnyContext,
+ TBeforeLoadFn = AnyContext,
+ TRemountDepsFn = AnyContext,
+ TSSR = unknown,
+ TServerMiddlewares = unknown,
+ THandlers = undefined,
+> {
validateSearch?: Constrain
shouldReload?:
@@ -814,7 +943,9 @@ export type FileBaseRouteOptions<
TLoaderDeps,
TRouterContext,
TRouteContextFn,
- TBeforeLoadFn
+ TBeforeLoadFn,
+ TServerMiddlewares,
+ THandlers
>,
) => any)
@@ -830,13 +961,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.
@@ -850,9 +982,16 @@ export type FileBaseRouteOptions<
TSearchValidator,
TParams,
TRouterContext,
- TRouteContextFn
+ TRouteContextFn,
+ TServerMiddlewares,
+ THandlers
>,
- ) => any
+ ) => ValidateSerializableLifecycleResult<
+ TRegister,
+ TParentRoute,
+ TSSR,
+ TBeforeLoadFn
+ >
>
loaderDeps?: (
@@ -881,13 +1020,21 @@ export type FileBaseRouteOptions<
TLoaderDeps,
TRouterContext,
TRouteContextFn,
- TBeforeLoadFn
+ TBeforeLoadFn,
+ TServerMiddlewares,
+ THandlers
>,
- ) => 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 +1046,12 @@ export type BaseRouteOptions<
TRouterContext = {},
TRouteContextFn = AnyContext,
TBeforeLoadFn = AnyContext,
+ TSSR = unknown,
+ TServerMiddlewares = unknown,
+ THandlers = undefined,
> = RoutePathOptions &
FileBaseRouteOptions<
+ TRegister,
TParentRoute,
TId,
TPath,
@@ -910,7 +1061,11 @@ export type BaseRouteOptions<
TLoaderFn,
TRouterContext,
TRouteContextFn,
- TBeforeLoadFn
+ TBeforeLoadFn,
+ AnyContext,
+ TSSR,
+ TServerMiddlewares,
+ THandlers
> & {
getParentRoute: () => TParentRoute
}
@@ -969,6 +1124,8 @@ export interface BeforeLoadContextOptions<
in out TParams,
in out TRouterContext,
in out TRouteContextFn,
+ in out TServerMiddlewares,
+ in out THandlers,
> extends ContextOptions,
FullSearchSchemaOption {
context: Expand<
@@ -1195,6 +1352,8 @@ export type RouteLoaderFn<
in out TRouterContext = {},
in out TRouteContextFn = AnyContext,
in out TBeforeLoadFn = AnyContext,
+ in out TServerMiddlewares = unknown,
+ in out THandlers = undefined,
> = (
match: LoaderFnContext<
TParentRoute,
@@ -1203,7 +1362,9 @@ export type RouteLoaderFn<
TLoaderDeps,
TRouterContext,
TRouteContextFn,
- TBeforeLoadFn
+ TBeforeLoadFn,
+ TServerMiddlewares,
+ THandlers
>,
) => any
@@ -1215,6 +1376,8 @@ export interface LoaderFnContext<
in out TRouterContext = {},
in out TRouteContextFn = AnyContext,
in out TBeforeLoadFn = AnyContext,
+ in out TServerMiddlewares = unknown,
+ in out THandlers = undefined,
> {
abortController: AbortController
preload: boolean
@@ -1249,14 +1412,19 @@ 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,
+ TServerMiddlewares = unknown,
+ THandlers = undefined,
> = Omit<
RouteOptions<
+ TRegister,
any, // TParentRoute
RootRouteId, // TId
RootRouteId, // TCustomId
@@ -1268,7 +1436,10 @@ export type RootRouteOptions<
TLoaderFn,
TRouterContext,
TRouteContextFn,
- TBeforeLoadFn
+ TBeforeLoadFn,
+ TSSR,
+ TServerMiddlewares,
+ THandlers
>,
| 'path'
| 'id'
@@ -1334,6 +1505,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 +1520,13 @@ export class BaseRoute<
in out TLoaderFn = undefined,
in out TChildren = unknown,
in out TFileRouteTypes = unknown,
+ in out TSSR = unknown,
+ in out TServerMiddlewares = unknown,
+ in out THandlers = undefined,
> {
isRoot: TParentRoute extends AnyRoute ? true : false
options: RouteOptions<
+ TRegister,
TParentRoute,
TId,
TCustomId,
@@ -1362,7 +1538,10 @@ export class BaseRoute<
TLoaderFn,
TRouterContext,
TRouteContextFn,
- TBeforeLoadFn
+ TBeforeLoadFn,
+ TSSR,
+ TServerMiddlewares,
+ THandlers
>
// The following properties are set up in this.init()
@@ -1395,6 +1574,7 @@ export class BaseRoute<
lazyFn?: () => Promise<
LazyRoute<
Route<
+ TRegister,
TParentRoute,
TPath,
TFullPath,
@@ -1408,7 +1588,10 @@ export class BaseRoute<
TLoaderDeps,
TLoaderFn,
TChildren,
- TFileRouteTypes
+ TFileRouteTypes,
+ TSSR,
+ TServerMiddlewares,
+ THandlers
>
>
>
@@ -1419,6 +1602,7 @@ export class BaseRoute<
constructor(
options?: RouteOptions<
+ TRegister,
TParentRoute,
TId,
TCustomId,
@@ -1430,7 +1614,10 @@ export class BaseRoute<
TLoaderFn,
TRouterContext,
TRouteContextFn,
- TBeforeLoadFn
+ TBeforeLoadFn,
+ TSSR,
+ TServerMiddlewares,
+ THandlers
>,
) {
this.options = (options as any) || {}
@@ -1455,7 +1642,10 @@ export class BaseRoute<
TLoaderDeps,
TLoaderFn,
TChildren,
- TFileRouteTypes
+ TFileRouteTypes,
+ TSSR,
+ TServerMiddlewares,
+ THandlers
>
init = (opts: { originalIndex: number }): void => {
@@ -1463,6 +1653,7 @@ export class BaseRoute<
const options = this.options as
| (RouteOptions<
+ TRegister,
TParentRoute,
TId,
TCustomId,
@@ -1474,7 +1665,9 @@ export class BaseRoute<
TLoaderFn,
TRouterContext,
TRouteContextFn,
- TBeforeLoadFn
+ TBeforeLoadFn,
+ TSSR,
+ TServerMiddlewares
> &
RoutePathOptionsIntersection)
| undefined
@@ -1536,6 +1729,7 @@ export class BaseRoute<
}
addChildren: RouteAddChildrenFn<
+ TRegister,
TParentRoute,
TPath,
TFullPath,
@@ -1548,12 +1742,16 @@ export class BaseRoute<
TBeforeLoadFn,
TLoaderDeps,
TLoaderFn,
- TFileRouteTypes
+ TFileRouteTypes,
+ TSSR,
+ TServerMiddlewares,
+ THandlers
> = (children) => {
return this._addFileChildren(children) as any
}
_addFileChildren: RouteAddFileChildrenFn<
+ TRegister,
TParentRoute,
TPath,
TFullPath,
@@ -1566,7 +1764,10 @@ export class BaseRoute<
TBeforeLoadFn,
TLoaderDeps,
TLoaderFn,
- TFileRouteTypes
+ TFileRouteTypes,
+ TSSR,
+ TServerMiddlewares,
+ THandlers
> = (children) => {
if (Array.isArray(children)) {
this.children = children as TChildren
@@ -1580,6 +1781,7 @@ export class BaseRoute<
}
_addFileTypes: RouteAddFileTypesFn<
+ TRegister,
TParentRoute,
TPath,
TFullPath,
@@ -1592,7 +1794,10 @@ export class BaseRoute<
TBeforeLoadFn,
TLoaderDeps,
TLoaderFn,
- TChildren
+ TChildren,
+ TSSR,
+ TServerMiddlewares,
+ THandlers
> = () => {
return this as any
}
@@ -1613,6 +1818,7 @@ export class BaseRoute<
}) => {
Object.assign(this.options, options)
return this as unknown as BaseRoute<
+ TRegister,
TParentRoute,
TPath,
TFullPath,
@@ -1626,7 +1832,10 @@ export class BaseRoute<
TLoaderDeps,
TNewLoaderFn,
TChildren,
- TFileRouteTypes
+ TFileRouteTypes,
+ TSSR,
+ TServerMiddlewares,
+ THandlers
>
}
@@ -1650,6 +1859,7 @@ export class BaseRoute<
lazy: RouteLazyFn<
Route<
+ TRegister,
TParentRoute,
TPath,
TFullPath,
@@ -1663,7 +1873,10 @@ export class BaseRoute<
TLoaderDeps,
TLoaderFn,
TChildren,
- TFileRouteTypes
+ TFileRouteTypes,
+ TSSR,
+ TServerMiddlewares,
+ THandlers
>
> = (lazyFn) => {
this.lazyFn = lazyFn
@@ -1684,6 +1897,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 +1906,11 @@ export interface RootRoute<
in out TLoaderFn = undefined,
in out TChildren = unknown,
in out TFileRouteTypes = unknown,
+ in out TSSR = unknown,
+ in out TServerMiddlewares = unknown,
+ in out THandlers = undefined,
> extends Route<
+ TRegister,
any, // TParentRoute
'/', // TPath
'/', // TFullPath
@@ -1706,10 +1924,14 @@ export interface RootRoute<
TLoaderDeps,
TLoaderFn,
TChildren, // TChildren
- TFileRouteTypes
+ TFileRouteTypes,
+ TSSR,
+ TServerMiddlewares,
+ THandlers
> {}
export class BaseRootRoute<
+ in out TRegister extends Register,
in out TSearchValidator = undefined,
in out TRouterContext = {},
in out TRouteContextFn = AnyContext,
@@ -1718,7 +1940,11 @@ export class BaseRootRoute<
in out TLoaderFn = undefined,
in out TChildren = unknown,
in out TFileRouteTypes = unknown,
+ in out TSSR = unknown,
+ in out TServerMiddlewares = unknown,
+ in out THandlers = undefined,
> extends BaseRoute<
+ TRegister,
any, // TParentRoute
'/', // TPath
'/', // TFullPath
@@ -1732,16 +1958,23 @@ export class BaseRootRoute<
TLoaderDeps,
TLoaderFn,
TChildren, // TChildren
- TFileRouteTypes
+ TFileRouteTypes,
+ TSSR,
+ TServerMiddlewares,
+ THandlers
> {
constructor(
options?: RootRouteOptions<
+ TRegister,
TSearchValidator,
TRouterContext,
TRouteContextFn,
TBeforeLoadFn,
TLoaderDeps,
- TLoaderFn
+ TLoaderFn,
+ TSSR,
+ TServerMiddlewares,
+ THandlers
>,
) {
super(options as any)
diff --git a/packages/router-core/src/router.ts b/packages/router-core/src/router.ts
index 6a132b5783..3534013e1c 100644
--- a/packages/router-core/src/router.ts
+++ b/packages/router-core/src/router.ts
@@ -1,9 +1,5 @@
import { Store, batch } from '@tanstack/store'
-import {
- createBrowserHistory,
- createMemoryHistory,
- parseHref,
-} from '@tanstack/history'
+import { createBrowserHistory, parseHref } from '@tanstack/history'
import invariant from 'tiny-invariant'
import {
createControlledPromise,
@@ -20,7 +16,6 @@ import {
SEGMENT_TYPE_WILDCARD,
cleanPath,
interpolatePath,
- joinPaths,
matchPathname,
parsePathname,
resolvePath,
@@ -35,6 +30,12 @@ import { rootRouteId } from './root'
import { isRedirect, redirect } from './redirect'
import { createLRUCache } from './lru-cache'
import { loadMatches, loadRouteChunk, routeNeedsPreload } from './load-matches'
+import {
+ composeRewrites,
+ executeRewriteInput,
+ executeRewriteOutput,
+ rewriteBasepath,
+} from './rewrite'
import type { ParsePathnameCache, Segment } from './path'
import type { SearchParser, SearchSerializer } from './searchParams'
import type { AnyRedirect, ResolvedRedirect } from './redirect'
@@ -46,6 +47,7 @@ import type {
} from '@tanstack/history'
import type {
Awaitable,
+ Constrain,
ControlledPromise,
NoInfer,
NonNullableUpdater,
@@ -84,6 +86,11 @@ 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
@@ -92,16 +99,39 @@ export type ControllablePromise = Promise & {
export type InjectedHtmlEntry = Promise
-export interface DefaultRegister {
+type FindMetaRegister<
+ TLookup,
+ TKeys extends keyof MetaRegister = keyof MetaRegister,
+> = TKeys extends TLookup
+ ? Register[MetaRegister[TKeys]] extends never
+ ? never
+ : Register[MetaRegister[TKeys]]
+ : never
+
+export type RegisteredRouter = [FindMetaRegister<'router'>] extends [never]
+ ? Register['router']
+ : FindMetaRegister<'router'>['~types']['router']
+
+export type RegisteredConfig = [FindMetaRegister<'config'>] extends [never]
+ ? Register['config']
+ : FindMetaRegister<'config'>['~types']['config']
+
+export interface AdditionalRegister {}
+
+export interface MetaRegister {
+ // router: unknown
+}
+
+export interface DefaultRegister extends AdditionalRegister {
router: AnyRouter
+ config: AnyRouterConfig
+ ssr: SSROption
}
export interface Register extends DefaultRegister {
// router: Router
}
-export type RegisteredRouter = Register['router']
-
export type DefaultRemountDepsFn = (
opts: MakeRemountDepsOptionsUnion,
) => any
@@ -111,12 +141,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.
@@ -261,6 +293,18 @@ export interface RouterOptions<
/**
* The basepath for then entire router. This is useful for mounting a router instance at a subpath.
*
+ * @deprecated - use `rewrite.input` with the new `rewriteBasepath` utility instead:
+ * ```ts
+ * const router = createRouter({
+ * routeTree,
+ * rewrite: rewriteBasepath('/basepath')
+ * // Or wrap existing rewrite functionality
+ * rewrite: rewriteBasepath('/basepath', {
+ * output: ({ url }) => {...},
+ * input: ({ url }) => {...},
+ * })
+ * })
+ * ```
* @default '/'
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#basepath-property)
*/
@@ -276,6 +320,9 @@ export interface RouterOptions<
* @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/router-context)
*/
context?: InferRouterContext
+
+ additionalContext?: any
+
/**
* A function that will be called when the router is dehydrated.
*
@@ -284,7 +331,10 @@ 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<
+ TDehydrated,
+ ValidateSerializableInput
+ >
/**
* A function that will be called when the router is hydrated.
*
@@ -354,7 +404,7 @@ export interface RouterOptions<
*
* @default true
*/
- defaultSsr?: boolean | 'data-only'
+ defaultSsr?: SSROption
search?: {
/**
@@ -390,7 +440,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,8 +473,48 @@ export interface RouterOptions<
* @default false
*/
disableGlobalCatchBoundary?: boolean
+
+ serializationAdapters?: ReadonlyArray
+ /**
+ * Configures how the router will rewrite the location between the actual href and the internal href of the router.
+ *
+ * @default undefined
+ * @description You can provide a custom rewrite pair (in/out) or use the utilities like `rewriteBasepath` as a convenience for common use cases, or even do both!
+ * This is useful for basepath rewriting, shifting data from the origin to the path (for things like )
+ */
+ rewrite?: LocationRewrite
+ origin?: string
}
+export type LocationRewrite = {
+ /**
+ * A function that will be called to rewrite the URL before it is interpreted by the router from the history instance.
+ * Utilities like `rewriteBasepath` are provided as a convenience for common use cases.
+ *
+ * @default undefined
+ */
+ input?: LocationRewriteFunction
+ /**
+ * A function that will be called to rewrite the URL before it is committed to the actual history instance from the router.
+ * Utilities like `rewriteBasepath` are provided as a convenience for common use cases.
+ *
+ * @default undefined
+ */
+ output?: LocationRewriteFunction
+}
+
+/**
+ * A function that will be called to rewrite the URL.
+ *
+ * @param url The URL to rewrite.
+ * @returns The rewritten URL (as a URL instance or full href string) or undefined if no rewrite is needed.
+ */
+export type LocationRewriteFunction = ({
+ url,
+}: {
+ url: URL
+}) => undefined | string | URL
+
export interface RouterState<
in out TRouteTree extends AnyRoute = AnyRoute,
in out TRouteMatch = MakeRouteMatchUnion,
@@ -703,6 +795,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 = {
@@ -792,7 +885,10 @@ export class RouterCore<
'stringifySearch' | 'parseSearch' | 'context'
>
history!: TRouterHistory
+ rewrite?: LocationRewrite
+ origin?: string
latestLocation!: ParsedLocation>
+ // @deprecated - basepath functionality is now implemented via the `rewrite` option
basepath!: string
routeTree!: TRouteTree
routesById!: RoutesById
@@ -856,7 +952,6 @@ export class RouterCore<
)
}
- const previousOptions = this.options
this.options = {
...this.options,
...newOptions,
@@ -873,32 +968,42 @@ export class RouterCore<
)
: undefined
- if (
- !this.basepath ||
- (newOptions.basepath && newOptions.basepath !== previousOptions.basepath)
- ) {
- if (
- newOptions.basepath === undefined ||
- newOptions.basepath === '' ||
- newOptions.basepath === '/'
- ) {
- this.basepath = '/'
- } else {
- this.basepath = `/${trimPath(newOptions.basepath)}`
- }
- }
-
if (
!this.history ||
(this.options.history && this.options.history !== this.history)
) {
- this.history =
- this.options.history ??
- ((this.isServer
- ? createMemoryHistory({
- initialEntries: [this.basepath || '/'],
- })
- : createBrowserHistory()) as TRouterHistory)
+ if (!this.options.history) {
+ if (!this.isServer) {
+ this.history = createBrowserHistory() as TRouterHistory
+ }
+ } else {
+ this.history = this.options.history
+ }
+ }
+ // For backwards compatibility, we support a basepath option, which we now implement as a rewrite
+ if (this.options.basepath) {
+ const basepathRewrite = rewriteBasepath({
+ basepath: this.options.basepath,
+ })
+ if (this.options.rewrite) {
+ this.rewrite = composeRewrites([basepathRewrite, this.options.rewrite])
+ } else {
+ this.rewrite = basepathRewrite
+ }
+ } else {
+ this.rewrite = this.options.rewrite
+ }
+
+ this.origin = this.options.origin
+ if (!this.origin) {
+ if (!this.isServer) {
+ this.origin = window.origin
+ } else {
+ // fallback for the server, can be overridden by calling router.update({origin}) on the server
+ this.origin = 'http://localhost'
+ }
+ }
+ if (this.history) {
this.updateLatestLocation()
}
@@ -907,7 +1012,7 @@ export class RouterCore<
this.buildRouteTree()
}
- if (!this.__store) {
+ if (!this.__store && this.latestLocation) {
this.__store = new Store(getInitialRouterState(this.latestLocation), {
onUpdate: () => {
this.__store.state = {
@@ -933,7 +1038,7 @@ export class RouterCore<
}
}
- get state() {
+ get state(): RouterState {
return this.__store.state
}
@@ -994,20 +1099,32 @@ export class RouterCore<
previousLocation,
) => {
const parse = ({
- pathname,
- search,
- hash,
+ href,
state,
}: HistoryLocation): ParsedLocation> => {
- const parsedSearch = this.options.parseSearch(search)
+ // Before we do any processing, we need to allow rewrites to modify the URL
+ // build up the full URL by combining the href from history with the router's origin
+ const fullUrl = new URL(href, this.origin)
+ const url = executeRewriteInput(this.rewrite, fullUrl)
+
+ const parsedSearch = this.options.parseSearch(url.search)
const searchStr = this.options.stringifySearch(parsedSearch)
+ // Make sure our final url uses the re-stringified pathname, search, and has for consistency
+ // (We were already doing this, so just keeping it for now)
+ url.search = searchStr
+
+ const fullPath = url.href.replace(url.origin, '')
+
+ const { pathname, hash } = url
return {
+ href: fullPath,
+ publicHref: href,
+ url: url.href,
pathname,
searchStr,
search: replaceEqualDeep(previousLocation?.search, parsedSearch) as any,
hash: hash.split('#').reverse()[0] ?? '',
- href: `${pathname}${searchStr}${hash}`,
state: replaceEqualDeep(previousLocation?.state, state),
}
}
@@ -1035,11 +1152,9 @@ export class RouterCore<
resolvePathWithBase = (from: string, path: string) => {
const resolvedPath = resolvePath({
- basepath: this.basepath,
base: from,
to: cleanPath(path),
trailingSlash: this.options.trailingSlash,
- caseSensitive: this.options.caseSensitive,
parseCache: this.parsePathnameCache,
})
return resolvedPath
@@ -1271,7 +1386,7 @@ export class RouterCore<
? replaceEqualDeep(previousMatch.params, routeParams)
: routeParams,
_strictParams: usedParams,
- pathname: joinPaths([this.basepath, interpolatedPath]),
+ pathname: interpolatedPath,
updatedAt: Date.now(),
search: previousMatch
? replaceEqualDeep(previousMatch.search, preMatchSearch)
@@ -1376,7 +1491,6 @@ export class RouterCore<
return getMatchedRoutes({
pathname,
routePathname,
- basepath: this.basepath,
caseSensitive: this.options.caseSensitive,
routesByPath: this.routesByPath,
routesById: this.routesById,
@@ -1414,50 +1528,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 +1573,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, '.')
@@ -1570,14 +1679,25 @@ export class RouterCore<
// Replace the equal deep
nextState = replaceEqualDeep(currentLocation.state, nextState)
- // Return the next location
+ // Create the full path of the location
+ const fullPath = `${nextPathname}${searchStr}${hashStr}`
+
+ // Create the new href with full origin
+ const url = new URL(fullPath, this.origin)
+
+ // If a rewrite function is provided, use it to rewrite the URL
+ const rewrittenUrl = executeRewriteOutput(this.rewrite, url)
+
return {
+ publicHref:
+ rewrittenUrl.pathname + rewrittenUrl.search + rewrittenUrl.hash,
+ href: fullPath,
+ url: rewrittenUrl.href,
pathname: nextPathname,
search: nextSearch,
searchStr,
state: nextState as any,
hash: hash ?? '',
- href: `${nextPathname}${searchStr}${hashStr}`,
unmaskOnReload: dest.unmaskOnReload,
}
}
@@ -1595,7 +1715,6 @@ export class RouterCore<
const foundMask = this.options.routeMasks?.find((d) => {
const match = matchPathname(
- this.basepath,
next.pathname,
{
to: d.from,
@@ -1625,8 +1744,7 @@ export class RouterCore<
}
if (maskedNext) {
- const maskedFinal = build(maskedDest)
- next.maskedLocation = maskedFinal
+ next.maskedLocation = maskedNext
}
return next
@@ -1669,7 +1787,8 @@ export class RouterCore<
return isEqual
}
- const isSameUrl = this.latestLocation.href === next.href
+ const isSameUrl =
+ trimPathRight(this.latestLocation.href) === trimPathRight(next.href)
const previousCommitPromise = this.commitLocationPromise
this.commitLocationPromise = createControlledPromise(() => {
@@ -1718,7 +1837,7 @@ export class RouterCore<
this.shouldViewTransition = viewTransition
this.history[next.replace ? 'replace' : 'push'](
- nextHistory.href,
+ nextHistory.publicHref,
nextHistory.state,
{ ignoreBlocker },
)
@@ -1780,7 +1899,7 @@ export class RouterCore<
if (reloadDocument) {
if (!href) {
const location = this.buildLocation({ to, ...rest } as any)
- href = this.history.createHref(location.href)
+ href = location.href
}
if (rest.replace) {
window.location.replace(href)
@@ -1833,6 +1952,7 @@ export class RouterCore<
throw redirect({ href: nextLocation.href })
}
}
+
// Match the routes
const pendingMatches = this.matchRoutes(this.latestLocation)
@@ -1978,6 +2098,7 @@ export class RouterCore<
this.latestLoadPromise = undefined
this.commitLocationPromise = undefined
}
+
resolve()
})
})
@@ -2276,7 +2397,6 @@ export class RouterCore<
: this.state.resolvedLocation || this.state.location
const match = matchPathname(
- this.basepath,
baseLocation.pathname,
{
...opts,
@@ -2612,7 +2732,6 @@ export function processRouteTree({
export function getMatchedRoutes({
pathname,
routePathname,
- basepath,
caseSensitive,
routesByPath,
routesById,
@@ -2621,7 +2740,6 @@ export function getMatchedRoutes({
}: {
pathname: string
routePathname?: string
- basepath: string
caseSensitive?: boolean
routesByPath: Record
routesById: Record
@@ -2632,7 +2750,6 @@ export function getMatchedRoutes({
const trimmedPath = trimPathRight(pathname)
const getMatchedParams = (route: TRouteLike) => {
const result = matchPathname(
- basepath,
trimmedPath,
{
to: route.fullPath,
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..2d1b3389e4
--- /dev/null
+++ b/packages/router-core/src/ssr/serializer/transformer.ts
@@ -0,0 +1,216 @@
+import { createPlugin } from 'seroval'
+import { GLOBAL_TSR } from '../constants'
+import type { Plugin, SerovalNode } from 'seroval'
+import type { Register, RegisteredConfig, 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