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..95a83e93d4 100644 --- a/docs/start/framework/react/migrate-from-next-js.md +++ b/docs/start/framework/react/migrate-from-next-js.md @@ -85,10 +85,11 @@ Now that you've installed the necessary dependencies, update your project config ```ts // vite.config.ts -import tailwindcss from '@tailwindcss/vite' -import { tanstackStart } from '@tanstack/react-start/plugin/vite' import { defineConfig } from 'vite' +import { tanstackStart } from '@tanstack/react-start/plugin/vite' +import viteReact from '@vitejs/plugin-react' import tsconfigPaths from 'vite-tsconfig-paths' +import tailwindcss from '@tailwindcss/vite' export default defineConfig({ server: { @@ -99,11 +100,12 @@ export default defineConfig({ // Enables Vite to resolve imports using path aliases. tsconfigPaths(), tanstackStart({ - tsr: { + router: { // Specifies the directory TanStack Router uses for your routes. routesDirectory: 'src/app', // Defaults to "src/routes" }, }), + viteReact(), ], }) ``` diff --git a/docs/start/framework/react/server-functions.md b/docs/start/framework/react/server-functions.md index 2c6a075b35..dd471cbe7f 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 for 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/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/components/RenderCounter.tsx b/e2e/react-router/basic-file-based/src/components/RenderCounter.tsx new file mode 100644 index 0000000000..38eff63cd3 --- /dev/null +++ b/e2e/react-router/basic-file-based/src/components/RenderCounter.tsx @@ -0,0 +1,7 @@ +import { useRef } from 'react' + +export const RenderCounter = () => { + const renderCounter = useRef(0) + renderCounter.current = renderCounter.current + 1 + return <>{renderCounter.current} +} 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..2ba33a6414 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,16 @@ 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 ParamsPsNonNestedRouteRouteImport } from './routes/params-ps/non-nested/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' @@ -50,11 +58,25 @@ import { Route as ParamsPsWildcardPrefixChar123Char125RouteImport } from './rout import { Route as ParamsPsWildcardSplatRouteImport } from './routes/params-ps/wildcard/$' import { Route as ParamsPsNamedChar123fooChar125suffixRouteImport } from './routes/params-ps/named/{$foo}suffix' import { Route as ParamsPsNamedPrefixChar123fooChar125RouteImport } from './routes/params-ps/named/prefix{$foo}' -import { Route as ParamsPsNamedFooRouteImport } from './routes/params-ps/named/$foo' 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 groupSubfolderInsideRouteImport } from './routes/(group)/subfolder/inside' import { Route as groupLayoutInsidelayoutRouteImport } from './routes/(group)/_layout.insidelayout' +import { Route as ParamsPsNonNestedFooRouteRouteImport } from './routes/params-ps/non-nested/$foo_/route' +import { Route as ParamsPsNamedFooRouteRouteImport } from './routes/params-ps/named/$foo/route' +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 ParamsPsNonNestedFooBarRouteImport } from './routes/params-ps/non-nested/$foo_/$bar' +import { Route as ParamsPsNamedFooBarRouteRouteImport } from './routes/params-ps/named/$foo/$bar.route' +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' +import { Route as ParamsPsNamedFooBarBazRouteImport } from './routes/params-ps/named/$foo/$bar.$baz' const groupRouteImport = createFileRoute('/(group)')() @@ -122,6 +144,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 +211,22 @@ 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 ParamsPsNonNestedRouteRoute = ParamsPsNonNestedRouteRouteImport.update({ + id: '/params-ps/non-nested', + path: '/params-ps/non-nested', + getParentRoute: () => rootRouteImport, +} as any) const RedirectTargetIndexRoute = RedirectTargetIndexRouteImport.update({ id: '/', path: '/', @@ -199,6 +242,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', @@ -264,11 +331,6 @@ const ParamsPsNamedPrefixChar123fooChar125Route = path: '/params-ps/named/prefix{$foo}', getParentRoute: () => rootRouteImport, } as any) -const ParamsPsNamedFooRoute = ParamsPsNamedFooRouteImport.update({ - id: '/params-ps/named/$foo', - path: '/params-ps/named/$foo', - getParentRoute: () => rootRouteImport, -} as any) const LayoutLayout2LayoutBRoute = LayoutLayout2LayoutBRouteImport.update({ id: '/layout-b', path: '/layout-b', @@ -289,6 +351,91 @@ const groupLayoutInsidelayoutRoute = groupLayoutInsidelayoutRouteImport.update({ path: '/insidelayout', getParentRoute: () => groupLayoutRoute, } as any) +const ParamsPsNonNestedFooRouteRoute = + ParamsPsNonNestedFooRouteRouteImport.update({ + id: '/$foo_', + path: '/$foo', + getParentRoute: () => ParamsPsNonNestedRouteRoute, + } as any) +const ParamsPsNamedFooRouteRoute = ParamsPsNamedFooRouteRouteImport.update({ + id: '/params-ps/named/$foo', + path: '/params-ps/named/$foo', + getParentRoute: () => rootRouteImport, +} 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 ParamsPsNonNestedFooBarRoute = ParamsPsNonNestedFooBarRouteImport.update({ + id: '/$bar', + path: '/$bar', + getParentRoute: () => ParamsPsNonNestedFooRouteRoute, +} as any) +const ParamsPsNamedFooBarRouteRoute = + ParamsPsNamedFooBarRouteRouteImport.update({ + id: '/$bar', + path: '/$bar', + getParentRoute: () => ParamsPsNamedFooRouteRoute, + } 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) +const ParamsPsNamedFooBarBazRoute = ParamsPsNamedFooBarBazRouteImport.update({ + id: '/$baz', + path: '/$baz', + getParentRoute: () => ParamsPsNamedFooBarRouteRoute, +} as any) export interface FileRoutesByFullPath { '/': typeof groupLayoutRouteWithChildren @@ -301,6 +448,9 @@ export interface FileRoutesByFullPath { '/posts': typeof PostsRouteWithChildren '/remountDeps': typeof RemountDepsRoute '/대한민국': typeof Char45824Char54620Char48124Char44397Route + '/params-ps/non-nested': typeof ParamsPsNonNestedRouteRouteWithChildren + '/relative/link': typeof RelativeLinkRouteRouteWithChildren + '/relative/useNavigate': typeof RelativeUseNavigateRouteRouteWithChildren '/onlyrouteinside': typeof anotherGroupOnlyrouteinsideRoute '/inside': typeof groupInsideRoute '/lazyinside': typeof groupLazyinsideRoute @@ -311,12 +461,14 @@ export interface FileRoutesByFullPath { '/params-ps': typeof ParamsPsIndexRoute '/posts/': typeof PostsIndexRoute '/redirect': typeof RedirectIndexRoute + '/relative': typeof RelativeIndexRoute '/search-params/': typeof SearchParamsIndexRoute + '/params-ps/named/$foo': typeof ParamsPsNamedFooRouteRouteWithChildren + '/params-ps/non-nested/$foo': typeof ParamsPsNonNestedFooRouteRouteWithChildren '/insidelayout': typeof groupLayoutInsidelayoutRoute '/subfolder/inside': typeof groupSubfolderInsideRoute '/layout-a': typeof LayoutLayout2LayoutARoute '/layout-b': typeof LayoutLayout2LayoutBRoute - '/params-ps/named/$foo': typeof ParamsPsNamedFooRoute '/params-ps/named/prefix{$foo}': typeof ParamsPsNamedPrefixChar123fooChar125Route '/params-ps/named/{$foo}suffix': typeof ParamsPsNamedChar123fooChar125suffixRoute '/params-ps/wildcard/$': typeof ParamsPsWildcardSplatRoute @@ -329,9 +481,26 @@ 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 + '/params-ps/named/$foo/$bar': typeof ParamsPsNamedFooBarRouteRouteWithChildren + '/params-ps/non-nested/$foo/$bar': typeof ParamsPsNonNestedFooBarRoute + '/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 + '/params-ps/named/$foo/$bar/$baz': typeof ParamsPsNamedFooBarBazRoute + '/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 +511,9 @@ export interface FileRoutesByTo { '/notRemountDeps': typeof NotRemountDepsRoute '/remountDeps': typeof RemountDepsRoute '/대한민국': typeof Char45824Char54620Char48124Char44397Route + '/params-ps/non-nested': typeof ParamsPsNonNestedRouteRouteWithChildren + '/relative/link': typeof RelativeLinkRouteRouteWithChildren + '/relative/useNavigate': typeof RelativeUseNavigateRouteRouteWithChildren '/onlyrouteinside': typeof anotherGroupOnlyrouteinsideRoute '/inside': typeof groupInsideRoute '/lazyinside': typeof groupLazyinsideRoute @@ -351,12 +523,14 @@ export interface FileRoutesByTo { '/params-ps': typeof ParamsPsIndexRoute '/posts': typeof PostsIndexRoute '/redirect': typeof RedirectIndexRoute + '/relative': typeof RelativeIndexRoute '/search-params': typeof SearchParamsIndexRoute + '/params-ps/named/$foo': typeof ParamsPsNamedFooRouteRouteWithChildren + '/params-ps/non-nested/$foo': typeof ParamsPsNonNestedFooRouteRouteWithChildren '/insidelayout': typeof groupLayoutInsidelayoutRoute '/subfolder/inside': typeof groupSubfolderInsideRoute '/layout-a': typeof LayoutLayout2LayoutARoute '/layout-b': typeof LayoutLayout2LayoutBRoute - '/params-ps/named/$foo': typeof ParamsPsNamedFooRoute '/params-ps/named/prefix{$foo}': typeof ParamsPsNamedPrefixChar123fooChar125Route '/params-ps/named/{$foo}suffix': typeof ParamsPsNamedChar123fooChar125suffixRoute '/params-ps/wildcard/$': typeof ParamsPsWildcardSplatRoute @@ -369,9 +543,26 @@ 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 + '/params-ps/named/$foo/$bar': typeof ParamsPsNamedFooBarRouteRouteWithChildren + '/params-ps/non-nested/$foo/$bar': typeof ParamsPsNonNestedFooBarRoute + '/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 + '/params-ps/named/$foo/$bar/$baz': typeof ParamsPsNamedFooBarBazRoute + '/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 +577,9 @@ export interface FileRoutesById { '/posts': typeof PostsRouteWithChildren '/remountDeps': typeof RemountDepsRoute '/대한민국': typeof Char45824Char54620Char48124Char44397Route + '/params-ps/non-nested': typeof ParamsPsNonNestedRouteRouteWithChildren + '/relative/link': typeof RelativeLinkRouteRouteWithChildren + '/relative/useNavigate': typeof RelativeUseNavigateRouteRouteWithChildren '/(another-group)/onlyrouteinside': typeof anotherGroupOnlyrouteinsideRoute '/(group)': typeof groupRouteWithChildren '/(group)/_layout': typeof groupLayoutRouteWithChildren @@ -399,12 +593,14 @@ export interface FileRoutesById { '/params-ps/': typeof ParamsPsIndexRoute '/posts/': typeof PostsIndexRoute '/redirect/': typeof RedirectIndexRoute + '/relative/': typeof RelativeIndexRoute '/search-params/': typeof SearchParamsIndexRoute + '/params-ps/named/$foo': typeof ParamsPsNamedFooRouteRouteWithChildren + '/params-ps/non-nested/$foo_': typeof ParamsPsNonNestedFooRouteRouteWithChildren '/(group)/_layout/insidelayout': typeof groupLayoutInsidelayoutRoute '/(group)/subfolder/inside': typeof groupSubfolderInsideRoute '/_layout/_layout-2/layout-a': typeof LayoutLayout2LayoutARoute '/_layout/_layout-2/layout-b': typeof LayoutLayout2LayoutBRoute - '/params-ps/named/$foo': typeof ParamsPsNamedFooRoute '/params-ps/named/prefix{$foo}': typeof ParamsPsNamedPrefixChar123fooChar125Route '/params-ps/named/{$foo}suffix': typeof ParamsPsNamedChar123fooChar125suffixRoute '/params-ps/wildcard/$': typeof ParamsPsWildcardSplatRoute @@ -417,9 +613,26 @@ 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 + '/params-ps/named/$foo/$bar': typeof ParamsPsNamedFooBarRouteRouteWithChildren + '/params-ps/non-nested/$foo_/$bar': typeof ParamsPsNonNestedFooBarRoute + '/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 + '/params-ps/named/$foo/$bar/$baz': typeof ParamsPsNamedFooBarBazRoute + '/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 +647,9 @@ export interface FileRouteTypes { | '/posts' | '/remountDeps' | '/대한민국' + | '/params-ps/non-nested' + | '/relative/link' + | '/relative/useNavigate' | '/onlyrouteinside' | '/inside' | '/lazyinside' @@ -444,12 +660,14 @@ export interface FileRouteTypes { | '/params-ps' | '/posts/' | '/redirect' + | '/relative' | '/search-params/' + | '/params-ps/named/$foo' + | '/params-ps/non-nested/$foo' | '/insidelayout' | '/subfolder/inside' | '/layout-a' | '/layout-b' - | '/params-ps/named/$foo' | '/params-ps/named/prefix{$foo}' | '/params-ps/named/{$foo}suffix' | '/params-ps/wildcard/$' @@ -462,9 +680,26 @@ 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/' + | '/params-ps/named/$foo/$bar' + | '/params-ps/non-nested/$foo/$bar' + | '/relative/link/nested' + | '/relative/link/path' + | '/relative/link/with-search' + | '/relative/useNavigate/nested' + | '/relative/useNavigate/path' + | '/relative/useNavigate/with-search' + | '/params-ps/named/$foo/$bar/$baz' + | '/relative/link/nested/deep' + | '/relative/link/path/$path' + | '/relative/useNavigate/nested/deep' + | '/relative/useNavigate/path/$path' fileRoutesByTo: FileRoutesByTo to: | '/' @@ -475,6 +710,9 @@ export interface FileRouteTypes { | '/notRemountDeps' | '/remountDeps' | '/대한민국' + | '/params-ps/non-nested' + | '/relative/link' + | '/relative/useNavigate' | '/onlyrouteinside' | '/inside' | '/lazyinside' @@ -484,12 +722,14 @@ export interface FileRouteTypes { | '/params-ps' | '/posts' | '/redirect' + | '/relative' | '/search-params' + | '/params-ps/named/$foo' + | '/params-ps/non-nested/$foo' | '/insidelayout' | '/subfolder/inside' | '/layout-a' | '/layout-b' - | '/params-ps/named/$foo' | '/params-ps/named/prefix{$foo}' | '/params-ps/named/{$foo}suffix' | '/params-ps/wildcard/$' @@ -502,9 +742,26 @@ 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' + | '/params-ps/named/$foo/$bar' + | '/params-ps/non-nested/$foo/$bar' + | '/relative/link/nested' + | '/relative/link/path' + | '/relative/link/with-search' + | '/relative/useNavigate/nested' + | '/relative/useNavigate/path' + | '/relative/useNavigate/with-search' + | '/params-ps/named/$foo/$bar/$baz' + | '/relative/link/nested/deep' + | '/relative/link/path/$path' + | '/relative/useNavigate/nested/deep' + | '/relative/useNavigate/path/$path' id: | '__root__' | '/' @@ -518,6 +775,9 @@ export interface FileRouteTypes { | '/posts' | '/remountDeps' | '/대한민국' + | '/params-ps/non-nested' + | '/relative/link' + | '/relative/useNavigate' | '/(another-group)/onlyrouteinside' | '/(group)' | '/(group)/_layout' @@ -531,12 +791,14 @@ export interface FileRouteTypes { | '/params-ps/' | '/posts/' | '/redirect/' + | '/relative/' | '/search-params/' + | '/params-ps/named/$foo' + | '/params-ps/non-nested/$foo_' | '/(group)/_layout/insidelayout' | '/(group)/subfolder/inside' | '/_layout/_layout-2/layout-a' | '/_layout/_layout-2/layout-b' - | '/params-ps/named/$foo' | '/params-ps/named/prefix{$foo}' | '/params-ps/named/{$foo}suffix' | '/params-ps/wildcard/$' @@ -549,9 +811,26 @@ 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/' + | '/params-ps/named/$foo/$bar' + | '/params-ps/non-nested/$foo_/$bar' + | '/relative/link/nested/' + | '/relative/link/path/' + | '/relative/link/with-search/' + | '/relative/useNavigate/nested/' + | '/relative/useNavigate/path/' + | '/relative/useNavigate/with-search/' + | '/params-ps/named/$foo/$bar/$baz' + | '/relative/link/nested/deep/' + | '/relative/link/path/$path/' + | '/relative/useNavigate/nested/deep/' + | '/relative/useNavigate/path/$path/' fileRoutesById: FileRoutesById } export interface RootRouteChildren { @@ -566,13 +845,17 @@ export interface RootRouteChildren { PostsRoute: typeof PostsRouteWithChildren RemountDepsRoute: typeof RemountDepsRoute Char45824Char54620Char48124Char44397Route: typeof Char45824Char54620Char48124Char44397Route + ParamsPsNonNestedRouteRoute: typeof ParamsPsNonNestedRouteRouteWithChildren + RelativeLinkRouteRoute: typeof RelativeLinkRouteRouteWithChildren + RelativeUseNavigateRouteRoute: typeof RelativeUseNavigateRouteRouteWithChildren anotherGroupOnlyrouteinsideRoute: typeof anotherGroupOnlyrouteinsideRoute groupRoute: typeof groupRouteWithChildren RedirectTargetRoute: typeof RedirectTargetRouteWithChildren StructuralSharingEnabledRoute: typeof StructuralSharingEnabledRoute ParamsPsIndexRoute: typeof ParamsPsIndexRoute RedirectIndexRoute: typeof RedirectIndexRoute - ParamsPsNamedFooRoute: typeof ParamsPsNamedFooRoute + RelativeIndexRoute: typeof RelativeIndexRoute + ParamsPsNamedFooRouteRoute: typeof ParamsPsNamedFooRouteRouteWithChildren ParamsPsNamedPrefixChar123fooChar125Route: typeof ParamsPsNamedPrefixChar123fooChar125Route ParamsPsNamedChar123fooChar125suffixRoute: typeof ParamsPsNamedChar123fooChar125suffixRoute ParamsPsWildcardSplatRoute: typeof ParamsPsWildcardSplatRoute @@ -680,6 +963,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 +1054,27 @@ 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 + } + '/params-ps/non-nested': { + id: '/params-ps/non-nested' + path: '/params-ps/non-nested' + fullPath: '/params-ps/non-nested' + preLoaderRoute: typeof ParamsPsNonNestedRouteRouteImport + parentRoute: typeof rootRouteImport + } '/redirect/$target/': { id: '/redirect/$target/' path: '/' @@ -785,6 +1096,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' @@ -869,13 +1208,6 @@ declare module '@tanstack/react-router' { preLoaderRoute: typeof ParamsPsNamedPrefixChar123fooChar125RouteImport parentRoute: typeof rootRouteImport } - '/params-ps/named/$foo': { - id: '/params-ps/named/$foo' - path: '/params-ps/named/$foo' - fullPath: '/params-ps/named/$foo' - preLoaderRoute: typeof ParamsPsNamedFooRouteImport - parentRoute: typeof rootRouteImport - } '/_layout/_layout-2/layout-b': { id: '/_layout/_layout-2/layout-b' path: '/layout-b' @@ -904,6 +1236,111 @@ declare module '@tanstack/react-router' { preLoaderRoute: typeof groupLayoutInsidelayoutRouteImport parentRoute: typeof groupLayoutRoute } + '/params-ps/non-nested/$foo_': { + id: '/params-ps/non-nested/$foo_' + path: '/$foo' + fullPath: '/params-ps/non-nested/$foo' + preLoaderRoute: typeof ParamsPsNonNestedFooRouteRouteImport + parentRoute: typeof ParamsPsNonNestedRouteRoute + } + '/params-ps/named/$foo': { + id: '/params-ps/named/$foo' + path: '/params-ps/named/$foo' + fullPath: '/params-ps/named/$foo' + preLoaderRoute: typeof ParamsPsNamedFooRouteRouteImport + parentRoute: typeof rootRouteImport + } + '/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 + } + '/params-ps/non-nested/$foo_/$bar': { + id: '/params-ps/non-nested/$foo_/$bar' + path: '/$bar' + fullPath: '/params-ps/non-nested/$foo/$bar' + preLoaderRoute: typeof ParamsPsNonNestedFooBarRouteImport + parentRoute: typeof ParamsPsNonNestedFooRouteRoute + } + '/params-ps/named/$foo/$bar': { + id: '/params-ps/named/$foo/$bar' + path: '/$bar' + fullPath: '/params-ps/named/$foo/$bar' + preLoaderRoute: typeof ParamsPsNamedFooBarRouteRouteImport + parentRoute: typeof ParamsPsNamedFooRouteRoute + } + '/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 + } + '/params-ps/named/$foo/$bar/$baz': { + id: '/params-ps/named/$foo/$bar/$baz' + path: '/$baz' + fullPath: '/params-ps/named/$foo/$bar/$baz' + preLoaderRoute: typeof ParamsPsNamedFooBarBazRouteImport + parentRoute: typeof ParamsPsNamedFooBarRouteRoute + } } } @@ -957,6 +1394,88 @@ const PostsRouteChildren: PostsRouteChildren = { const PostsRouteWithChildren = PostsRoute._addFileChildren(PostsRouteChildren) +interface ParamsPsNonNestedFooRouteRouteChildren { + ParamsPsNonNestedFooBarRoute: typeof ParamsPsNonNestedFooBarRoute +} + +const ParamsPsNonNestedFooRouteRouteChildren: ParamsPsNonNestedFooRouteRouteChildren = + { + ParamsPsNonNestedFooBarRoute: ParamsPsNonNestedFooBarRoute, + } + +const ParamsPsNonNestedFooRouteRouteWithChildren = + ParamsPsNonNestedFooRouteRoute._addFileChildren( + ParamsPsNonNestedFooRouteRouteChildren, + ) + +interface ParamsPsNonNestedRouteRouteChildren { + ParamsPsNonNestedFooRouteRoute: typeof ParamsPsNonNestedFooRouteRouteWithChildren +} + +const ParamsPsNonNestedRouteRouteChildren: ParamsPsNonNestedRouteRouteChildren = + { + ParamsPsNonNestedFooRouteRoute: ParamsPsNonNestedFooRouteRouteWithChildren, + } + +const ParamsPsNonNestedRouteRouteWithChildren = + ParamsPsNonNestedRouteRoute._addFileChildren( + ParamsPsNonNestedRouteRouteChildren, + ) + +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 } @@ -1001,6 +1520,33 @@ const RedirectTargetRouteWithChildren = RedirectTargetRoute._addFileChildren( RedirectTargetRouteChildren, ) +interface ParamsPsNamedFooBarRouteRouteChildren { + ParamsPsNamedFooBarBazRoute: typeof ParamsPsNamedFooBarBazRoute +} + +const ParamsPsNamedFooBarRouteRouteChildren: ParamsPsNamedFooBarRouteRouteChildren = + { + ParamsPsNamedFooBarBazRoute: ParamsPsNamedFooBarBazRoute, + } + +const ParamsPsNamedFooBarRouteRouteWithChildren = + ParamsPsNamedFooBarRouteRoute._addFileChildren( + ParamsPsNamedFooBarRouteRouteChildren, + ) + +interface ParamsPsNamedFooRouteRouteChildren { + ParamsPsNamedFooBarRouteRoute: typeof ParamsPsNamedFooBarRouteRouteWithChildren +} + +const ParamsPsNamedFooRouteRouteChildren: ParamsPsNamedFooRouteRouteChildren = { + ParamsPsNamedFooBarRouteRoute: ParamsPsNamedFooBarRouteRouteWithChildren, +} + +const ParamsPsNamedFooRouteRouteWithChildren = + ParamsPsNamedFooRouteRoute._addFileChildren( + ParamsPsNamedFooRouteRouteChildren, + ) + const rootRouteChildren: RootRouteChildren = { IndexRoute: IndexRoute, SearchParamsRouteRoute: SearchParamsRouteRouteWithChildren, @@ -1014,13 +1560,17 @@ const rootRouteChildren: RootRouteChildren = { RemountDepsRoute: RemountDepsRoute, Char45824Char54620Char48124Char44397Route: Char45824Char54620Char48124Char44397Route, + ParamsPsNonNestedRouteRoute: ParamsPsNonNestedRouteRouteWithChildren, + RelativeLinkRouteRoute: RelativeLinkRouteRouteWithChildren, + RelativeUseNavigateRouteRoute: RelativeUseNavigateRouteRouteWithChildren, anotherGroupOnlyrouteinsideRoute: anotherGroupOnlyrouteinsideRoute, groupRoute: groupRouteWithChildren, RedirectTargetRoute: RedirectTargetRouteWithChildren, StructuralSharingEnabledRoute: StructuralSharingEnabledRoute, ParamsPsIndexRoute: ParamsPsIndexRoute, RedirectIndexRoute: RedirectIndexRoute, - ParamsPsNamedFooRoute: ParamsPsNamedFooRoute, + RelativeIndexRoute: RelativeIndexRoute, + ParamsPsNamedFooRouteRoute: ParamsPsNamedFooRouteRouteWithChildren, ParamsPsNamedPrefixChar123fooChar125Route: ParamsPsNamedPrefixChar123fooChar125Route, ParamsPsNamedChar123fooChar125suffixRoute: 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 + {' '} +
+

Non-nested path params

+
    +
  • + + Non-nested + +
  • +
) } diff --git a/e2e/react-router/basic-file-based/src/routes/params-ps/named/$foo.tsx b/e2e/react-router/basic-file-based/src/routes/params-ps/named/$foo.tsx deleted file mode 100644 index dae4251e29..0000000000 --- a/e2e/react-router/basic-file-based/src/routes/params-ps/named/$foo.tsx +++ /dev/null @@ -1,14 +0,0 @@ -import { createFileRoute } from '@tanstack/react-router' -export const Route = createFileRoute('/params-ps/named/$foo')({ - component: RouteComponent, -}) - -function RouteComponent() { - const p = Route.useParams() - return ( -
-

ParamsNamedFoo

-
{JSON.stringify(p)}
-
- ) -} diff --git a/e2e/react-router/basic-file-based/src/routes/params-ps/named/$foo/$bar.$baz.tsx b/e2e/react-router/basic-file-based/src/routes/params-ps/named/$foo/$bar.$baz.tsx new file mode 100644 index 0000000000..2a38545def --- /dev/null +++ b/e2e/react-router/basic-file-based/src/routes/params-ps/named/$foo/$bar.$baz.tsx @@ -0,0 +1,17 @@ +import { createFileRoute } from '@tanstack/react-router' + +export const Route = createFileRoute('/params-ps/named/$foo/$bar/$baz')({ + component: RouteComponent, +}) + +function RouteComponent() { + const { foo, bar, baz } = Route.useParams() + return ( +
+ Hello "/params-ps/named/{foo}/{bar}/{baz}"! +
+ baz: {baz} +
+
+ ) +} diff --git a/e2e/react-router/basic-file-based/src/routes/params-ps/named/$foo/$bar.route.tsx b/e2e/react-router/basic-file-based/src/routes/params-ps/named/$foo/$bar.route.tsx new file mode 100644 index 0000000000..653dcd951a --- /dev/null +++ b/e2e/react-router/basic-file-based/src/routes/params-ps/named/$foo/$bar.route.tsx @@ -0,0 +1,45 @@ +import { + Link, + Outlet, + createFileRoute, + useParams, +} from '@tanstack/react-router' +import { RenderCounter } from '../../../../components/RenderCounter' + +export const Route = createFileRoute('/params-ps/named/$foo/$bar')({ + component: RouteComponent, +}) + +function RouteComponent() { + const { foo, bar, baz } = useParams({ + strict: false, + }) + + return ( +
+ Hello "/params-ps/named/{foo}/{bar}"! +
+ Bar Render Count:{' '} + + + +
+
+ Bar: {bar} +
+
+ Baz in Bar:{' '} + {baz ?? 'no param'} +
+ + To Baz + + +
+ ) +} diff --git a/e2e/react-router/basic-file-based/src/routes/params-ps/named/$foo/route.tsx b/e2e/react-router/basic-file-based/src/routes/params-ps/named/$foo/route.tsx new file mode 100644 index 0000000000..432facc3cc --- /dev/null +++ b/e2e/react-router/basic-file-based/src/routes/params-ps/named/$foo/route.tsx @@ -0,0 +1,42 @@ +import { Link, Outlet, createFileRoute } from '@tanstack/react-router' +import { RenderCounter } from '../../../../components/RenderCounter' + +export const Route = createFileRoute('/params-ps/named/$foo')({ + component: RouteComponent, +}) + +function RouteComponent() { + const foo = Route.useParams() + return ( +
+

ParamsNamedFoo

+
+ RenderCount:{' '} + + + +
+
{JSON.stringify(foo)}
+ + Index + + + Bar1 + + + Bar2 + + +
+ ) +} diff --git a/e2e/react-router/basic-file-based/src/routes/params-ps/named/index.tsx b/e2e/react-router/basic-file-based/src/routes/params-ps/named/index.tsx index f9a9a7ac06..e11cbd530c 100644 --- a/e2e/react-router/basic-file-based/src/routes/params-ps/named/index.tsx +++ b/e2e/react-router/basic-file-based/src/routes/params-ps/named/index.tsx @@ -1,5 +1,4 @@ -import { createFileRoute } from '@tanstack/react-router' -import { redirect } from '@tanstack/react-router' +import { createFileRoute, redirect } from '@tanstack/react-router' export const Route = createFileRoute('/params-ps/named/')({ beforeLoad: () => { diff --git a/e2e/react-router/basic-file-based/src/routes/params-ps/non-nested/$foo_/$bar.tsx b/e2e/react-router/basic-file-based/src/routes/params-ps/non-nested/$foo_/$bar.tsx new file mode 100644 index 0000000000..4f1406030d --- /dev/null +++ b/e2e/react-router/basic-file-based/src/routes/params-ps/non-nested/$foo_/$bar.tsx @@ -0,0 +1,19 @@ +import { createFileRoute, useParams } from '@tanstack/react-router' + +export const Route = createFileRoute('/params-ps/non-nested/$foo_/$bar')({ + component: RouteComponent, +}) + +function RouteComponent() { + const fooParams = useParams({ from: '/params-ps/non-nested/$foo_' }) + const routeParams = Route.useParams() + + return ( +
+
{JSON.stringify(fooParams)}
+
+ {JSON.stringify(routeParams)} +
+
+ ) +} diff --git a/e2e/react-router/basic-file-based/src/routes/params-ps/non-nested/$foo_/route.tsx b/e2e/react-router/basic-file-based/src/routes/params-ps/non-nested/$foo_/route.tsx new file mode 100644 index 0000000000..a05ef2993b --- /dev/null +++ b/e2e/react-router/basic-file-based/src/routes/params-ps/non-nested/$foo_/route.tsx @@ -0,0 +1,3 @@ +import { createFileRoute } from '@tanstack/react-router' + +export const Route = createFileRoute('/params-ps/non-nested/$foo_')() diff --git a/e2e/react-router/basic-file-based/src/routes/params-ps/non-nested/route.tsx b/e2e/react-router/basic-file-based/src/routes/params-ps/non-nested/route.tsx new file mode 100644 index 0000000000..3760bde708 --- /dev/null +++ b/e2e/react-router/basic-file-based/src/routes/params-ps/non-nested/route.tsx @@ -0,0 +1,26 @@ +import { Link, Outlet, createFileRoute } from '@tanstack/react-router' + +export const Route = createFileRoute('/params-ps/non-nested')({ + component: RouteComponent, +}) + +function RouteComponent() { + return ( +
+

Non-nested path params

+ + +
+ ) +} diff --git a/e2e/react-router/basic-file-based/src/routes/relative/index.tsx b/e2e/react-router/basic-file-based/src/routes/relative/index.tsx new file mode 100644 index 0000000000..0450c32433 --- /dev/null +++ b/e2e/react-router/basic-file-based/src/routes/relative/index.tsx @@ -0,0 +1,22 @@ +import { Link, Outlet, createFileRoute } from '@tanstack/react-router' + +export const Route = createFileRoute('/relative/')({ + component: RouteComponent, +}) + +function RouteComponent() { + return ( +
+
+ 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}"! +
+
+ +
+
+ ) +} 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 +
+
+ + + + + + + + + +
+
+ +
+
+ ) +} 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}! +
+
+ + + ) +} diff --git a/e2e/react-router/basic-file-based/tests/params.spec.ts b/e2e/react-router/basic-file-based/tests/params.spec.ts index 546fa80d31..d4d6d2e602 100644 --- a/e2e/react-router/basic-file-based/tests/params.spec.ts +++ b/e2e/react-router/basic-file-based/tests/params.spec.ts @@ -55,6 +55,37 @@ test.describe('ensure single params have been parsed correctly whilst being stab } }) +test.describe('params operations + non-nested routes', () => { + test.beforeEach(async ({ page }) => { + await page.goto('/params-ps/non-nested') + }) + + test('useParams must resolve non-nested path params', async ({ page }) => { + await page.waitForURL('/params-ps/non-nested') + + const fooBarLink = page.getByTestId('l-to-non-nested-foo-bar') + + await expect(fooBarLink).toHaveAttribute( + 'href', + '/params-ps/non-nested/foo/bar', + ) + await fooBarLink.click() + await page.waitForLoadState('networkidle') + const pagePathname = new URL(page.url()).pathname + expect(pagePathname).toBe('/params-ps/non-nested/foo/bar') + + const fooParamsValue = page.getByTestId('foo-params-value') + const fooParamsText = await fooParamsValue.innerText() + const fooParamsObj = JSON.parse(fooParamsText) + expect(fooParamsObj).toEqual({ foo: 'foo' }) + + const paramsValue = page.getByTestId('foo-bar-params-value') + const paramsText = await paramsValue.innerText() + const paramsObj = JSON.parse(paramsText) + expect(paramsObj).toEqual({ foo: 'foo', bar: 'bar' }) + }) +}) + test.describe('params operations + prefix/suffix', () => { test.beforeEach(async ({ page }) => { await page.goto('/params-ps') @@ -129,6 +160,80 @@ test.describe('params operations + prefix/suffix', () => { expect(paramsObj).toEqual(params) }) }) + + test(`ensure use params doesn't cause excess renders and is stable across various usage options`, async ({ + page, + }) => { + await page.goto('/params-ps/named/foo') + await page.waitForLoadState('networkidle') + + const pagePathname = new URL(page.url()).pathname + expect(pagePathname).toBe('/params-ps/named/foo') + + const fooRenderCount = page.getByTestId('foo-render-count') + const fooIndexLink = page.getByTestId('params-foo-links-index') + const fooBar1Link = page.getByTestId('params-foo-links-bar1') + const fooBar2Link = page.getByTestId('params-foo-links-bar2') + const fooBarBazLink = page.getByTestId('params-foo-bar-links-baz') + const fooValue = page.getByTestId('params-output') + const fooBarValue = page.getByTestId('foo-bar-value') + const fooBazInBarValue = page.getByTestId('foo-baz-in-bar-value') + const fooBarRenderCount = page.getByTestId('foo-bar-render-count') + const fooBarBazValue = page.getByTestId('foo-bar-baz-value') + + await expect(fooRenderCount).toBeInViewport() + await expect(fooValue).toBeInViewport() + await expect(fooIndexLink).toBeInViewport() + await expect(fooBar1Link).toBeInViewport() + await expect(fooBar2Link).toBeInViewport() + await expect(fooRenderCount).toHaveText('1') + await expect(fooValue).toHaveText(JSON.stringify({ foo: 'foo' })) + + await fooBar1Link.click() + await page.waitForLoadState('networkidle') + await expect(fooValue).toBeInViewport() + await expect(fooRenderCount).toBeInViewport() + await expect(fooBarRenderCount).toBeInViewport() + await expect(fooBarValue).toBeInViewport() + await expect(fooBazInBarValue).toBeInViewport() + await expect(fooBarBazLink).toBeInViewport() + await expect(fooValue).toHaveText(JSON.stringify({ foo: 'foo' })) + await expect(fooRenderCount).toHaveText('1') + await expect(fooBarRenderCount).toHaveText('1') + await expect(fooBarValue).toHaveText('1') + await expect(fooBazInBarValue).toHaveText('no param') + + await fooBarBazLink.click() + await page.waitForLoadState('networkidle') + await expect(fooValue).toBeInViewport() + await expect(fooRenderCount).toBeInViewport() + await expect(fooBarRenderCount).toBeInViewport() + await expect(fooBarValue).toBeInViewport() + await expect(fooBazInBarValue).toBeInViewport() + await expect(fooValue).toHaveText(JSON.stringify({ foo: 'foo' })) + await expect(fooRenderCount).toHaveText('1') + await expect(fooBarRenderCount).toHaveText('2') + await expect(fooBarValue).toHaveText('1') + await expect(fooBazInBarValue).toHaveText('1_10') + await expect(fooBarBazValue).toHaveText('1_10') + + await fooBar2Link.click() + await page.waitForLoadState('networkidle') + await expect(fooValue).toBeInViewport() + await expect(fooRenderCount).toBeInViewport() + await expect(fooBarValue).toBeInViewport() + await expect(fooValue).toHaveText(JSON.stringify({ foo: 'foo' })) + await expect(fooRenderCount).toHaveText('1') + await expect(fooBarValue).toHaveText('2') + + await fooIndexLink.click() + await page.waitForLoadState('networkidle') + await expect(fooValue).toBeInViewport() + await expect(fooRenderCount).toBeInViewport() + await expect(fooBarValue).not.toBeInViewport() + await expect(fooValue).toHaveText(JSON.stringify({ foo: 'foo' })) + await expect(fooRenderCount).toHaveText('1') + }) }) test.describe('wildcard param', () => { diff --git a/e2e/react-router/basic-file-based/tests/redirect.spec.ts b/e2e/react-router/basic-file-based/tests/redirect.spec.ts index 63d36d9610..8ec1a1698e 100644 --- a/e2e/react-router/basic-file-based/tests/redirect.spec.ts +++ b/e2e/react-router/basic-file-based/tests/redirect.spec.ts @@ -53,6 +53,7 @@ test.describe('redirects', () => { setTimeout(resolve, expectRequestHappened ? 5000 : 500), ) await Promise.race([requestPromise, timeoutPromise]) + await page.waitForLoadState('networkidle') expect(requestHappened).toBe(expectRequestHappened) await link.click() let fullPageLoad = false 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-scroll-restoration/tests/app.spec.ts b/e2e/react-router/basic-scroll-restoration/tests/app.spec.ts index af79f97c52..c7360ce8a4 100644 --- a/e2e/react-router/basic-scroll-restoration/tests/app.spec.ts +++ b/e2e/react-router/basic-scroll-restoration/tests/app.spec.ts @@ -5,6 +5,7 @@ test('restore scroll positions by page, home pages top message should not displa }) => { // Step 1: Navigate to the home page await page.goto('/') + await page.waitForURL('/') await expect(page.locator('#greeting')).toContainText('Welcome Home!') await expect(page.locator('#top-message')).toBeInViewport() @@ -45,6 +46,7 @@ test('restore scroll positions by element, first regular list item should not di }) => { // Step 1: Navigate to the by-element page await page.goto('/by-element') + await page.waitForURL('/by-element') // Step 2: Scroll to a position that hides the first list item in regular list const targetScrollPosition = 1000 @@ -86,6 +88,7 @@ test('scroll to top when not scrolled, regression test for #4782', async ({ page, }) => { await page.goto('/foo') + await page.waitForURL('/foo') await expect(page.getByTestId('foo-route-component')).toBeVisible() diff --git a/e2e/react-router/basic-virtual-file-based/package.json b/e2e/react-router/basic-virtual-file-based/package.json index ccfaa1ff49..49e8a3fe1a 100644 --- a/e2e/react-router/basic-virtual-file-based/package.json +++ b/e2e/react-router/basic-virtual-file-based/package.json @@ -29,6 +29,6 @@ "@types/react": "^19.0.8", "@types/react-dom": "^19.0.3", "@vitejs/plugin-react": "^4.3.4", - "vite": "^6.3.5" + "vite": "^7.1.1" } } diff --git a/e2e/react-router/basic-virtual-named-export-config-file-based/package.json b/e2e/react-router/basic-virtual-named-export-config-file-based/package.json index cc0549be9c..74d013545f 100644 --- a/e2e/react-router/basic-virtual-named-export-config-file-based/package.json +++ b/e2e/react-router/basic-virtual-named-export-config-file-based/package.json @@ -29,6 +29,6 @@ "@types/react": "^19.0.8", "@types/react-dom": "^19.0.3", "@vitejs/plugin-react": "^4.3.4", - "vite": "^6.3.5" + "vite": "^7.1.1" } } diff --git a/e2e/react-router/basic-virtual-named-export-config-file-based/tests/app.spec.ts b/e2e/react-router/basic-virtual-named-export-config-file-based/tests/app.spec.ts index 3e5a69ccaa..0aedada786 100644 --- a/e2e/react-router/basic-virtual-named-export-config-file-based/tests/app.spec.ts +++ b/e2e/react-router/basic-virtual-named-export-config-file-based/tests/app.spec.ts @@ -5,12 +5,14 @@ test.beforeEach(async ({ page }) => { }) test('Navigating to a post page', async ({ page }) => { + await page.waitForURL('/') await page.getByRole('link', { name: 'Posts' }).click() await page.getByRole('link', { name: 'sunt aut facere repe' }).click() await expect(page.getByRole('heading')).toContainText('sunt aut facere') }) test('Navigating nested layouts', async ({ page }) => { + await page.waitForURL('/') await page.getByRole('link', { name: 'Layout', exact: true }).click() await expect(page.locator('#app')).toContainText("I'm a layout") @@ -24,6 +26,7 @@ test('Navigating nested layouts', async ({ page }) => { }) test('Navigating to a not-found route', async ({ page }) => { + await page.waitForURL('/') await page.getByRole('link', { name: 'This Route Does Not Exist' }).click() await expect(page.getByRole('paragraph')).toContainText( 'This is the notFoundComponent configured on root route', 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/rspack-basic-virtual-named-export-config-file-based/tests/app.spec.ts b/e2e/react-router/rspack-basic-virtual-named-export-config-file-based/tests/app.spec.ts index 10beff655f..a689f459e3 100644 --- a/e2e/react-router/rspack-basic-virtual-named-export-config-file-based/tests/app.spec.ts +++ b/e2e/react-router/rspack-basic-virtual-named-export-config-file-based/tests/app.spec.ts @@ -5,12 +5,14 @@ test.beforeEach(async ({ page }) => { }) test('Navigating to a post page', async ({ page }) => { + await page.waitForURL('/') await page.getByRole('link', { name: 'Posts' }).click() await page.getByRole('link', { name: 'sunt aut facere repe' }).click() await expect(page.getByRole('heading')).toContainText('sunt aut facere') }) test('Navigating nested layouts', async ({ page }) => { + await page.waitForURL('/') await page.getByRole('link', { name: 'Layout', exact: true }).click() await expect(page.locator('#root')).toContainText("I'm a layout") @@ -24,6 +26,7 @@ test('Navigating nested layouts', async ({ page }) => { }) test('Navigating to a not-found route', async ({ page }) => { + await page.waitForURL('/') await page.getByRole('link', { name: 'This Route Does Not Exist' }).click() await expect(page.getByRole('paragraph')).toContainText( 'This is the notFoundComponent configured on root route', diff --git a/e2e/react-router/scroll-restoration-sandbox-vite/package.json b/e2e/react-router/scroll-restoration-sandbox-vite/package.json index 1a28218b4f..8469b9a79c 100644 --- a/e2e/react-router/scroll-restoration-sandbox-vite/package.json +++ b/e2e/react-router/scroll-restoration-sandbox-vite/package.json @@ -32,6 +32,6 @@ "@types/react": "^19.0.8", "@types/react-dom": "^19.0.3", "@vitejs/plugin-react": "^4.3.4", - "vite": "^6.3.5" + "vite": "^7.1.1" } } diff --git a/e2e/react-router/sentry-integration/package.json b/e2e/react-router/sentry-integration/package.json index e653d74ffb..44fa594fa0 100644 --- a/e2e/react-router/sentry-integration/package.json +++ b/e2e/react-router/sentry-integration/package.json @@ -29,6 +29,6 @@ "@types/react": "^19.0.8", "@types/react-dom": "^19.0.3", "@vitejs/plugin-react": "^4.3.4", - "vite": "^6.3.5" + "vite": "^7.1.1" } } diff --git a/e2e/react-router/sentry-integration/tests/app.spec.ts b/e2e/react-router/sentry-integration/tests/app.spec.ts index 9a3b53a966..1de2800c80 100644 --- a/e2e/react-router/sentry-integration/tests/app.spec.ts +++ b/e2e/react-router/sentry-integration/tests/app.spec.ts @@ -1,6 +1,5 @@ import { expect } from '@playwright/test' - -import { test } from './fixture' +import { test } from '@tanstack/router-e2e-utils' test.beforeEach(async ({ page }) => { await page.goto('/') diff --git a/e2e/react-start/basic-auth/package.json b/e2e/react-start/basic-auth/package.json index f5ee14762e..4578e784a3 100644 --- a/e2e/react-start/basic-auth/package.json +++ b/e2e/react-start/basic-auth/package.json @@ -21,7 +21,7 @@ "react-dom": "^19.0.0", "redaxios": "^0.5.1", "tailwind-merge": "^2.6.0", - "vite": "^6.3.5" + "vite": "^7.1.1" }, "devDependencies": { "@playwright/test": "^1.50.1", diff --git a/e2e/react-start/basic-auth/vite.config.ts b/e2e/react-start/basic-auth/vite.config.ts index 1df337cd40..dc57f144e4 100644 --- a/e2e/react-start/basic-auth/vite.config.ts +++ b/e2e/react-start/basic-auth/vite.config.ts @@ -1,6 +1,7 @@ import { defineConfig } from 'vite' import tsConfigPaths from 'vite-tsconfig-paths' import { tanstackStart } from '@tanstack/react-start/plugin/vite' +import viteReact from '@vitejs/plugin-react' export default defineConfig({ plugins: [ @@ -8,5 +9,6 @@ export default defineConfig({ projects: ['./tsconfig.json'], }), tanstackStart(), + viteReact(), ], }) diff --git a/e2e/react-start/basic-react-query/package.json b/e2e/react-start/basic-react-query/package.json index 284e0626f7..ac0c200bd6 100644 --- a/e2e/react-start/basic-react-query/package.json +++ b/e2e/react-start/basic-react-query/package.json @@ -7,7 +7,7 @@ "dev": "vite dev --port 3000", "dev:e2e": "vite dev", "build": "vite build && tsc --noEmit", - "start": "node .output/server/index.mjs", + "start": "pnpx srvx --prod -s ../client dist/server/server.js", "test:e2e": "rm -rf port*.txt; playwright test --project=chromium" }, "dependencies": { @@ -21,7 +21,7 @@ "react-dom": "^19.0.0", "redaxios": "^0.5.1", "tailwind-merge": "^2.6.0", - "vite": "^6.3.5" + "vite": "^7.1.1" }, "devDependencies": { "@playwright/test": "^1.50.1", @@ -32,6 +32,7 @@ "@vitejs/plugin-react": "^4.3.4", "autoprefixer": "^10.4.20", "postcss": "^8.5.1", + "srvx": "^0.8.6", "tailwindcss": "^3.4.17", "typescript": "^5.7.2", "vite-tsconfig-paths": "^5.1.4" diff --git a/e2e/react-start/basic-react-query/vite.config.ts b/e2e/react-start/basic-react-query/vite.config.ts index 1df337cd40..dc57f144e4 100644 --- a/e2e/react-start/basic-react-query/vite.config.ts +++ b/e2e/react-start/basic-react-query/vite.config.ts @@ -1,6 +1,7 @@ import { defineConfig } from 'vite' import tsConfigPaths from 'vite-tsconfig-paths' import { tanstackStart } from '@tanstack/react-start/plugin/vite' +import viteReact from '@vitejs/plugin-react' export default defineConfig({ plugins: [ @@ -8,5 +9,6 @@ export default defineConfig({ projects: ['./tsconfig.json'], }), tanstackStart(), + viteReact(), ], }) diff --git a/e2e/react-start/basic-rsc/package.json b/e2e/react-start/basic-rsc/package.json index 9c820c9ccd..30ac070db2 100644 --- a/e2e/react-start/basic-rsc/package.json +++ b/e2e/react-start/basic-rsc/package.json @@ -17,7 +17,7 @@ "react-dom": "^19.0.0", "redaxios": "^0.5.1", "tailwind-merge": "^2.6.0", - "vite": "^6.3.5" + "vite": "^7.1.1" }, "devDependencies": { "@types/react": "^19.0.8", diff --git a/e2e/react-start/basic-rsc/vite.config.ts b/e2e/react-start/basic-rsc/vite.config.ts index 1df337cd40..dc57f144e4 100644 --- a/e2e/react-start/basic-rsc/vite.config.ts +++ b/e2e/react-start/basic-rsc/vite.config.ts @@ -1,6 +1,7 @@ import { defineConfig } from 'vite' import tsConfigPaths from 'vite-tsconfig-paths' import { tanstackStart } from '@tanstack/react-start/plugin/vite' +import viteReact from '@vitejs/plugin-react' export default defineConfig({ plugins: [ @@ -8,5 +9,6 @@ export default defineConfig({ projects: ['./tsconfig.json'], }), tanstackStart(), + viteReact(), ], }) diff --git a/e2e/react-start/basic-tsr-config/package.json b/e2e/react-start/basic-tsr-config/package.json index 6e36695183..a41ed7d467 100644 --- a/e2e/react-start/basic-tsr-config/package.json +++ b/e2e/react-start/basic-tsr-config/package.json @@ -7,7 +7,7 @@ "dev": "vite dev --port 3000", "dev:e2e": "vite dev", "build": "rimraf ./count.txt && vite build && tsc --noEmit", - "start": "node .output/server/index.mjs", + "start": "pnpx srvx --prod -s ../client dist/server/server.js", "test:e2e": "rm -rf port*.txt; playwright test --project=chromium" }, "dependencies": { @@ -15,13 +15,14 @@ "@tanstack/react-start": "workspace:^", "react": "^19.0.0", "react-dom": "^19.0.0", - "vite": "^6.3.5" + "vite": "^7.1.1" }, "devDependencies": { "@tanstack/router-e2e-utils": "workspace:^", "@types/node": "^22.10.2", "@types/react": "^19.0.8", "@types/react-dom": "^19.0.3", + "srvx": "^0.8.6", "typescript": "^5.7.2" } } diff --git a/e2e/react-start/basic-tsr-config/tests/app.spec.ts b/e2e/react-start/basic-tsr-config/tests/app.spec.ts index e3488df952..07a562fcb3 100644 --- a/e2e/react-start/basic-tsr-config/tests/app.spec.ts +++ b/e2e/react-start/basic-tsr-config/tests/app.spec.ts @@ -2,9 +2,14 @@ import { expect, test } from '@playwright/test' test('opening the app', async ({ page }) => { await page.goto('/') - - await expect(page.getByTestId('add-button')).toContainText('Add 1 to 0?') - await page.getByTestId('add-button').click() await page.waitForLoadState('networkidle') - await expect(page.getByTestId('add-button')).toContainText('Add 1 to 1?') + + const button = page.getByTestId('add-button') + + await expect(button).toContainText('Add 1 to 0?') + + await button.click() + await page.waitForLoadState('networkidle') + + await expect(button).toContainText('Add 1 to 1?') }) diff --git a/e2e/react-start/basic-tsr-config/vite.config.ts b/e2e/react-start/basic-tsr-config/vite.config.ts index 69045b5a44..92aabad3ba 100644 --- a/e2e/react-start/basic-tsr-config/vite.config.ts +++ b/e2e/react-start/basic-tsr-config/vite.config.ts @@ -7,9 +7,7 @@ export default defineConfig({ }, plugins: [ tanstackStart({ - tsr: { - srcDirectory: './src/app', - }, + srcDirectory: './src/app', }), ], }) diff --git a/e2e/react-start/basic/package.json b/e2e/react-start/basic/package.json index 57309b87a4..b3f2fe4b23 100644 --- a/e2e/react-start/basic/package.json +++ b/e2e/react-start/basic/package.json @@ -7,7 +7,7 @@ "dev": "vite dev --port 3000", "dev:e2e": "vite dev", "build": "vite build && tsc --noEmit", - "start": "node .output/server/index.mjs", + "start": "pnpx srvx --prod -s ../client dist/server/server.js", "test:e2e": "rm -rf port*.txt; playwright test --project=chromium" }, "dependencies": { @@ -17,9 +17,7 @@ "react": "^19.0.0", "react-dom": "^19.0.0", "redaxios": "^0.5.1", - "tailwind-merge": "^2.6.0", - "vite": "6.3.5", - "zod": "^3.24.2" + "tailwind-merge": "^2.6.0" }, "devDependencies": { "@playwright/test": "^1.50.1", @@ -31,8 +29,11 @@ "autoprefixer": "^10.4.20", "combinate": "^1.1.11", "postcss": "^8.5.1", + "srvx": "^0.8.6", "tailwindcss": "^3.4.17", "typescript": "^5.7.2", - "vite-tsconfig-paths": "^5.1.4" + "vite": "^7.1.1", + "vite-tsconfig-paths": "^5.1.4", + "zod": "^3.24.2" } } diff --git a/e2e/react-start/basic/src/server.ts b/e2e/react-start/basic/src/server.ts index 77cb4a1316..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/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 ( +
+ +
+ {JSON.stringify(validResponse)} +
+ +
+ +
+ {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-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()} + +

+ +
+ ) +} +function RouteComponent() { + return ( +
+

+ Server functions middleware E2E tests +

+ {Object.entries(functions).map(([name, testCase]) => ( + + ))} +
+ ) +} diff --git a/e2e/react-start/server-functions/src/routes/headers.tsx b/e2e/react-start/server-functions/src/routes/headers.tsx index 77c576e40b..79b05c0fcb 100644 --- a/e2e/react-start/server-functions/src/routes/headers.tsx +++ b/e2e/react-start/server-functions/src/routes/headers.tsx @@ -1,8 +1,11 @@ import { createFileRoute } from '@tanstack/react-router' import * as React from 'react' import { createServerFn } from '@tanstack/react-start' -import { getHeaders, setHeader } from '@tanstack/react-start/server' -import type { HTTPHeaderName } from '@tanstack/react-start/server' +import { + getRequestHeaders, + setResponseHeader, +} from '@tanstack/react-start/server' +import type { RequestHeaderName } from '@tanstack/react-start/server' export const Route = createFileRoute('/headers')({ loader: async () => { @@ -17,17 +20,18 @@ export const Route = createFileRoute('/headers')({ }) export const getTestHeaders = createServerFn().handler(() => { - setHeader('x-test-header', 'test-value') + setResponseHeader('x-test-header', 'test-value') + const reqHeaders = Object.fromEntries(getRequestHeaders().entries()) return { - serverHeaders: getHeaders(), - headers: getHeaders(), + serverHeaders: reqHeaders, + headers: reqHeaders, } }) type TestHeadersResult = { - headers?: Partial> - serverHeaders?: Partial> + headers?: Partial> + serverHeaders?: Partial> } function ResponseHeaders({ diff --git a/e2e/react-start/server-functions/src/routes/index.tsx b/e2e/react-start/server-functions/src/routes/index.tsx index 949cc08f58..6251940689 100644 --- a/e2e/react-start/server-functions/src/routes/index.tsx +++ b/e2e/react-start/server-functions/src/routes/index.tsx @@ -85,6 +85,9 @@ function Home() {
  • Server Functions Middlware E2E tests
  • +
  • + Server Functions Factory E2E tests +
  • ) diff --git a/e2e/react-start/server-functions/src/routes/raw-response.tsx b/e2e/react-start/server-functions/src/routes/raw-response.tsx index 8da5f8af7d..f30ff6660e 100644 --- a/e2e/react-start/server-functions/src/routes/raw-response.tsx +++ b/e2e/react-start/server-functions/src/routes/raw-response.tsx @@ -8,7 +8,7 @@ export const Route = createFileRoute('/raw-response')({ }) const expectedValue = 'Hello from a server function!' -export const rawResponseFn = createServerFn({ response: 'raw' }).handler(() => { +export const rawResponseFn = createServerFn().handler(() => { return new Response(expectedValue) }) diff --git a/e2e/react-start/server-functions/src/routes/serialize-form-data.tsx b/e2e/react-start/server-functions/src/routes/serialize-form-data.tsx index b1b9dc777a..5429df98c8 100644 --- a/e2e/react-start/server-functions/src/routes/serialize-form-data.tsx +++ b/e2e/react-start/server-functions/src/routes/serialize-form-data.tsx @@ -15,7 +15,7 @@ const testValues = { __adder: 1, } -export const greetUser = createServerFn() +export const greetUser = createServerFn({ method: 'POST' }) .validator((data: FormData) => { if (!(data instanceof FormData)) { throw new Error('Invalid! FormData is required') diff --git a/e2e/react-start/server-functions/src/routes/submit-post-formdata.tsx b/e2e/react-start/server-functions/src/routes/submit-post-formdata.tsx index 05df922817..4369239a05 100644 --- a/e2e/react-start/server-functions/src/routes/submit-post-formdata.tsx +++ b/e2e/react-start/server-functions/src/routes/submit-post-formdata.tsx @@ -9,7 +9,7 @@ const testValues = { name: 'Sean', } -export const greetUser = createServerFn({ method: 'POST', response: 'raw' }) +export const greetUser = createServerFn({ method: 'POST' }) .validator((data: FormData) => { if (!(data instanceof FormData)) { throw new Error('Invalid! FormData is required') diff --git a/e2e/react-start/server-functions/tests/fixture.ts b/e2e/react-start/server-functions/tests/fixture.ts deleted file mode 100644 index abb7b1d564..0000000000 --- a/e2e/react-start/server-functions/tests/fixture.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { test as base, expect } from '@playwright/test' - -export interface TestFixtureOptions { - whitelistErrors: Array -} -export const test = base.extend({ - whitelistErrors: [[], { option: true }], - page: async ({ page, whitelistErrors }, use) => { - const errorMessages: Array = [] - page.on('console', (m) => { - if (m.type() === 'error') { - const text = m.text() - for (const whitelistError of whitelistErrors) { - if ( - (typeof whitelistError === 'string' && - text.includes(whitelistError)) || - (whitelistError instanceof RegExp && whitelistError.test(text)) - ) { - return - } - } - errorMessages.push(text) - } - }) - await use(page) - expect(errorMessages).toEqual([]) - }, -}) diff --git a/e2e/react-start/server-functions/tests/server-functions.spec.ts b/e2e/react-start/server-functions/tests/server-functions.spec.ts index 86332e7491..990487289f 100644 --- a/e2e/react-start/server-functions/tests/server-functions.spec.ts +++ b/e2e/react-start/server-functions/tests/server-functions.spec.ts @@ -1,8 +1,11 @@ import * as fs from 'node:fs' -import { expect, test } from '@playwright/test' -import { PORT } from '../playwright.config' +import { expect } from '@playwright/test' +import { getTestServerPort, test } from '@tanstack/router-e2e-utils' +import packageJson from '../package.json' with { type: 'json' } import type { Page } from '@playwright/test' +const PORT = await getTestServerPort(packageJson.name) + test('invoking a server function with custom response status code', async ({ page, }) => { @@ -11,16 +14,10 @@ test('invoking a server function with custom response status code', async ({ await page.waitForLoadState('networkidle') const requestPromise = new Promise((resolve) => { - page.on('response', async (response) => { + page.on('response', (response) => { expect(response.status()).toBe(225) expect(response.statusText()).toBe('hello') - expect(response.headers()['content-type']).toBe('application/json') - expect(await response.json()).toEqual( - expect.objectContaining({ - result: { hello: 'world' }, - context: {}, - }), - ) + expect(response.headers()['content-type']).toContain('application/json') resolve() }) }) @@ -122,11 +119,11 @@ test('env-only functions can only be called on the server or client respectively 'server got: hello', ) await expect(page.getByTestId('server-on-client')).toContainText( - 'serverEcho threw an error: serverOnly() functions can only be called on the server!', + 'serverEcho threw an error: createServerOnlyFn() functions can only be called on the server!', ) await expect(page.getByTestId('client-on-server')).toContainText( - 'clientEcho threw an error: clientOnly() functions can only be called on the client!', + 'clientEcho threw an error: createClientOnlyFn() functions can only be called on the client!', ) await expect(page.getByTestId('client-on-client')).toContainText( 'client got: hello', @@ -372,3 +369,37 @@ test.describe('middleware', () => { }) }) }) + +test('factory', async ({ page }) => { + await page.goto('/factory') + + await expect(page.getByTestId('factory-route-component')).toBeInViewport() + + const buttons = await page + .locator('[data-testid^="btn-fn-"]') + .elementHandles() + for (const button of buttons) { + const testId = await button.getAttribute('data-testid') + + if (!testId) { + throw new Error('Button is missing data-testid') + } + + const suffix = testId.replace('btn-fn-', '') + + const expected = + (await page.getByTestId(`expected-fn-result-${suffix}`).textContent()) || + '' + expect(expected).not.toBe('') + + await button.click() + + await expect(page.getByTestId(`fn-result-${suffix}`)).toContainText( + expected, + ) + + await expect(page.getByTestId(`fn-comparison-${suffix}`)).toContainText( + 'equal', + ) + } +}) diff --git a/e2e/react-start/server-functions/vite.config.ts b/e2e/react-start/server-functions/vite.config.ts index 1df337cd40..dc57f144e4 100644 --- a/e2e/react-start/server-functions/vite.config.ts +++ b/e2e/react-start/server-functions/vite.config.ts @@ -1,6 +1,7 @@ import { defineConfig } from 'vite' import tsConfigPaths from 'vite-tsconfig-paths' import { tanstackStart } from '@tanstack/react-start/plugin/vite' +import viteReact from '@vitejs/plugin-react' export default defineConfig({ plugins: [ @@ -8,5 +9,6 @@ export default defineConfig({ projects: ['./tsconfig.json'], }), tanstackStart(), + viteReact(), ], }) diff --git a/e2e/react-start/server-routes/package.json b/e2e/react-start/server-routes/package.json index e7352c35ce..614c5d1552 100644 --- a/e2e/react-start/server-routes/package.json +++ b/e2e/react-start/server-routes/package.json @@ -7,7 +7,7 @@ "dev": "vite dev --port 3000", "dev:e2e": "vite dev", "build": "vite build && tsc --noEmit", - "start": "node .output/server/index.mjs", + "start": "pnpx srvx --prod -s ../client dist/server/server.js", "test:e2e": "playwright test --project=chromium" }, "dependencies": { @@ -19,7 +19,7 @@ "react-dom": "^19.0.0", "redaxios": "^0.5.1", "tailwind-merge": "^2.6.0", - "vite": "^6.3.5", + "vite": "^7.1.1", "zod": "^3.24.2" }, "devDependencies": { @@ -33,6 +33,7 @@ "autoprefixer": "^10.4.20", "combinate": "^1.1.11", "postcss": "^8.5.1", + "srvx": "^0.8.6", "tailwindcss": "^3.4.17", "typescript": "^5.7.2", "vite-tsconfig-paths": "^5.1.4" diff --git a/e2e/react-start/server-routes/tests/fixture.ts b/e2e/react-start/server-routes/tests/fixture.ts deleted file mode 100644 index abb7b1d564..0000000000 --- a/e2e/react-start/server-routes/tests/fixture.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { test as base, expect } from '@playwright/test' - -export interface TestFixtureOptions { - whitelistErrors: Array -} -export const test = base.extend({ - whitelistErrors: [[], { option: true }], - page: async ({ page, whitelistErrors }, use) => { - const errorMessages: Array = [] - page.on('console', (m) => { - if (m.type() === 'error') { - const text = m.text() - for (const whitelistError of whitelistErrors) { - if ( - (typeof whitelistError === 'string' && - text.includes(whitelistError)) || - (whitelistError instanceof RegExp && whitelistError.test(text)) - ) { - return - } - } - errorMessages.push(text) - } - }) - await use(page) - expect(errorMessages).toEqual([]) - }, -}) diff --git a/e2e/react-start/server-routes/tests/server-routes.spec.ts b/e2e/react-start/server-routes/tests/server-routes.spec.ts index 098a40b2ef..33176a23fd 100644 --- a/e2e/react-start/server-routes/tests/server-routes.spec.ts +++ b/e2e/react-start/server-routes/tests/server-routes.spec.ts @@ -1,4 +1,5 @@ -import { expect, test } from '@playwright/test' +import { expect } from '@playwright/test' +import { test } from '@tanstack/router-e2e-utils' test('merge-server-fn-middleware-context', async ({ page }) => { await page.goto('/merge-server-fn-middleware-context') diff --git a/e2e/react-start/server-routes/vite.config.ts b/e2e/react-start/server-routes/vite.config.ts index 1df337cd40..dc57f144e4 100644 --- a/e2e/react-start/server-routes/vite.config.ts +++ b/e2e/react-start/server-routes/vite.config.ts @@ -1,6 +1,7 @@ import { defineConfig } from 'vite' import tsConfigPaths from 'vite-tsconfig-paths' import { tanstackStart } from '@tanstack/react-start/plugin/vite' +import viteReact from '@vitejs/plugin-react' export default defineConfig({ plugins: [ @@ -8,5 +9,6 @@ export default defineConfig({ projects: ['./tsconfig.json'], }), tanstackStart(), + viteReact(), ], }) diff --git a/e2e/react-start/spa-mode/package.json b/e2e/react-start/spa-mode/package.json index ec5aaa4d5d..ae48f46c88 100644 --- a/e2e/react-start/spa-mode/package.json +++ b/e2e/react-start/spa-mode/package.json @@ -7,7 +7,7 @@ "dev": "vite dev --port 3000", "dev:e2e": "vite dev", "build": "vite build && tsc --noEmit", - "start": "npx serve .output/public", + "start": "npx serve dist/client", "test:e2e": "rm -rf port*.txt; playwright test --project=chromium" }, "dependencies": { @@ -25,7 +25,7 @@ "postcss": "^8.5.1", "tailwindcss": "^3.4.17", "typescript": "^5.7.2", - "vite": "^6.3.5", + "vite": "^7.1.1", "vite-tsconfig-paths": "^5.1.4" } } diff --git a/e2e/react-start/spa-mode/tests/app.spec.ts b/e2e/react-start/spa-mode/tests/app.spec.ts index 8970ec333c..c18a0ff65d 100644 --- a/e2e/react-start/spa-mode/tests/app.spec.ts +++ b/e2e/react-start/spa-mode/tests/app.spec.ts @@ -1,5 +1,5 @@ import { expect } from '@playwright/test' -import { test } from './fixture' +import { test } from '@tanstack/router-e2e-utils' import type { Page } from '@playwright/test' async function runTest( diff --git a/e2e/react-start/spa-mode/tests/fixture.ts b/e2e/react-start/spa-mode/tests/fixture.ts deleted file mode 100644 index abb7b1d564..0000000000 --- a/e2e/react-start/spa-mode/tests/fixture.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { test as base, expect } from '@playwright/test' - -export interface TestFixtureOptions { - whitelistErrors: Array -} -export const test = base.extend({ - whitelistErrors: [[], { option: true }], - page: async ({ page, whitelistErrors }, use) => { - const errorMessages: Array = [] - page.on('console', (m) => { - if (m.type() === 'error') { - const text = m.text() - for (const whitelistError of whitelistErrors) { - if ( - (typeof whitelistError === 'string' && - text.includes(whitelistError)) || - (whitelistError instanceof RegExp && whitelistError.test(text)) - ) { - return - } - } - errorMessages.push(text) - } - }) - await use(page) - expect(errorMessages).toEqual([]) - }, -}) diff --git a/e2e/react-start/virtual-routes/package.json b/e2e/react-start/virtual-routes/package.json index 3347f1e995..b4f3b6b6ed 100644 --- a/e2e/react-start/virtual-routes/package.json +++ b/e2e/react-start/virtual-routes/package.json @@ -7,7 +7,7 @@ "dev": "vite dev --port 3000", "dev:e2e": "vite dev", "build": "vite build && tsc --noEmit", - "start": "node .output/server/index.mjs", + "start": "pnpx srvx --prod -s ../client dist/server/server.js", "test:e2e": "rm -rf port*.txt; playwright test --project=chromium" }, "dependencies": { @@ -19,7 +19,7 @@ "react-dom": "^19.0.0", "redaxios": "^0.5.1", "tailwind-merge": "^2.6.0", - "vite": "^6.3.5", + "vite": "^7.1.1", "zod": "^3.24.2" }, "devDependencies": { @@ -32,6 +32,7 @@ "autoprefixer": "^10.4.20", "combinate": "^1.1.11", "postcss": "^8.5.1", + "srvx": "^0.8.6", "tailwindcss": "^3.4.17", "typescript": "^5.7.2", "vite-tsconfig-paths": "^5.1.4" diff --git a/e2e/react-start/virtual-routes/vite.config.ts b/e2e/react-start/virtual-routes/vite.config.ts index 21ff4c2940..110811e198 100644 --- a/e2e/react-start/virtual-routes/vite.config.ts +++ b/e2e/react-start/virtual-routes/vite.config.ts @@ -11,7 +11,7 @@ export default defineConfig({ projects: ['./tsconfig.json'], }), tanstackStart({ - tsr: { + router: { virtualRouteConfig: './routes.ts', }, }), diff --git a/e2e/react-start/website/package.json b/e2e/react-start/website/package.json index 2990a23c08..5d54afc056 100644 --- a/e2e/react-start/website/package.json +++ b/e2e/react-start/website/package.json @@ -7,7 +7,7 @@ "dev": "vite dev --port 3000", "dev:e2e": "vite dev", "build": "vite build && tsc --noEmit", - "start": "node .output/server/index.mjs", + "start": "pnpx srvx --prod -s ../client dist/server/server.js", "test:e2e": "rm -rf port*.txt; playwright test --project=chromium" }, "dependencies": { @@ -29,9 +29,10 @@ "@vitejs/plugin-react": "^4.3.4", "autoprefixer": "^10.4.20", "postcss": "^8.5.1", + "srvx": "^0.8.6", "tailwindcss": "^3.4.17", "typescript": "^5.7.2", - "vite": "^6.3.5", + "vite": "^7.1.1", "vite-tsconfig-paths": "^5.1.4" } } diff --git a/e2e/react-start/website/vite.config.ts b/e2e/react-start/website/vite.config.ts index a1b3d840f5..c2c28ae93b 100644 --- a/e2e/react-start/website/vite.config.ts +++ b/e2e/react-start/website/vite.config.ts @@ -1,6 +1,7 @@ import { defineConfig } from 'vite' import tsConfigPaths from 'vite-tsconfig-paths' import { tanstackStart } from '@tanstack/react-start/plugin/vite' +import viteReact from '@vitejs/plugin-react' export default defineConfig({ server: { @@ -11,5 +12,6 @@ export default defineConfig({ projects: ['./tsconfig.json'], }), tanstackStart(), + viteReact(), ], }) diff --git a/e2e/solid-router/basic-file-based-code-splitting/package.json b/e2e/solid-router/basic-file-based-code-splitting/package.json index 6a929a45bc..05739aa9c5 100644 --- a/e2e/solid-router/basic-file-based-code-splitting/package.json +++ b/e2e/solid-router/basic-file-based-code-splitting/package.json @@ -25,7 +25,7 @@ "devDependencies": { "@playwright/test": "^1.50.1", "@tanstack/router-e2e-utils": "workspace:^", - "vite": "^6.3.5", - "vite-plugin-solid": "^2.11.2" + "vite": "^7.1.1", + "vite-plugin-solid": "^2.11.8" } } diff --git a/e2e/solid-router/basic-file-based/package.json b/e2e/solid-router/basic-file-based/package.json index 50b911f89a..f3a3019b46 100644 --- a/e2e/solid-router/basic-file-based/package.json +++ b/e2e/solid-router/basic-file-based/package.json @@ -25,8 +25,8 @@ "devDependencies": { "@playwright/test": "^1.50.1", "@tanstack/router-e2e-utils": "workspace:^", - "vite-plugin-solid": "^2.11.2", + "vite-plugin-solid": "^2.11.8", "combinate": "^1.1.11", - "vite": "^6.3.5" + "vite": "^7.1.1" } } diff --git a/e2e/solid-router/basic-file-based/src/routeTree.gen.ts b/e2e/solid-router/basic-file-based/src/routeTree.gen.ts index 08d8fb4978..f4b02f10a8 100644 --- a/e2e/solid-router/basic-file-based/src/routeTree.gen.ts +++ b/e2e/solid-router/basic-file-based/src/routeTree.gen.ts @@ -22,8 +22,10 @@ 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' import { Route as SearchParamsDefaultRouteImport } from './routes/search-params/default' import { Route as RedirectTargetRouteImport } from './routes/redirect/$target' import { Route as PostsPostIdRouteImport } from './routes/posts.$postId' @@ -32,7 +34,14 @@ 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 ParamsPsNonNestedRouteRouteImport } from './routes/params-ps/non-nested/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 +53,21 @@ 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 ParamsPsNonNestedFooRouteRouteImport } from './routes/params-ps/non-nested/$foo_/route' +import { Route as ParamsPsNamedFooRouteRouteImport } from './routes/params-ps/named/$foo/route' +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 ParamsPsNonNestedFooBarRouteImport } from './routes/params-ps/non-nested/$foo_/$bar' +import { Route as ParamsPsNamedFooBarRouteRouteImport } from './routes/params-ps/named/$foo/$bar.route' +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' +import { Route as ParamsPsNamedFooBarBazRouteImport } from './routes/params-ps/named/$foo/$bar.$baz' const groupRouteImport = createFileRoute('/(group)')() @@ -105,6 +129,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/', @@ -115,6 +144,11 @@ const PostsIndexRoute = PostsIndexRouteImport.update({ path: '/', getParentRoute: () => PostsRoute, } as any) +const ParamsPsIndexRoute = ParamsPsIndexRouteImport.update({ + id: '/params-ps/', + path: '/params-ps/', + getParentRoute: () => rootRouteImport, +} as any) const SearchParamsDefaultRoute = SearchParamsDefaultRouteImport.update({ id: '/default', path: '/default', @@ -156,11 +190,51 @@ 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 ParamsPsNonNestedRouteRoute = ParamsPsNonNestedRouteRouteImport.update({ + id: '/params-ps/non-nested', + path: '/params-ps/non-nested', + 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 +291,91 @@ const groupLayoutInsidelayoutRoute = groupLayoutInsidelayoutRouteImport.update({ path: '/insidelayout', getParentRoute: () => groupLayoutRoute, } as any) +const ParamsPsNonNestedFooRouteRoute = + ParamsPsNonNestedFooRouteRouteImport.update({ + id: '/$foo_', + path: '/$foo', + getParentRoute: () => ParamsPsNonNestedRouteRoute, + } as any) +const ParamsPsNamedFooRouteRoute = ParamsPsNamedFooRouteRouteImport.update({ + id: '/params-ps/named/$foo', + path: '/params-ps/named/$foo', + getParentRoute: () => rootRouteImport, +} 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 ParamsPsNonNestedFooBarRoute = ParamsPsNonNestedFooBarRouteImport.update({ + id: '/$bar', + path: '/$bar', + getParentRoute: () => ParamsPsNonNestedFooRouteRoute, +} as any) +const ParamsPsNamedFooBarRouteRoute = + ParamsPsNamedFooBarRouteRouteImport.update({ + id: '/$bar', + path: '/$bar', + getParentRoute: () => ParamsPsNamedFooRouteRoute, + } 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) +const ParamsPsNamedFooBarBazRoute = ParamsPsNamedFooBarBazRouteImport.update({ + id: '/$baz', + path: '/$baz', + getParentRoute: () => ParamsPsNamedFooBarRouteRoute, +} as any) export interface FileRoutesByFullPath { '/': typeof groupLayoutRouteWithChildren @@ -228,15 +387,22 @@ export interface FileRoutesByFullPath { '/notRemountDeps': typeof NotRemountDepsRoute '/posts': typeof PostsRouteWithChildren '/remountDeps': typeof RemountDepsRoute + '/params-ps/non-nested': typeof ParamsPsNonNestedRouteRouteWithChildren + '/relative/link': typeof RelativeLinkRouteRouteWithChildren + '/relative/useNavigate': typeof RelativeUseNavigateRouteRouteWithChildren '/onlyrouteinside': typeof anotherGroupOnlyrouteinsideRoute '/inside': typeof groupInsideRoute '/lazyinside': typeof groupLazyinsideRoute '/posts/$postId': typeof PostsPostIdRoute '/redirect/$target': typeof RedirectTargetRouteWithChildren '/search-params/default': typeof SearchParamsDefaultRoute + '/params-ps': typeof ParamsPsIndexRoute '/posts/': typeof PostsIndexRoute '/redirect': typeof RedirectIndexRoute + '/relative': typeof RelativeIndexRoute '/search-params/': typeof SearchParamsIndexRoute + '/params-ps/named/$foo': typeof ParamsPsNamedFooRouteRouteWithChildren + '/params-ps/non-nested/$foo': typeof ParamsPsNonNestedFooRouteRouteWithChildren '/insidelayout': typeof groupLayoutInsidelayoutRoute '/subfolder/inside': typeof groupSubfolderInsideRoute '/layout-a': typeof LayoutLayout2LayoutARoute @@ -248,7 +414,24 @@ 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 + '/params-ps/named/$foo/$bar': typeof ParamsPsNamedFooBarRouteRouteWithChildren + '/params-ps/non-nested/$foo/$bar': typeof ParamsPsNonNestedFooBarRoute + '/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 + '/params-ps/named/$foo/$bar/$baz': typeof ParamsPsNamedFooBarBazRoute + '/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,14 +441,21 @@ export interface FileRoutesByTo { '/editing-b': typeof EditingBRoute '/notRemountDeps': typeof NotRemountDepsRoute '/remountDeps': typeof RemountDepsRoute + '/params-ps/non-nested': typeof ParamsPsNonNestedRouteRouteWithChildren + '/relative/link': typeof RelativeLinkRouteRouteWithChildren + '/relative/useNavigate': typeof RelativeUseNavigateRouteRouteWithChildren '/onlyrouteinside': typeof anotherGroupOnlyrouteinsideRoute '/inside': typeof groupInsideRoute '/lazyinside': typeof groupLazyinsideRoute '/posts/$postId': typeof PostsPostIdRoute '/search-params/default': typeof SearchParamsDefaultRoute + '/params-ps': typeof ParamsPsIndexRoute '/posts': typeof PostsIndexRoute '/redirect': typeof RedirectIndexRoute + '/relative': typeof RelativeIndexRoute '/search-params': typeof SearchParamsIndexRoute + '/params-ps/named/$foo': typeof ParamsPsNamedFooRouteRouteWithChildren + '/params-ps/non-nested/$foo': typeof ParamsPsNonNestedFooRouteRouteWithChildren '/insidelayout': typeof groupLayoutInsidelayoutRoute '/subfolder/inside': typeof groupSubfolderInsideRoute '/layout-a': typeof LayoutLayout2LayoutARoute @@ -277,7 +467,24 @@ 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 + '/params-ps/named/$foo/$bar': typeof ParamsPsNamedFooBarRouteRouteWithChildren + '/params-ps/non-nested/$foo/$bar': typeof ParamsPsNonNestedFooBarRoute + '/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 + '/params-ps/named/$foo/$bar/$baz': typeof ParamsPsNamedFooBarBazRoute + '/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 +498,9 @@ export interface FileRoutesById { '/notRemountDeps': typeof NotRemountDepsRoute '/posts': typeof PostsRouteWithChildren '/remountDeps': typeof RemountDepsRoute + '/params-ps/non-nested': typeof ParamsPsNonNestedRouteRouteWithChildren + '/relative/link': typeof RelativeLinkRouteRouteWithChildren + '/relative/useNavigate': typeof RelativeUseNavigateRouteRouteWithChildren '/(another-group)/onlyrouteinside': typeof anotherGroupOnlyrouteinsideRoute '/(group)': typeof groupRouteWithChildren '/(group)/_layout': typeof groupLayoutRouteWithChildren @@ -300,9 +510,13 @@ export interface FileRoutesById { '/posts/$postId': typeof PostsPostIdRoute '/redirect/$target': typeof RedirectTargetRouteWithChildren '/search-params/default': typeof SearchParamsDefaultRoute + '/params-ps/': typeof ParamsPsIndexRoute '/posts/': typeof PostsIndexRoute '/redirect/': typeof RedirectIndexRoute + '/relative/': typeof RelativeIndexRoute '/search-params/': typeof SearchParamsIndexRoute + '/params-ps/named/$foo': typeof ParamsPsNamedFooRouteRouteWithChildren + '/params-ps/non-nested/$foo_': typeof ParamsPsNonNestedFooRouteRouteWithChildren '/(group)/_layout/insidelayout': typeof groupLayoutInsidelayoutRoute '/(group)/subfolder/inside': typeof groupSubfolderInsideRoute '/_layout/_layout-2/layout-a': typeof LayoutLayout2LayoutARoute @@ -314,7 +528,24 @@ 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 + '/params-ps/named/$foo/$bar': typeof ParamsPsNamedFooBarRouteRouteWithChildren + '/params-ps/non-nested/$foo_/$bar': typeof ParamsPsNonNestedFooBarRoute + '/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 + '/params-ps/named/$foo/$bar/$baz': typeof ParamsPsNamedFooBarBazRoute + '/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,15 +559,22 @@ export interface FileRouteTypes { | '/notRemountDeps' | '/posts' | '/remountDeps' + | '/params-ps/non-nested' + | '/relative/link' + | '/relative/useNavigate' | '/onlyrouteinside' | '/inside' | '/lazyinside' | '/posts/$postId' | '/redirect/$target' | '/search-params/default' + | '/params-ps' | '/posts/' | '/redirect' + | '/relative' | '/search-params/' + | '/params-ps/named/$foo' + | '/params-ps/non-nested/$foo' | '/insidelayout' | '/subfolder/inside' | '/layout-a' @@ -348,7 +586,24 @@ 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/' + | '/params-ps/named/$foo/$bar' + | '/params-ps/non-nested/$foo/$bar' + | '/relative/link/nested' + | '/relative/link/path' + | '/relative/link/with-search' + | '/relative/useNavigate/nested' + | '/relative/useNavigate/path' + | '/relative/useNavigate/with-search' + | '/params-ps/named/$foo/$bar/$baz' + | '/relative/link/nested/deep' + | '/relative/link/path/$path' + | '/relative/useNavigate/nested/deep' + | '/relative/useNavigate/path/$path' fileRoutesByTo: FileRoutesByTo to: | '/' @@ -358,14 +613,21 @@ export interface FileRouteTypes { | '/editing-b' | '/notRemountDeps' | '/remountDeps' + | '/params-ps/non-nested' + | '/relative/link' + | '/relative/useNavigate' | '/onlyrouteinside' | '/inside' | '/lazyinside' | '/posts/$postId' | '/search-params/default' + | '/params-ps' | '/posts' | '/redirect' + | '/relative' | '/search-params' + | '/params-ps/named/$foo' + | '/params-ps/non-nested/$foo' | '/insidelayout' | '/subfolder/inside' | '/layout-a' @@ -377,7 +639,24 @@ 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' + | '/params-ps/named/$foo/$bar' + | '/params-ps/non-nested/$foo/$bar' + | '/relative/link/nested' + | '/relative/link/path' + | '/relative/link/with-search' + | '/relative/useNavigate/nested' + | '/relative/useNavigate/path' + | '/relative/useNavigate/with-search' + | '/params-ps/named/$foo/$bar/$baz' + | '/relative/link/nested/deep' + | '/relative/link/path/$path' + | '/relative/useNavigate/nested/deep' + | '/relative/useNavigate/path/$path' id: | '__root__' | '/' @@ -390,6 +669,9 @@ export interface FileRouteTypes { | '/notRemountDeps' | '/posts' | '/remountDeps' + | '/params-ps/non-nested' + | '/relative/link' + | '/relative/useNavigate' | '/(another-group)/onlyrouteinside' | '/(group)' | '/(group)/_layout' @@ -399,9 +681,13 @@ export interface FileRouteTypes { | '/posts/$postId' | '/redirect/$target' | '/search-params/default' + | '/params-ps/' | '/posts/' | '/redirect/' + | '/relative/' | '/search-params/' + | '/params-ps/named/$foo' + | '/params-ps/non-nested/$foo_' | '/(group)/_layout/insidelayout' | '/(group)/subfolder/inside' | '/_layout/_layout-2/layout-a' @@ -413,7 +699,24 @@ 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/' + | '/params-ps/named/$foo/$bar' + | '/params-ps/non-nested/$foo_/$bar' + | '/relative/link/nested/' + | '/relative/link/path/' + | '/relative/link/with-search/' + | '/relative/useNavigate/nested/' + | '/relative/useNavigate/path/' + | '/relative/useNavigate/with-search/' + | '/params-ps/named/$foo/$bar/$baz' + | '/relative/link/nested/deep/' + | '/relative/link/path/$path/' + | '/relative/useNavigate/nested/deep/' + | '/relative/useNavigate/path/$path/' fileRoutesById: FileRoutesById } export interface RootRouteChildren { @@ -427,10 +730,16 @@ export interface RootRouteChildren { NotRemountDepsRoute: typeof NotRemountDepsRoute PostsRoute: typeof PostsRouteWithChildren RemountDepsRoute: typeof RemountDepsRoute + ParamsPsNonNestedRouteRoute: typeof ParamsPsNonNestedRouteRouteWithChildren + RelativeLinkRouteRoute: typeof RelativeLinkRouteRouteWithChildren + RelativeUseNavigateRouteRoute: typeof RelativeUseNavigateRouteRouteWithChildren anotherGroupOnlyrouteinsideRoute: typeof anotherGroupOnlyrouteinsideRoute groupRoute: typeof groupRouteWithChildren RedirectTargetRoute: typeof RedirectTargetRouteWithChildren + ParamsPsIndexRoute: typeof ParamsPsIndexRoute RedirectIndexRoute: typeof RedirectIndexRoute + RelativeIndexRoute: typeof RelativeIndexRoute + ParamsPsNamedFooRouteRoute: typeof ParamsPsNamedFooRouteRouteWithChildren ParamsSingleValueRoute: typeof ParamsSingleValueRoute PostsPostIdEditRoute: typeof PostsPostIdEditRoute RedirectPreloadFirstRoute: typeof RedirectPreloadFirstRoute @@ -524,6 +833,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' @@ -538,6 +854,13 @@ declare module '@tanstack/solid-router' { preLoaderRoute: typeof PostsIndexRouteImport parentRoute: typeof PostsRoute } + '/params-ps/': { + id: '/params-ps/' + path: '/params-ps' + fullPath: '/params-ps' + preLoaderRoute: typeof ParamsPsIndexRouteImport + parentRoute: typeof rootRouteImport + } '/search-params/default': { id: '/search-params/default' path: '/default' @@ -594,6 +917,27 @@ 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 + } + '/params-ps/non-nested': { + id: '/params-ps/non-nested' + path: '/params-ps/non-nested' + fullPath: '/params-ps/non-nested' + preLoaderRoute: typeof ParamsPsNonNestedRouteRouteImport + parentRoute: typeof rootRouteImport + } '/redirect/$target/': { id: '/redirect/$target/' path: '/' @@ -601,6 +945,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 +1050,111 @@ declare module '@tanstack/solid-router' { preLoaderRoute: typeof groupLayoutInsidelayoutRouteImport parentRoute: typeof groupLayoutRoute } + '/params-ps/non-nested/$foo_': { + id: '/params-ps/non-nested/$foo_' + path: '/$foo' + fullPath: '/params-ps/non-nested/$foo' + preLoaderRoute: typeof ParamsPsNonNestedFooRouteRouteImport + parentRoute: typeof ParamsPsNonNestedRouteRoute + } + '/params-ps/named/$foo': { + id: '/params-ps/named/$foo' + path: '/params-ps/named/$foo' + fullPath: '/params-ps/named/$foo' + preLoaderRoute: typeof ParamsPsNamedFooRouteRouteImport + parentRoute: typeof rootRouteImport + } + '/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 + } + '/params-ps/non-nested/$foo_/$bar': { + id: '/params-ps/non-nested/$foo_/$bar' + path: '/$bar' + fullPath: '/params-ps/non-nested/$foo/$bar' + preLoaderRoute: typeof ParamsPsNonNestedFooBarRouteImport + parentRoute: typeof ParamsPsNonNestedFooRouteRoute + } + '/params-ps/named/$foo/$bar': { + id: '/params-ps/named/$foo/$bar' + path: '/$bar' + fullPath: '/params-ps/named/$foo/$bar' + preLoaderRoute: typeof ParamsPsNamedFooBarRouteRouteImport + parentRoute: typeof ParamsPsNamedFooRouteRoute + } + '/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 + } + '/params-ps/named/$foo/$bar/$baz': { + id: '/params-ps/named/$foo/$bar/$baz' + path: '/$baz' + fullPath: '/params-ps/named/$foo/$bar/$baz' + preLoaderRoute: typeof ParamsPsNamedFooBarBazRouteImport + parentRoute: typeof ParamsPsNamedFooBarRouteRoute + } } } @@ -731,6 +1208,88 @@ const PostsRouteChildren: PostsRouteChildren = { const PostsRouteWithChildren = PostsRoute._addFileChildren(PostsRouteChildren) +interface ParamsPsNonNestedFooRouteRouteChildren { + ParamsPsNonNestedFooBarRoute: typeof ParamsPsNonNestedFooBarRoute +} + +const ParamsPsNonNestedFooRouteRouteChildren: ParamsPsNonNestedFooRouteRouteChildren = + { + ParamsPsNonNestedFooBarRoute: ParamsPsNonNestedFooBarRoute, + } + +const ParamsPsNonNestedFooRouteRouteWithChildren = + ParamsPsNonNestedFooRouteRoute._addFileChildren( + ParamsPsNonNestedFooRouteRouteChildren, + ) + +interface ParamsPsNonNestedRouteRouteChildren { + ParamsPsNonNestedFooRouteRoute: typeof ParamsPsNonNestedFooRouteRouteWithChildren +} + +const ParamsPsNonNestedRouteRouteChildren: ParamsPsNonNestedRouteRouteChildren = + { + ParamsPsNonNestedFooRouteRoute: ParamsPsNonNestedFooRouteRouteWithChildren, + } + +const ParamsPsNonNestedRouteRouteWithChildren = + ParamsPsNonNestedRouteRoute._addFileChildren( + ParamsPsNonNestedRouteRouteChildren, + ) + +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 } @@ -775,6 +1334,33 @@ const RedirectTargetRouteWithChildren = RedirectTargetRoute._addFileChildren( RedirectTargetRouteChildren, ) +interface ParamsPsNamedFooBarRouteRouteChildren { + ParamsPsNamedFooBarBazRoute: typeof ParamsPsNamedFooBarBazRoute +} + +const ParamsPsNamedFooBarRouteRouteChildren: ParamsPsNamedFooBarRouteRouteChildren = + { + ParamsPsNamedFooBarBazRoute: ParamsPsNamedFooBarBazRoute, + } + +const ParamsPsNamedFooBarRouteRouteWithChildren = + ParamsPsNamedFooBarRouteRoute._addFileChildren( + ParamsPsNamedFooBarRouteRouteChildren, + ) + +interface ParamsPsNamedFooRouteRouteChildren { + ParamsPsNamedFooBarRouteRoute: typeof ParamsPsNamedFooBarRouteRouteWithChildren +} + +const ParamsPsNamedFooRouteRouteChildren: ParamsPsNamedFooRouteRouteChildren = { + ParamsPsNamedFooBarRouteRoute: ParamsPsNamedFooBarRouteRouteWithChildren, +} + +const ParamsPsNamedFooRouteRouteWithChildren = + ParamsPsNamedFooRouteRoute._addFileChildren( + ParamsPsNamedFooRouteRouteChildren, + ) + const rootRouteChildren: RootRouteChildren = { IndexRoute: IndexRoute, SearchParamsRouteRoute: SearchParamsRouteRouteWithChildren, @@ -786,10 +1372,16 @@ const rootRouteChildren: RootRouteChildren = { NotRemountDepsRoute: NotRemountDepsRoute, PostsRoute: PostsRouteWithChildren, RemountDepsRoute: RemountDepsRoute, + ParamsPsNonNestedRouteRoute: ParamsPsNonNestedRouteRouteWithChildren, + RelativeLinkRouteRoute: RelativeLinkRouteRouteWithChildren, + RelativeUseNavigateRouteRoute: RelativeUseNavigateRouteRouteWithChildren, anotherGroupOnlyrouteinsideRoute: anotherGroupOnlyrouteinsideRoute, groupRoute: groupRouteWithChildren, RedirectTargetRoute: RedirectTargetRouteWithChildren, + ParamsPsIndexRoute: ParamsPsIndexRoute, RedirectIndexRoute: RedirectIndexRoute, + RelativeIndexRoute: RelativeIndexRoute, + ParamsPsNamedFooRouteRoute: ParamsPsNamedFooRouteRouteWithChildren, 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 + {' '} +

    Named path params

    +
      +
    • + + /params-ps/named/$foo + +
    • +
    +
    +

    Non-nested path params

    +
      +
    • + + Non-nested + +
    • +
    + + ) +} diff --git a/e2e/solid-router/basic-file-based/src/routes/params-ps/named/$foo/$bar.$baz.tsx b/e2e/solid-router/basic-file-based/src/routes/params-ps/named/$foo/$bar.$baz.tsx new file mode 100644 index 0000000000..0b6488f389 --- /dev/null +++ b/e2e/solid-router/basic-file-based/src/routes/params-ps/named/$foo/$bar.$baz.tsx @@ -0,0 +1,17 @@ +import { createFileRoute } from '@tanstack/solid-router' + +export const Route = createFileRoute('/params-ps/named/$foo/$bar/$baz')({ + component: RouteComponent, +}) + +function RouteComponent() { + const params = Route.useParams() + return ( +
    + Hello "/params-ps/named/$foo/$bar/$baz"! +
    + baz: {params().baz} +
    +
    + ) +} diff --git a/e2e/solid-router/basic-file-based/src/routes/params-ps/named/$foo/$bar.route.tsx b/e2e/solid-router/basic-file-based/src/routes/params-ps/named/$foo/$bar.route.tsx new file mode 100644 index 0000000000..4387aed56d --- /dev/null +++ b/e2e/solid-router/basic-file-based/src/routes/params-ps/named/$foo/$bar.route.tsx @@ -0,0 +1,64 @@ +import { + Link, + Outlet, + createFileRoute, + useParams, +} from '@tanstack/solid-router' +import { createEffect, createSignal } from 'solid-js' + +export const Route = createFileRoute('/params-ps/named/$foo/$bar')({ + component: RouteComponent, +}) + +function RouteComponent() { + const [renderBarCount, setBarRenderCount] = createSignal(0) + const [renderBazCount, setBazRenderCount] = createSignal(0) + + const params = useParams({ + strict: false, + }) + + createEffect(() => { + params().bar + setBarRenderCount((prev) => prev + 1) + }) + + createEffect(() => { + params().baz + setBazRenderCount((prev) => prev + 1) + }) + + return ( +
    + Hello "/params-ps/named/$foo/$bar"! +
    + Bar Render Count:{' '} + {renderBarCount()} +
    +
    + Bar: {params().bar} +
    +
    + Baz in Bar Render Count:{' '} + + {renderBazCount()} + +
    +
    + Baz in Bar:{' '} + + {params().baz ?? 'no param'} + +
    + + To Baz + + +
    + ) +} diff --git a/e2e/solid-router/basic-file-based/src/routes/params-ps/named/$foo/route.tsx b/e2e/solid-router/basic-file-based/src/routes/params-ps/named/$foo/route.tsx new file mode 100644 index 0000000000..58a78e3822 --- /dev/null +++ b/e2e/solid-router/basic-file-based/src/routes/params-ps/named/$foo/route.tsx @@ -0,0 +1,47 @@ +import { Link, Outlet, createFileRoute } from '@tanstack/solid-router' +import { createEffect, createSignal } from 'solid-js' + +export const Route = createFileRoute('/params-ps/named/$foo')({ + component: RouteComponent, +}) + +function RouteComponent() { + const [renderCount, setRenderCount] = createSignal(0) + const params = Route.useParams() + + createEffect(() => { + params().foo + + setRenderCount((prev) => prev + 1) + }) + + return ( +
    +

    ParamsNamedFoo

    +
    + RenderCount: {renderCount()} +
    +
    {JSON.stringify(params())}
    + + Index + + + Bar1 + + + Bar2 + + +
    + ) +} diff --git a/e2e/solid-router/basic-file-based/src/routes/params-ps/non-nested/$foo_/$bar.tsx b/e2e/solid-router/basic-file-based/src/routes/params-ps/non-nested/$foo_/$bar.tsx new file mode 100644 index 0000000000..837aa937c2 --- /dev/null +++ b/e2e/solid-router/basic-file-based/src/routes/params-ps/non-nested/$foo_/$bar.tsx @@ -0,0 +1,19 @@ +import { createFileRoute, useParams } from '@tanstack/solid-router' + +export const Route = createFileRoute('/params-ps/non-nested/$foo_/$bar')({ + component: RouteComponent, +}) + +function RouteComponent() { + const fooParams = useParams({ from: '/params-ps/non-nested/$foo_' }) + const routeParams = Route.useParams() + + return ( +
    +
    {JSON.stringify(fooParams())}
    +
    + {JSON.stringify(routeParams())} +
    +
    + ) +} diff --git a/e2e/solid-router/basic-file-based/src/routes/params-ps/non-nested/$foo_/route.tsx b/e2e/solid-router/basic-file-based/src/routes/params-ps/non-nested/$foo_/route.tsx new file mode 100644 index 0000000000..b0611e8627 --- /dev/null +++ b/e2e/solid-router/basic-file-based/src/routes/params-ps/non-nested/$foo_/route.tsx @@ -0,0 +1,3 @@ +import { createFileRoute } from '@tanstack/solid-router' + +export const Route = createFileRoute('/params-ps/non-nested/$foo_')() diff --git a/e2e/solid-router/basic-file-based/src/routes/params-ps/non-nested/route.tsx b/e2e/solid-router/basic-file-based/src/routes/params-ps/non-nested/route.tsx new file mode 100644 index 0000000000..496542c667 --- /dev/null +++ b/e2e/solid-router/basic-file-based/src/routes/params-ps/non-nested/route.tsx @@ -0,0 +1,26 @@ +import { Link, Outlet, createFileRoute } from '@tanstack/solid-router' + +export const Route = createFileRoute('/params-ps/non-nested')({ + component: RouteComponent, +}) + +function RouteComponent() { + return ( +
    +

    Non-nested path params

    +
      +
    • + + /params-ps/non-nested/$foo/$bar + +
    • +
    + +
    + ) +} diff --git a/e2e/solid-router/basic-file-based/src/routes/relative/index.tsx b/e2e/solid-router/basic-file-based/src/routes/relative/index.tsx new file mode 100644 index 0000000000..4ccd38e430 --- /dev/null +++ b/e2e/solid-router/basic-file-based/src/routes/relative/index.tsx @@ -0,0 +1,22 @@ +import { Link, Outlet, createFileRoute } from '@tanstack/solid-router' + +export const Route = createFileRoute('/relative/')({ + component: RouteComponent, +}) + +function RouteComponent() { + return ( +
    +
    + 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}"! +
    +
    + +
    +
    + ) +} 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 +
    +
    + + + + + + + + + +
    +
    + +
    +
    + ) +} 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}! +
    +
    + + + ) +} diff --git a/e2e/solid-router/basic-file-based/tests/params.spec.ts b/e2e/solid-router/basic-file-based/tests/params.spec.ts index e95bc56c59..3a63c93417 100644 --- a/e2e/solid-router/basic-file-based/tests/params.spec.ts +++ b/e2e/solid-router/basic-file-based/tests/params.spec.ts @@ -54,3 +54,109 @@ test.describe('ensure single params have been parsed correctly whilst being stab }) } }) + +test('ensure only applicable params are returned and updated with multiple params', async ({ + page, +}) => { + await page.goto('/params-ps/named/foo') + await page.waitForLoadState('networkidle') + + const pagePathname = new URL(page.url()).pathname + expect(pagePathname).toBe('/params-ps/named/foo') + + const fooRenderCount = page.getByTestId('foo-render-count') + const fooIndexLink = page.getByTestId('params-foo-links-index') + const fooBar1Link = page.getByTestId('params-foo-links-bar1') + const fooBar2Link = page.getByTestId('params-foo-links-bar2') + const fooBarBazLink = page.getByTestId('params-foo-bar-links-baz') + const fooValue = page.getByTestId('params-output') + const fooBarValue = page.getByTestId('foo-bar-value') + const fooBazInBarValue = page.getByTestId('foo-baz-in-bar-value') + const fooBarRenderCount = page.getByTestId('foo-bar-render-count') + const fooBazInBarRenderCount = page.getByTestId('foo-baz-in-bar-render-count') + const fooBarBazValue = page.getByTestId('foo-bar-baz-value') + + await expect(fooRenderCount).toBeInViewport() + await expect(fooValue).toBeInViewport() + await expect(fooIndexLink).toBeInViewport() + await expect(fooBar1Link).toBeInViewport() + await expect(fooBar2Link).toBeInViewport() + await expect(fooRenderCount).toHaveText('1') + await expect(fooValue).toHaveText(JSON.stringify({ foo: 'foo' })) + + await fooBar1Link.click() + await page.waitForLoadState('networkidle') + await expect(fooValue).toBeInViewport() + await expect(fooRenderCount).toBeInViewport() + await expect(fooBarRenderCount).toBeInViewport() + await expect(fooBarValue).toBeInViewport() + await expect(fooBazInBarValue).toBeInViewport() + await expect(fooBarBazLink).toBeInViewport() + await expect(fooValue).toHaveText(JSON.stringify({ foo: 'foo' })) + await expect(fooRenderCount).toHaveText('1') + await expect(fooBarRenderCount).toHaveText('1') + await expect(fooBarValue).toHaveText('1') + await expect(fooBazInBarValue).toHaveText('no param') + await expect(fooBazInBarRenderCount).toHaveText('1') + + await fooBarBazLink.click() + await page.waitForLoadState('networkidle') + await expect(fooValue).toBeInViewport() + await expect(fooRenderCount).toBeInViewport() + await expect(fooBarRenderCount).toBeInViewport() + await expect(fooBarValue).toBeInViewport() + await expect(fooBazInBarValue).toBeInViewport() + await expect(fooValue).toHaveText(JSON.stringify({ foo: 'foo' })) + await expect(fooRenderCount).toHaveText('1') + await expect(fooBarRenderCount).toHaveText('1') + await expect(fooBarValue).toHaveText('1') + await expect(fooBazInBarValue).toHaveText('1_10') + await expect(fooBarBazValue).toHaveText('1_10') + await expect(fooBazInBarRenderCount).toHaveText('2') + + await fooBar2Link.click() + await expect(fooValue).toBeInViewport() + await expect(fooRenderCount).toBeInViewport() + await expect(fooBarValue).toBeInViewport() + await expect(fooValue).toHaveText(JSON.stringify({ foo: 'foo' })) + await expect(fooRenderCount).toHaveText('1') + await expect(fooBarValue).toHaveText('2') + + await fooIndexLink.click() + await expect(fooValue).toBeInViewport() + await expect(fooRenderCount).toBeInViewport() + await expect(fooBarValue).not.toBeInViewport() + await expect(fooValue).toHaveText(JSON.stringify({ foo: 'foo' })) + await expect(fooRenderCount).toHaveText('1') +}) + +test.describe('params operations + non-nested routes', () => { + test.beforeEach(async ({ page }) => { + await page.goto('/params-ps/non-nested') + }) + + test('useParams must resolve non-nested path params', async ({ page }) => { + await page.waitForURL('/params-ps/non-nested') + + const fooBarLink = page.getByTestId('l-to-non-nested-foo-bar') + + await expect(fooBarLink).toHaveAttribute( + 'href', + '/params-ps/non-nested/foo/bar', + ) + await fooBarLink.click() + await page.waitForLoadState('networkidle') + const pagePathname = new URL(page.url()).pathname + expect(pagePathname).toBe('/params-ps/non-nested/foo/bar') + + const fooParamsValue = page.getByTestId('foo-params-value') + const fooParamsText = await fooParamsValue.innerText() + const fooParamsObj = JSON.parse(fooParamsText) + expect(fooParamsObj).toEqual({ foo: 'foo' }) + + const paramsValue = page.getByTestId('foo-bar-params-value') + const paramsText = await paramsValue.innerText() + const paramsObj = JSON.parse(paramsText) + expect(paramsObj).toEqual({ foo: 'foo', bar: 'bar' }) + }) +}) 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-named-export-config-file-based/package.json b/e2e/solid-router/basic-virtual-named-export-config-file-based/package.json index 212cb73be7..6f57ade84c 100644 --- a/e2e/solid-router/basic-virtual-named-export-config-file-based/package.json +++ b/e2e/solid-router/basic-virtual-named-export-config-file-based/package.json @@ -25,7 +25,7 @@ "devDependencies": { "@playwright/test": "^1.50.1", "@tanstack/router-e2e-utils": "workspace:^", - "vite-plugin-solid": "^2.11.2", - "vite": "^6.3.5" + "vite-plugin-solid": "^2.11.8", + "vite": "^7.1.1" } } diff --git a/e2e/solid-router/basic/package.json b/e2e/solid-router/basic/package.json index 9634148185..930f065ce8 100644 --- a/e2e/solid-router/basic/package.json +++ b/e2e/solid-router/basic/package.json @@ -22,7 +22,7 @@ "devDependencies": { "@playwright/test": "^1.50.1", "@tanstack/router-e2e-utils": "workspace:^", - "vite-plugin-solid": "^2.11.2", - "vite": "^6.3.5" + "vite-plugin-solid": "^2.11.8", + "vite": "^7.1.1" } } diff --git a/e2e/solid-router/scroll-restoration-sandbox-vite/package.json b/e2e/solid-router/scroll-restoration-sandbox-vite/package.json index 8d41ebe795..c39283cc58 100644 --- a/e2e/solid-router/scroll-restoration-sandbox-vite/package.json +++ b/e2e/solid-router/scroll-restoration-sandbox-vite/package.json @@ -28,7 +28,7 @@ "devDependencies": { "@playwright/test": "^1.50.1", "@tanstack/router-e2e-utils": "workspace:^", - "vite-plugin-solid": "^2.11.2", - "vite": "^6.3.5" + "vite-plugin-solid": "^2.11.8", + "vite": "^7.1.1" } } diff --git a/e2e/solid-start/basic-tsr-config/package.json b/e2e/solid-start/basic-tsr-config/package.json index 97d12fa5ba..e94beef5ee 100644 --- a/e2e/solid-start/basic-tsr-config/package.json +++ b/e2e/solid-start/basic-tsr-config/package.json @@ -7,7 +7,7 @@ "dev": "vite dev --port 3000", "dev:e2e": "vite dev", "build": "rimraf ./count.txt && vite build && tsc --noEmit", - "start": "node .output/server/index.mjs", + "start": "pnpx srvx --prod -s ../client dist/server/server.js", "test:e2e": "rm -rf port*.txt; playwright test --project=chromium" }, "dependencies": { @@ -15,12 +15,14 @@ "@tanstack/solid-router-devtools": "workspace:^", "@tanstack/solid-start": "workspace:^", "solid-js": "^1.9.5", - "vite": "6.3.5" + "vite": "^7.1.1" }, "devDependencies": { "@tanstack/router-e2e-utils": "workspace:^", "@types/node": "^22.10.2", + "srvx": "^0.8.6", "typescript": "^5.7.2", + "vite-plugin-solid": "^2.11.8", "vite-tsconfig-paths": "^5.1.4" } } diff --git a/e2e/solid-start/basic-tsr-config/tests/app.spec.ts b/e2e/solid-start/basic-tsr-config/tests/app.spec.ts index e3488df952..782007684a 100644 --- a/e2e/solid-start/basic-tsr-config/tests/app.spec.ts +++ b/e2e/solid-start/basic-tsr-config/tests/app.spec.ts @@ -3,6 +3,7 @@ import { expect, test } from '@playwright/test' test('opening the app', async ({ page }) => { await page.goto('/') + await page.waitForLoadState('networkidle') await expect(page.getByTestId('add-button')).toContainText('Add 1 to 0?') await page.getByTestId('add-button').click() await page.waitForLoadState('networkidle') diff --git a/e2e/solid-start/basic-tsr-config/vite.config.ts b/e2e/solid-start/basic-tsr-config/vite.config.ts index 347962b83d..fa5673a503 100644 --- a/e2e/solid-start/basic-tsr-config/vite.config.ts +++ b/e2e/solid-start/basic-tsr-config/vite.config.ts @@ -1,6 +1,7 @@ import { defineConfig } from 'vite' import tsConfigPaths from 'vite-tsconfig-paths' import { tanstackStart } from '@tanstack/solid-start/plugin/vite' +import viteSolid from 'vite-plugin-solid' export default defineConfig({ server: { @@ -11,9 +12,8 @@ export default defineConfig({ projects: ['./tsconfig.json'], }), tanstackStart({ - tsr: { - srcDirectory: './src/app', - }, + srcDirectory: './src/app', }), + viteSolid({ ssr: true }), ], }) diff --git a/e2e/solid-start/basic/package.json b/e2e/solid-start/basic/package.json index c7b631c1d6..d3515f9eaf 100644 --- a/e2e/solid-start/basic/package.json +++ b/e2e/solid-start/basic/package.json @@ -7,7 +7,7 @@ "dev": "vite dev --port 3000", "dev:e2e": "vite dev", "build": "vite build && tsc --noEmit", - "start": "node .output/server/index.mjs", + "start": "pnpx srvx --prod -s ../client dist/server/server.js", "test:e2e": "rm -rf port*.txt; playwright test --project=chromium" }, "dependencies": { @@ -17,7 +17,7 @@ "redaxios": "^0.5.1", "solid-js": "^1.9.5", "tailwind-merge": "^2.6.0", - "vite": "6.3.5", + "vite": "^7.1.1", "zod": "^3.24.2" }, "devDependencies": { @@ -27,9 +27,10 @@ "autoprefixer": "^10.4.20", "combinate": "^1.1.11", "postcss": "^8.5.1", + "srvx": "^0.8.6", "tailwindcss": "^3.4.17", "typescript": "^5.7.2", - "vite-plugin-solid": "^2.11.2", + "vite-plugin-solid": "^2.11.8", "vite-tsconfig-paths": "^5.1.4" } } diff --git a/e2e/solid-start/basic/src/server.ts b/e2e/solid-start/basic/src/server.ts index f9fbb3a2d5..dc9f547478 100644 --- a/e2e/solid-start/basic/src/server.ts +++ b/e2e/solid-start/basic/src/server.ts @@ -8,6 +8,10 @@ import { createRouter } from './router' console.log("[server-entry]: using custom server entry in 'src/server.ts'") -export default createStartHandler({ +const fetch = createStartHandler({ createRouter, })(defaultStreamHandler) + +export default { + fetch, +} diff --git a/e2e/solid-start/basic/tests/fixture.ts b/e2e/solid-start/basic/tests/fixture.ts deleted file mode 100644 index abb7b1d564..0000000000 --- a/e2e/solid-start/basic/tests/fixture.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { test as base, expect } from '@playwright/test' - -export interface TestFixtureOptions { - whitelistErrors: Array -} -export const test = base.extend({ - whitelistErrors: [[], { option: true }], - page: async ({ page, whitelistErrors }, use) => { - const errorMessages: Array = [] - page.on('console', (m) => { - if (m.type() === 'error') { - const text = m.text() - for (const whitelistError of whitelistErrors) { - if ( - (typeof whitelistError === 'string' && - text.includes(whitelistError)) || - (whitelistError instanceof RegExp && whitelistError.test(text)) - ) { - return - } - } - errorMessages.push(text) - } - }) - await use(page) - expect(errorMessages).toEqual([]) - }, -}) diff --git a/e2e/solid-start/basic/tests/navigation.spec.ts b/e2e/solid-start/basic/tests/navigation.spec.ts index 5d21f2adbe..b73d4ddf09 100644 --- a/e2e/solid-start/basic/tests/navigation.spec.ts +++ b/e2e/solid-start/basic/tests/navigation.spec.ts @@ -1,5 +1,11 @@ -import { expect, test } from '@playwright/test' +import { expect } from '@playwright/test' +import { test } from '@tanstack/router-e2e-utils' +test.use({ + whitelistErrors: [ + /Failed to load resource: the server responded with a status of 404/, + ], +}) test('Navigating to post', async ({ page }) => { await page.goto('/') diff --git a/e2e/solid-start/basic/tests/not-found.spec.ts b/e2e/solid-start/basic/tests/not-found.spec.ts index 0d83ab5280..ab1c94eee9 100644 --- a/e2e/solid-start/basic/tests/not-found.spec.ts +++ b/e2e/solid-start/basic/tests/not-found.spec.ts @@ -1,6 +1,6 @@ import { expect } from '@playwright/test' import combinateImport from 'combinate' -import { test } from './fixture' +import { test } from '@tanstack/router-e2e-utils' // somehow playwright does not correctly import default exports const combinate = (combinateImport as any).default as typeof combinateImport diff --git a/e2e/solid-start/basic/tests/redirect.spec.ts b/e2e/solid-start/basic/tests/redirect.spec.ts index 87e93a42e6..78c57d6a00 100644 --- a/e2e/solid-start/basic/tests/redirect.spec.ts +++ b/e2e/solid-start/basic/tests/redirect.spec.ts @@ -4,9 +4,9 @@ import combinateImport from 'combinate' import { getDummyServerPort, getTestServerPort, + test, } from '@tanstack/router-e2e-utils' import packageJson from '../package.json' with { type: 'json' } -import { test } from './fixture' // somehow playwright does not correctly import default exports const combinate = (combinateImport as any).default as typeof combinateImport @@ -184,6 +184,8 @@ test.describe('redirects', () => { await page.goto(`/redirect/${target}/serverFn/via-useServerFn?${q}`) + await page.waitForLoadState('networkidle') + const button = page.getByTestId('redirect-on-click') let fullPageLoad = false diff --git a/e2e/solid-start/basic/tests/search-params.spec.ts b/e2e/solid-start/basic/tests/search-params.spec.ts index 23cd97517d..d7ce617890 100644 --- a/e2e/solid-start/basic/tests/search-params.spec.ts +++ b/e2e/solid-start/basic/tests/search-params.spec.ts @@ -1,5 +1,5 @@ import { expect } from '@playwright/test' -import { test } from './fixture' +import { test } from '@tanstack/router-e2e-utils' import type { Response } from '@playwright/test' function expectRedirect(response: Response | null, endsWith: string) { diff --git a/e2e/solid-start/basic/tests/streaming.spec.ts b/e2e/solid-start/basic/tests/streaming.spec.ts index 252bb192aa..15f60b7deb 100644 --- a/e2e/solid-start/basic/tests/streaming.spec.ts +++ b/e2e/solid-start/basic/tests/streaming.spec.ts @@ -1,4 +1,5 @@ -import { expect, test } from '@playwright/test' +import { expect } from '@playwright/test' +import { test } from '@tanstack/router-e2e-utils' test('Navigating to deferred route', async ({ page }) => { await page.goto('/') diff --git a/e2e/solid-start/basic/vite.config.ts b/e2e/solid-start/basic/vite.config.ts index 3af67d62ad..1a2219f443 100644 --- a/e2e/solid-start/basic/vite.config.ts +++ b/e2e/solid-start/basic/vite.config.ts @@ -1,6 +1,7 @@ import { defineConfig } from 'vite' import tsConfigPaths from 'vite-tsconfig-paths' import { tanstackStart } from '@tanstack/solid-start/plugin/vite' +import viteSolid from 'vite-plugin-solid' export default defineConfig({ server: { @@ -10,6 +11,7 @@ export default defineConfig({ tsConfigPaths({ projects: ['./tsconfig.json'], }), - tanstackStart({}), + tanstackStart(), + viteSolid({ ssr: true }), ], }) diff --git a/e2e/solid-start/custom-basepath/express-server.ts b/e2e/solid-start/custom-basepath/express-server.ts new file mode 100644 index 0000000000..6fa802e447 --- /dev/null +++ b/e2e/solid-start/custom-basepath/express-server.ts @@ -0,0 +1,44 @@ +import express from 'express' +import { toNodeHandler } from 'srvx/node' + +const DEVELOPMENT = process.env.NODE_ENV === 'development' +const PORT = Number.parseInt(process.env.PORT || '3000') + +const app = express() + +if (DEVELOPMENT) { + const viteDevServer = await import('vite').then((vite) => + vite.createServer({ + server: { middlewareMode: true }, + }), + ) + app.use(viteDevServer.middlewares) + app.use(async (req, res, next) => { + try { + const { default: serverEntry } = + await viteDevServer.ssrLoadModule('./src/server.ts') + const handler = toNodeHandler(serverEntry.fetch) + await handler(req, res) + } catch (error) { + if (typeof error === 'object' && error instanceof Error) { + viteDevServer.ssrFixStacktrace(error) + } + next(error) + } + }) +} else { + const { default: handler } = await import('./dist/server/server.js') + const nodeHandler = toNodeHandler(handler.fetch) + app.use('/custom/basepath', express.static('dist/client')) + app.use(async (req, res, next) => { + try { + await nodeHandler(req, res) + } catch (error) { + next(error) + } + }) +} + +app.listen(PORT, () => { + console.log(`Server is running on http://localhost:${PORT}`) +}) diff --git a/e2e/solid-start/custom-basepath/package.json b/e2e/solid-start/custom-basepath/package.json index 1f668703a3..1b0755af31 100644 --- a/e2e/solid-start/custom-basepath/package.json +++ b/e2e/solid-start/custom-basepath/package.json @@ -4,32 +4,33 @@ "sideEffects": false, "type": "module", "scripts": { - "dev": "vite dev --port 3000", - "dev:e2e": "vite dev", + "dev": "cross-env NODE_ENV=development tsx express-server.ts", "build": "vite build && tsc --noEmit", - "start": "node .output/server/index.mjs", + "start": "tsx express-server.ts", "test:e2e": "rm -rf port*.txt; playwright test --project=chromium" }, "dependencies": { "@tanstack/solid-router": "workspace:^", "@tanstack/solid-router-devtools": "workspace:^", "@tanstack/solid-start": "workspace:^", + "express": "^4.21.2", "redaxios": "^0.5.1", - "solid-js": "^1.9.5", - "tailwind-merge": "^2.6.0", - "vite": "6.3.5", - "zod": "^3.24.2" + "solid-js": "^1.9.5" }, "devDependencies": { "@playwright/test": "^1.50.1", "@tanstack/router-e2e-utils": "workspace:^", + "@types/express": "^5.0.3", "@types/node": "^22.10.2", "autoprefixer": "^10.4.20", - "combinate": "^1.1.11", + "cross-env": "^10.0.0", "postcss": "^8.5.1", + "srvx": "^0.8.6", "tailwindcss": "^3.4.17", + "tsx": "^4.20.3", "typescript": "^5.7.2", - "vite-plugin-solid": "^2.11.2", + "vite": "^7.1.1", + "vite-plugin-solid": "^2.11.8", "vite-tsconfig-paths": "^5.1.4" } } diff --git a/e2e/solid-start/custom-basepath/src/server.ts b/e2e/solid-start/custom-basepath/src/server.ts new file mode 100644 index 0000000000..d54db7edf0 --- /dev/null +++ b/e2e/solid-start/custom-basepath/src/server.ts @@ -0,0 +1,14 @@ +import { + createStartHandler, + defaultStreamHandler, +} from '@tanstack/solid-start/server' + +import { createRouter } from './router' + +const fetch = createStartHandler({ + createRouter, +})(defaultStreamHandler) + +export default { + fetch, +} diff --git a/e2e/solid-start/custom-basepath/vite.config.ts b/e2e/solid-start/custom-basepath/vite.config.ts index d6784f657c..4f0310eddf 100644 --- a/e2e/solid-start/custom-basepath/vite.config.ts +++ b/e2e/solid-start/custom-basepath/vite.config.ts @@ -1,6 +1,7 @@ import { defineConfig } from 'vite' import tsConfigPaths from 'vite-tsconfig-paths' import { tanstackStart } from '@tanstack/solid-start/plugin/vite' +import viteSolid from 'vite-plugin-solid' export default defineConfig({ base: '/custom/basepath', @@ -11,6 +12,7 @@ export default defineConfig({ tsConfigPaths({ projects: ['./tsconfig.json'], }), - tanstackStart({}), + tanstackStart(), + viteSolid({ ssr: true }), ], }) diff --git a/e2e/solid-start/scroll-restoration/package.json b/e2e/solid-start/scroll-restoration/package.json index 60f64e7d04..8527fa97e4 100644 --- a/e2e/solid-start/scroll-restoration/package.json +++ b/e2e/solid-start/scroll-restoration/package.json @@ -7,7 +7,7 @@ "dev": "vite dev --port 3000", "dev:e2e": "vite dev", "build": "vite build && tsc --noEmit", - "start": "node .output/server/index.mjs", + "start": "pnpx srvx --prod -s ../client dist/server/server.js", "test:e2e": "rm -rf port*.txt; playwright test --project=chromium" }, "dependencies": { @@ -18,7 +18,7 @@ "redaxios": "^0.5.1", "solid-js": "^1.9.5", "tailwind-merge": "^2.6.0", - "vite": "6.3.5", + "vite": "^7.1.1", "zod": "^3.24.2" }, "devDependencies": { @@ -28,9 +28,10 @@ "autoprefixer": "^10.4.20", "combinate": "^1.1.11", "postcss": "^8.5.1", + "srvx": "^0.8.6", "tailwindcss": "^3.4.17", "typescript": "^5.7.2", - "vite-plugin-solid": "^2.11.6", + "vite-plugin-solid": "^2.11.8", "vite-tsconfig-paths": "^5.1.4" } } diff --git a/e2e/solid-start/scroll-restoration/vite.config.ts b/e2e/solid-start/scroll-restoration/vite.config.ts index 3af67d62ad..1a2219f443 100644 --- a/e2e/solid-start/scroll-restoration/vite.config.ts +++ b/e2e/solid-start/scroll-restoration/vite.config.ts @@ -1,6 +1,7 @@ import { defineConfig } from 'vite' import tsConfigPaths from 'vite-tsconfig-paths' import { tanstackStart } from '@tanstack/solid-start/plugin/vite' +import viteSolid from 'vite-plugin-solid' export default defineConfig({ server: { @@ -10,6 +11,7 @@ export default defineConfig({ tsConfigPaths({ projects: ['./tsconfig.json'], }), - tanstackStart({}), + tanstackStart(), + viteSolid({ ssr: true }), ], }) diff --git a/e2e/solid-start/selective-ssr/package.json b/e2e/solid-start/selective-ssr/package.json index 3be0fee142..67a902cfe2 100644 --- a/e2e/solid-start/selective-ssr/package.json +++ b/e2e/solid-start/selective-ssr/package.json @@ -7,7 +7,7 @@ "dev": "vite dev --port 3000", "dev:e2e": "vite dev", "build": "vite build && tsc --noEmit", - "start": "node .output/server/index.mjs", + "start": "pnpx srvx --prod -s ../client dist/server/server.js", "test:e2e": "rm -rf port*.txt; playwright test --project=chromium" }, "dependencies": { @@ -19,9 +19,11 @@ "devDependencies": { "@tanstack/router-e2e-utils": "workspace:^", "postcss": "^8.5.1", + "srvx": "^0.8.6", "tailwindcss": "^3.4.17", "typescript": "^5.7.2", - "vite": "^6.3.5", + "vite": "^7.1.1", + "vite-plugin-solid": "^2.11.8", "vite-tsconfig-paths": "^5.1.4" } } diff --git a/e2e/solid-start/selective-ssr/tests/app.spec.ts b/e2e/solid-start/selective-ssr/tests/app.spec.ts index b013dfb169..aea216d506 100644 --- a/e2e/solid-start/selective-ssr/tests/app.spec.ts +++ b/e2e/solid-start/selective-ssr/tests/app.spec.ts @@ -1,5 +1,5 @@ import { expect } from '@playwright/test' -import { test } from './fixture' +import { test } from '@tanstack/router-e2e-utils' const testCount = 7 diff --git a/e2e/solid-start/selective-ssr/tests/fixture.ts b/e2e/solid-start/selective-ssr/tests/fixture.ts deleted file mode 100644 index abb7b1d564..0000000000 --- a/e2e/solid-start/selective-ssr/tests/fixture.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { test as base, expect } from '@playwright/test' - -export interface TestFixtureOptions { - whitelistErrors: Array -} -export const test = base.extend({ - whitelistErrors: [[], { option: true }], - page: async ({ page, whitelistErrors }, use) => { - const errorMessages: Array = [] - page.on('console', (m) => { - if (m.type() === 'error') { - const text = m.text() - for (const whitelistError of whitelistErrors) { - if ( - (typeof whitelistError === 'string' && - text.includes(whitelistError)) || - (whitelistError instanceof RegExp && whitelistError.test(text)) - ) { - return - } - } - errorMessages.push(text) - } - }) - await use(page) - expect(errorMessages).toEqual([]) - }, -}) diff --git a/e2e/solid-start/selective-ssr/vite.config.ts b/e2e/solid-start/selective-ssr/vite.config.ts index 151f2248f8..20ffdb3d6e 100644 --- a/e2e/solid-start/selective-ssr/vite.config.ts +++ b/e2e/solid-start/selective-ssr/vite.config.ts @@ -1,6 +1,7 @@ import { defineConfig } from 'vite' import { tanstackStart } from '@tanstack/solid-start/plugin/vite' import tsConfigPaths from 'vite-tsconfig-paths' +import viteSolid from 'vite-plugin-solid' export default defineConfig({ server: { @@ -11,5 +12,6 @@ export default defineConfig({ projects: ['./tsconfig.json'], }), tanstackStart(), + viteSolid({ ssr: true }), ], }) diff --git a/e2e/solid-start/server-functions/package.json b/e2e/solid-start/server-functions/package.json index 7a02e8266e..fb3d649934 100644 --- a/e2e/solid-start/server-functions/package.json +++ b/e2e/solid-start/server-functions/package.json @@ -7,7 +7,7 @@ "dev": "vite dev --port 3000", "dev:e2e": "vite dev", "build": "vite build && tsc --noEmit", - "start": "node .output/server/index.mjs", + "start": "pnpx srvx --prod -s ../client dist/server/server.js", "test:e2e": "rm -rf port*.txt; playwright test --project=chromium" }, "dependencies": { @@ -18,7 +18,7 @@ "redaxios": "^0.5.1", "solid-js": "^1.9.5", "tailwind-merge": "^2.6.0", - "vite": "6.3.5", + "vite": "^7.1.1", "zod": "^3.24.2" }, "devDependencies": { @@ -29,9 +29,10 @@ "autoprefixer": "^10.4.20", "combinate": "^1.1.11", "postcss": "^8.5.1", + "srvx": "^0.8.6", "tailwindcss": "^3.4.17", "typescript": "^5.7.2", - "vite-plugin-solid": "^2.11.6", + "vite-plugin-solid": "^2.11.8", "vite-tsconfig-paths": "^5.1.4" } } diff --git a/e2e/solid-start/server-functions/src/routes/env-only.tsx b/e2e/solid-start/server-functions/src/routes/env-only.tsx index df8f08eed2..85bcae0f60 100644 --- a/e2e/solid-start/server-functions/src/routes/env-only.tsx +++ b/e2e/solid-start/server-functions/src/routes/env-only.tsx @@ -1,9 +1,13 @@ import { createFileRoute } from '@tanstack/solid-router' -import { clientOnly, createServerFn, serverOnly } from '@tanstack/solid-start' +import { + createClientOnlyFn, + createServerFn, + createServerOnlyFn, +} from '@tanstack/solid-start' import { createSignal } from 'solid-js' -const serverEcho = serverOnly((input: string) => 'server got: ' + input) -const clientEcho = clientOnly((input: string) => 'client got: ' + input) +const serverEcho = createServerOnlyFn((input: string) => 'server got: ' + input) +const clientEcho = createClientOnlyFn((input: string) => 'client got: ' + input) const testOnServer = createServerFn().handler(() => { const serverOnServer = serverEcho('hello') diff --git a/e2e/solid-start/server-functions/src/routes/headers.tsx b/e2e/solid-start/server-functions/src/routes/headers.tsx index 3b1ce8d499..132f304fbe 100644 --- a/e2e/solid-start/server-functions/src/routes/headers.tsx +++ b/e2e/solid-start/server-functions/src/routes/headers.tsx @@ -1,8 +1,11 @@ import { createFileRoute } from '@tanstack/solid-router' import * as Solid from 'solid-js' import { createServerFn } from '@tanstack/solid-start' -import { getHeaders, setHeader } from '@tanstack/solid-start/server' -import type { HTTPHeaderName } from '@tanstack/solid-start/server' +import { + getRequestHeaders, + setResponseHeader, +} from '@tanstack/solid-start/server' +import type { RequestHeaderName } from '@tanstack/solid-start/server' export const Route = createFileRoute('/headers')({ loader: async () => { @@ -17,17 +20,18 @@ export const Route = createFileRoute('/headers')({ }) export const getTestHeaders = createServerFn().handler(() => { - setHeader('x-test-header', 'test-value') + setResponseHeader('x-test-header', 'test-value') + const reqHeaders = Object.fromEntries(getRequestHeaders().entries()) return { - serverHeaders: getHeaders(), - headers: getHeaders(), + serverHeaders: reqHeaders, + headers: reqHeaders, } }) type TestHeadersResult = { - headers?: Partial> - serverHeaders?: Partial> + headers?: Partial> + serverHeaders?: Partial> } function ResponseHeaders({ diff --git a/e2e/solid-start/server-functions/src/routes/raw-response.tsx b/e2e/solid-start/server-functions/src/routes/raw-response.tsx index 24f95e2cd1..ad3cfdc419 100644 --- a/e2e/solid-start/server-functions/src/routes/raw-response.tsx +++ b/e2e/solid-start/server-functions/src/routes/raw-response.tsx @@ -8,7 +8,7 @@ export const Route = createFileRoute('/raw-response')({ }) const expectedValue = 'Hello from a server function!' -export const rawResponseFn = createServerFn({ response: 'raw' }).handler(() => { +export const rawResponseFn = createServerFn().handler(() => { return new Response(expectedValue) }) diff --git a/e2e/solid-start/server-functions/src/routes/serialize-form-data.tsx b/e2e/solid-start/server-functions/src/routes/serialize-form-data.tsx index 1973e9f7b9..aeaf80576c 100644 --- a/e2e/solid-start/server-functions/src/routes/serialize-form-data.tsx +++ b/e2e/solid-start/server-functions/src/routes/serialize-form-data.tsx @@ -11,7 +11,7 @@ const testValues = { __adder: 1, } -export const greetUser = createServerFn() +export const greetUser = createServerFn({ method: 'POST' }) .validator((data: FormData) => { if (!(data instanceof FormData)) { throw new Error('Invalid! FormData is required') diff --git a/e2e/solid-start/server-functions/src/routes/submit-post-formdata.tsx b/e2e/solid-start/server-functions/src/routes/submit-post-formdata.tsx index 3fb6ea356f..d9b8ed5588 100644 --- a/e2e/solid-start/server-functions/src/routes/submit-post-formdata.tsx +++ b/e2e/solid-start/server-functions/src/routes/submit-post-formdata.tsx @@ -9,7 +9,7 @@ const testValues = { name: 'Sean', } -export const greetUser = createServerFn({ method: 'POST', response: 'raw' }) +export const greetUser = createServerFn({ method: 'POST' }) .validator((data: FormData) => { if (!(data instanceof FormData)) { throw new Error('Invalid! FormData is required') diff --git a/e2e/solid-start/server-functions/tests/fixture.ts b/e2e/solid-start/server-functions/tests/fixture.ts deleted file mode 100644 index abb7b1d564..0000000000 --- a/e2e/solid-start/server-functions/tests/fixture.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { test as base, expect } from '@playwright/test' - -export interface TestFixtureOptions { - whitelistErrors: Array -} -export const test = base.extend({ - whitelistErrors: [[], { option: true }], - page: async ({ page, whitelistErrors }, use) => { - const errorMessages: Array = [] - page.on('console', (m) => { - if (m.type() === 'error') { - const text = m.text() - for (const whitelistError of whitelistErrors) { - if ( - (typeof whitelistError === 'string' && - text.includes(whitelistError)) || - (whitelistError instanceof RegExp && whitelistError.test(text)) - ) { - return - } - } - errorMessages.push(text) - } - }) - await use(page) - expect(errorMessages).toEqual([]) - }, -}) diff --git a/e2e/solid-start/server-functions/tests/server-functions.spec.ts b/e2e/solid-start/server-functions/tests/server-functions.spec.ts index 80c89004c5..2af3201cf4 100644 --- a/e2e/solid-start/server-functions/tests/server-functions.spec.ts +++ b/e2e/solid-start/server-functions/tests/server-functions.spec.ts @@ -1,5 +1,6 @@ import * as fs from 'node:fs' -import { expect, test } from '@playwright/test' +import { expect } from '@playwright/test' +import { test } from '@tanstack/router-e2e-utils' import { PORT } from '../playwright.config' import type { Page } from '@playwright/test' @@ -11,16 +12,10 @@ test('invoking a server function with custom response status code', async ({ await page.waitForLoadState('networkidle') const requestPromise = new Promise((resolve) => { - page.on('response', async (response) => { + page.on('response', (response) => { expect(response.status()).toBe(225) expect(response.statusText()).toBe('hello') - expect(response.headers()['content-type']).toBe('application/json') - expect(await response.json()).toEqual( - expect.objectContaining({ - result: { hello: 'world' }, - context: {}, - }), - ) + expect(response.headers()['content-type']).toContain('application/json') resolve() }) }) @@ -122,11 +117,11 @@ test('env-only functions can only be called on the server or client respectively 'server got: hello', ) await expect(page.getByTestId('server-on-client')).toContainText( - 'serverEcho threw an error: serverOnly() functions can only be called on the server!', + 'serverEcho threw an error: createServerOnlyFn() functions can only be called on the server!', ) await expect(page.getByTestId('client-on-server')).toContainText( - 'clientEcho threw an error: clientOnly() functions can only be called on the client!', + 'clientEcho threw an error: createClientOnlyFn() functions can only be called on the client!', ) await expect(page.getByTestId('client-on-client')).toContainText( 'client got: hello', diff --git a/e2e/solid-start/server-functions/vite.config.ts b/e2e/solid-start/server-functions/vite.config.ts index bae1bfaad6..1a2219f443 100644 --- a/e2e/solid-start/server-functions/vite.config.ts +++ b/e2e/solid-start/server-functions/vite.config.ts @@ -1,6 +1,7 @@ import { defineConfig } from 'vite' import tsConfigPaths from 'vite-tsconfig-paths' import { tanstackStart } from '@tanstack/solid-start/plugin/vite' +import viteSolid from 'vite-plugin-solid' export default defineConfig({ server: { @@ -11,5 +12,6 @@ export default defineConfig({ projects: ['./tsconfig.json'], }), tanstackStart(), + viteSolid({ ssr: true }), ], }) diff --git a/e2e/solid-start/server-routes/package.json b/e2e/solid-start/server-routes/package.json index c2bec1aa27..96a395f286 100644 --- a/e2e/solid-start/server-routes/package.json +++ b/e2e/solid-start/server-routes/package.json @@ -7,7 +7,7 @@ "dev": "vite dev --port 3000", "dev:e2e": "vite dev", "build": "vite build && tsc --noEmit", - "start": "node .output/server/index.mjs", + "start": "pnpx srvx --prod -s ../client dist/server/server.js", "test:e2e": "playwright test --project=chromium" }, "dependencies": { @@ -18,7 +18,7 @@ "redaxios": "^0.5.1", "solid-js": "^1.9.5", "tailwind-merge": "^2.6.0", - "vite": "6.3.5", + "vite": "^7.1.1", "zod": "^3.24.2" }, "devDependencies": { @@ -29,9 +29,10 @@ "autoprefixer": "^10.4.20", "combinate": "^1.1.11", "postcss": "^8.5.1", + "srvx": "^0.8.6", "tailwindcss": "^3.4.17", "typescript": "^5.7.2", - "vite-plugin-solid": "^2.11.6", + "vite-plugin-solid": "^2.11.8", "vite-tsconfig-paths": "^5.1.4" } } diff --git a/e2e/solid-start/server-routes/tests/fixture.ts b/e2e/solid-start/server-routes/tests/fixture.ts deleted file mode 100644 index abb7b1d564..0000000000 --- a/e2e/solid-start/server-routes/tests/fixture.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { test as base, expect } from '@playwright/test' - -export interface TestFixtureOptions { - whitelistErrors: Array -} -export const test = base.extend({ - whitelistErrors: [[], { option: true }], - page: async ({ page, whitelistErrors }, use) => { - const errorMessages: Array = [] - page.on('console', (m) => { - if (m.type() === 'error') { - const text = m.text() - for (const whitelistError of whitelistErrors) { - if ( - (typeof whitelistError === 'string' && - text.includes(whitelistError)) || - (whitelistError instanceof RegExp && whitelistError.test(text)) - ) { - return - } - } - errorMessages.push(text) - } - }) - await use(page) - expect(errorMessages).toEqual([]) - }, -}) diff --git a/e2e/solid-start/server-routes/tests/server-routes.spec.ts b/e2e/solid-start/server-routes/tests/server-routes.spec.ts index 098a40b2ef..33176a23fd 100644 --- a/e2e/solid-start/server-routes/tests/server-routes.spec.ts +++ b/e2e/solid-start/server-routes/tests/server-routes.spec.ts @@ -1,4 +1,5 @@ -import { expect, test } from '@playwright/test' +import { expect } from '@playwright/test' +import { test } from '@tanstack/router-e2e-utils' test('merge-server-fn-middleware-context', async ({ page }) => { await page.goto('/merge-server-fn-middleware-context') diff --git a/e2e/solid-start/server-routes/vite.config.ts b/e2e/solid-start/server-routes/vite.config.ts index bae1bfaad6..1a2219f443 100644 --- a/e2e/solid-start/server-routes/vite.config.ts +++ b/e2e/solid-start/server-routes/vite.config.ts @@ -1,6 +1,7 @@ import { defineConfig } from 'vite' import tsConfigPaths from 'vite-tsconfig-paths' import { tanstackStart } from '@tanstack/solid-start/plugin/vite' +import viteSolid from 'vite-plugin-solid' export default defineConfig({ server: { @@ -11,5 +12,6 @@ export default defineConfig({ projects: ['./tsconfig.json'], }), tanstackStart(), + viteSolid({ ssr: true }), ], }) diff --git a/e2e/solid-start/spa-mode/package.json b/e2e/solid-start/spa-mode/package.json index 74f862abcb..a0ffac57a5 100644 --- a/e2e/solid-start/spa-mode/package.json +++ b/e2e/solid-start/spa-mode/package.json @@ -7,7 +7,7 @@ "dev": "vite dev --port 3000", "dev:e2e": "vite dev", "build": "vite build && tsc --noEmit", - "start": "npx serve .output/public", + "start": "npx serve dist/client", "test:e2e": "rm -rf port*.txt; playwright test --project=chromium" }, "dependencies": { @@ -22,7 +22,8 @@ "postcss": "^8.5.1", "tailwindcss": "^3.4.17", "typescript": "^5.7.2", - "vite": "^6.3.5", - "vite-tsconfig-paths": "^5.1.4" + "vite": "^7.1.1", + "vite-tsconfig-paths": "^5.1.4", + "vite-plugin-solid": "^2.11.8" } } diff --git a/e2e/solid-start/spa-mode/tests/app.spec.ts b/e2e/solid-start/spa-mode/tests/app.spec.ts index 8970ec333c..c18a0ff65d 100644 --- a/e2e/solid-start/spa-mode/tests/app.spec.ts +++ b/e2e/solid-start/spa-mode/tests/app.spec.ts @@ -1,5 +1,5 @@ import { expect } from '@playwright/test' -import { test } from './fixture' +import { test } from '@tanstack/router-e2e-utils' import type { Page } from '@playwright/test' async function runTest( diff --git a/e2e/solid-start/spa-mode/tests/fixture.ts b/e2e/solid-start/spa-mode/tests/fixture.ts deleted file mode 100644 index abb7b1d564..0000000000 --- a/e2e/solid-start/spa-mode/tests/fixture.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { test as base, expect } from '@playwright/test' - -export interface TestFixtureOptions { - whitelistErrors: Array -} -export const test = base.extend({ - whitelistErrors: [[], { option: true }], - page: async ({ page, whitelistErrors }, use) => { - const errorMessages: Array = [] - page.on('console', (m) => { - if (m.type() === 'error') { - const text = m.text() - for (const whitelistError of whitelistErrors) { - if ( - (typeof whitelistError === 'string' && - text.includes(whitelistError)) || - (whitelistError instanceof RegExp && whitelistError.test(text)) - ) { - return - } - } - errorMessages.push(text) - } - }) - await use(page) - expect(errorMessages).toEqual([]) - }, -}) diff --git a/e2e/solid-start/spa-mode/vite.config.ts b/e2e/solid-start/spa-mode/vite.config.ts index f14e499525..3bad2df77e 100644 --- a/e2e/solid-start/spa-mode/vite.config.ts +++ b/e2e/solid-start/spa-mode/vite.config.ts @@ -1,6 +1,7 @@ import { defineConfig } from 'vite' import { tanstackStart } from '@tanstack/solid-start/plugin/vite' import tsConfigPaths from 'vite-tsconfig-paths' +import viteSolid from 'vite-plugin-solid' export default defineConfig({ server: { @@ -25,5 +26,6 @@ export default defineConfig({ }, ], }), + viteSolid({ ssr: true }), ], }) diff --git a/e2e/solid-start/website/package.json b/e2e/solid-start/website/package.json index 383f3305db..0a60d4e5f6 100644 --- a/e2e/solid-start/website/package.json +++ b/e2e/solid-start/website/package.json @@ -7,7 +7,7 @@ "dev": "vite dev --port 3000", "dev:e2e": "vite dev", "build": "vite build && tsc --noEmit", - "start": "node .output/server/index.mjs", + "start": "pnpx srvx --prod -s ../client dist/server/server.js", "test:e2e": "rm -rf port*.txt; playwright test --project=chromium" }, "dependencies": { @@ -17,7 +17,7 @@ "redaxios": "^0.5.1", "solid-js": "^1.9.5", "tailwind-merge": "^2.6.0", - "vite": "6.3.5", + "vite": "^7.1.1", "zod": "^3.24.2" }, "devDependencies": { @@ -26,9 +26,10 @@ "@types/node": "^22.10.2", "autoprefixer": "^10.4.20", "postcss": "^8.5.1", + "srvx": "^0.8.6", "tailwindcss": "^3.4.17", "typescript": "^5.7.2", - "vite-plugin-solid": "^2.11.6", + "vite-plugin-solid": "^2.11.8", "vite-tsconfig-paths": "^5.1.4" } } diff --git a/e2e/solid-start/website/vite.config.ts b/e2e/solid-start/website/vite.config.ts index 3af67d62ad..1a2219f443 100644 --- a/e2e/solid-start/website/vite.config.ts +++ b/e2e/solid-start/website/vite.config.ts @@ -1,6 +1,7 @@ import { defineConfig } from 'vite' import tsConfigPaths from 'vite-tsconfig-paths' import { tanstackStart } from '@tanstack/solid-start/plugin/vite' +import viteSolid from 'vite-plugin-solid' export default defineConfig({ server: { @@ -10,6 +11,7 @@ export default defineConfig({ tsConfigPaths({ projects: ['./tsconfig.json'], }), - tanstackStart({}), + tanstackStart(), + viteSolid({ ssr: true }), ], }) diff --git a/examples/react/authenticated-routes-firebase/package.json b/examples/react/authenticated-routes-firebase/package.json index c188e691b0..501082e410 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.21", + "@tanstack/react-router-devtools": "^1.132.0-alpha.21", + "@tanstack/router-plugin": "^1.132.0-alpha.21", "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..61b6301c0f 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.21", + "@tanstack/react-router-devtools": "^1.132.0-alpha.21", + "@tanstack/router-plugin": "^1.132.0-alpha.21", "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..ee01ad3aad 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.21", + "@tanstack/react-router-devtools": "^1.132.0-alpha.21", "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..e03391b6d3 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.21", + "@tanstack/react-router-devtools": "^1.132.0-alpha.21", "@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..6eeb09cb28 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.21", + "@tanstack/react-router-devtools": "^1.132.0-alpha.21", + "@tanstack/router-plugin": "^1.132.0-alpha.21", "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..9e728b20ef 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.21", + "@tanstack/react-router-devtools": "^1.132.0-alpha.21", "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..f2e6a21bf8 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.21", + "@tanstack/react-router-devtools": "^1.132.0-alpha.21", + "@tanstack/router-plugin": "^1.132.0-alpha.21", "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..43cbbe4147 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.21", + "@tanstack/react-router-devtools": "^1.132.0-alpha.21", "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..6f96d76176 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.21", + "@tanstack/router-plugin": "^1.132.0-alpha.21", "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.21", "@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..4f0baee265 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.21", + "@tanstack/router-plugin": "^1.132.0-alpha.21", "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.21", "@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..8c21ce622c 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.21", + "@tanstack/react-router-devtools": "^1.132.0-alpha.21", + "@tanstack/router-plugin": "^1.132.0-alpha.21", + "@tanstack/virtual-file-routes": "^1.132.0-alpha.1", "react": "^19.0.0", "react-dom": "^19.0.0", "redaxios": "^0.5.1", @@ -26,6 +26,6 @@ "@types/react-dom": "^19.0.3", "@vitejs/plugin-react": "^4.3.4", "typescript": "^5.7.2", - "vite": "^6.3.5" + "vite": "^7.1.1" } } diff --git a/examples/react/basic-virtual-inside-file-based/package.json b/examples/react/basic-virtual-inside-file-based/package.json index 2bea5afad5..44fb1ca557 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.21", + "@tanstack/react-router-devtools": "^1.132.0-alpha.21", + "@tanstack/router-plugin": "^1.132.0-alpha.21", + "@tanstack/virtual-file-routes": "^1.132.0-alpha.1", "react": "^19.0.0", "react-dom": "^19.0.0", "redaxios": "^0.5.1", @@ -26,6 +26,6 @@ "@types/react-dom": "^19.0.3", "@vitejs/plugin-react": "^4.3.4", "typescript": "^5.7.2", - "vite": "^6.3.5" + "vite": "^7.1.1" } } diff --git a/examples/react/basic/package.json b/examples/react/basic/package.json index 17e33d6a3b..8df322bb8f 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.21", + "@tanstack/react-router-devtools": "^1.132.0-alpha.21", "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..6eca7f4572 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.21", + "@tanstack/react-router-devtools": "^1.132.0-alpha.21", "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..bf537abbee 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.21", + "@tanstack/react-router-devtools": "^1.132.0-alpha.21", + "@tanstack/router-plugin": "^1.132.0-alpha.21", "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..7961f92c09 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.21", + "@tanstack/react-router-devtools": "^1.132.0-alpha.21", + "@tanstack/router-plugin": "^1.132.0-alpha.21", "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..9bdbe55a11 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.21", + "@tanstack/react-router-devtools": "^1.132.0-alpha.21", "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..864c7883da 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.21", + "@tanstack/react-router-devtools": "^1.132.0-alpha.21", "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..1f0b8f94b5 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.21", + "@tanstack/react-router-devtools": "^1.132.0-alpha.21", + "@tanstack/router-plugin": "^1.132.0-alpha.21", "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..00b0a8728c 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.21", + "@tanstack/react-router-devtools": "^1.132.0-alpha.21", "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..c287ec02e5 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.21", + "@tanstack/react-router-devtools": "^1.132.0-alpha.21", "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..31ff6451c6 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.21", + "@tanstack/react-router-devtools": "^1.132.0-alpha.21", + "@tanstack/router-plugin": "^1.132.0-alpha.21", "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..3faf01ad64 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.21", + "@tanstack/react-router-devtools": "^1.132.0-alpha.21", + "@tanstack/router-plugin": "^1.132.0-alpha.21", "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..5392758729 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.21", + "@tanstack/react-router-devtools": "^1.132.0-alpha.21", "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.21", "@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..9d00ad90b9 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.21", + "@tanstack/react-router-devtools": "^1.132.0-alpha.21", "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.21", "@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..edc06e1bbc 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.21", + "@tanstack/react-router-devtools": "^1.132.0-alpha.21", "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..57eed9d5d5 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.21", + "@tanstack/react-router-devtools": "^1.132.0-alpha.21", + "@tanstack/router-plugin": "^1.132.0-alpha.21", "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..357715f7bb 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.21", "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..247e08b9d0 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.21", + "@tanstack/router-plugin": "^1.132.0-alpha.21", "@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..0c4d447b40 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.21", + "@tanstack/react-router-devtools": "^1.132.0-alpha.21", + "@tanstack/router-plugin": "^1.132.0-alpha.21", "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..f5feac2950 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.21", "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..277dc0b4c8 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.21", + "@tanstack/router-plugin": "^1.132.0-alpha.21", "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..61c96ea601 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.21", + "@tanstack/react-router-devtools": "^1.132.0-alpha.21", + "@tanstack/router-plugin": "^1.132.0-alpha.21", "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..89a1fe09ce 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.21", + "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..981c122b83 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.21", + "@tanstack/router-plugin": "^1.132.0-alpha.21", "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..b1cd8a243d 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.21", "@tanstack/react-virtual": "^3.13.0", - "@tanstack/react-router-devtools": "^1.131.27", + "@tanstack/react-router-devtools": "^1.132.0-alpha.21", "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..85fb11e04d 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.21", "@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.21", + "@tanstack/react-router-devtools": "^1.132.0-alpha.21", + "@tanstack/router-plugin": "^1.132.0-alpha.21", + "@tanstack/valibot-adapter": "^1.132.0-alpha.21", + "@tanstack/zod-adapter": "^1.132.0-alpha.21", "arktype": "^2.1.7", "react": "^19.0.0", "react-dom": "^19.0.0", @@ -33,6 +33,6 @@ "@types/react-dom": "^19.0.3", "@vitejs/plugin-react": "^4.3.4", "typescript": "^5.7.2", - "vite": "^6.3.5" + "vite": "^7.1.1" } } diff --git a/examples/react/start-bare/package.json b/examples/react/start-bare/package.json index 08e46031e5..69933bac30 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.21", + "@tanstack/react-router-devtools": "^1.132.0-alpha.21", + "@tanstack/react-start": "^1.132.0-alpha.22", "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..06c2a3dfa6 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.21", + "@tanstack/react-router-devtools": "^1.132.0-alpha.21", + "@tanstack/react-start": "^1.132.0-alpha.22", "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..ec5c5c013e 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.21", + "@tanstack/react-router-ssr-query": "^1.132.0-alpha.21", + "@tanstack/react-router-devtools": "^1.132.0-alpha.21", + "@tanstack/react-start": "^1.132.0-alpha.22", "react": "^19.0.0", "react-dom": "^19.0.0", "redaxios": "^0.5.1", @@ -24,11 +24,12 @@ "@types/node": "^22.5.4", "@types/react": "^19.0.8", "@types/react-dom": "^19.0.3", + "@vitejs/plugin-react": "^4.3.4", "postcss": "^8.5.1", "autoprefixer": "^10.4.20", "tailwindcss": "^3.4.17", "typescript": "^5.7.2", - "vite": "^6.3.5", + "vite": "^7.1.1", "vite-tsconfig-paths": "^5.1.4" } } diff --git a/examples/react/start-basic-react-query/vite.config.ts b/examples/react/start-basic-react-query/vite.config.ts index 1f5fd1961a..f10c86e79f 100644 --- a/examples/react/start-basic-react-query/vite.config.ts +++ b/examples/react/start-basic-react-query/vite.config.ts @@ -1,6 +1,7 @@ import { tanstackStart } from '@tanstack/react-start/plugin/vite' import { defineConfig } from 'vite' import tsConfigPaths from 'vite-tsconfig-paths' +import viteReact from '@vitejs/plugin-react' export default defineConfig({ server: { @@ -11,5 +12,6 @@ export default defineConfig({ projects: ['./tsconfig.json'], }), tanstackStart(), + viteReact(), ], }) diff --git a/examples/react/start-basic-rsc/package.json b/examples/react/start-basic-rsc/package.json index 754091755d..d5f67c1bca 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.21", + "@tanstack/react-router-devtools": "^1.132.0-alpha.21", + "@tanstack/react-start": "^1.132.0-alpha.22", "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..ae982308e4 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.21", + "@tanstack/react-router-devtools": "^1.132.0-alpha.21", + "@tanstack/react-start": "^1.132.0-alpha.22", + "@tanstack/start-static-server-functions": "^1.132.0-alpha.21", "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..4672a07777 100644 --- a/examples/react/start-basic/package.json +++ b/examples/react/start-basic/package.json @@ -9,9 +9,9 @@ "start": "node .output/server/index.mjs" }, "dependencies": { - "@tanstack/react-router": "^1.131.27", - "@tanstack/react-router-devtools": "^1.131.27", - "@tanstack/react-start": "^1.131.27", + "@tanstack/react-router": "^1.132.0-alpha.21", + "@tanstack/react-router-devtools": "^1.132.0-alpha.21", + "@tanstack/react-start": "^1.132.0-alpha.22", "react": "^19.0.0", "react-dom": "^19.0.0", "tailwind-merge": "^2.6.0", @@ -26,7 +26,7 @@ "postcss": "^8.5.1", "tailwindcss": "^3.4.17", "typescript": "^5.7.2", - "vite": "^6.3.5", + "vite": "^7.1.1", "vite-tsconfig-paths": "^5.1.4" } } diff --git a/examples/react/start-basic/src/routes/index.tsx b/examples/react/start-basic/src/routes/index.tsx index 37c8d237bd..09a907cb18 100644 --- a/examples/react/start-basic/src/routes/index.tsx +++ b/examples/react/start-basic/src/routes/index.tsx @@ -1,4 +1,5 @@ import { createFileRoute } from '@tanstack/react-router' + export const Route = createFileRoute('/')({ component: Home, }) diff --git a/examples/react/start-basic/vite.config.ts b/examples/react/start-basic/vite.config.ts index 70067dfa49..f10c86e79f 100644 --- a/examples/react/start-basic/vite.config.ts +++ b/examples/react/start-basic/vite.config.ts @@ -11,7 +11,7 @@ export default defineConfig({ tsConfigPaths({ projects: ['./tsconfig.json'], }), - tanstackStart({ customViteReactPlugin: true }), + tanstackStart(), viteReact(), ], }) diff --git a/examples/react/start-clerk-basic/package.json b/examples/react/start-clerk-basic/package.json index 8a0e5a1262..95353e0d0a 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.21", + "@tanstack/react-router-devtools": "^1.132.0-alpha.21", + "@tanstack/react-start": "^1.132.0-alpha.22", + "@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..912eb62709 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.21", + "@tanstack/react-router-ssr-query": "^1.132.0-alpha.21", + "@tanstack/react-router-devtools": "^1.132.0-alpha.21", + "@tanstack/react-start": "^1.132.0-alpha.22", "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..107e9b8903 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.21", + "@tanstack/react-router-devtools": "^1.132.0-alpha.21", + "@tanstack/react-start": "^1.132.0-alpha.22", "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..7785feceac 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.21", + "@tanstack/react-router-devtools": "^1.132.0-alpha.21", + "@tanstack/react-start": "^1.132.0-alpha.22", "react": "^19.0.0", "react-dom": "^19.0.0", "redaxios": "^0.5.1", @@ -25,11 +25,12 @@ "@types/node": "^22.5.4", "@types/react": "^19.0.8", "@types/react-dom": "^19.0.3", + "@vitejs/plugin-react": "^4.3.4", "postcss": "^8.5.1", "autoprefixer": "^10.4.20", "tailwindcss": "^3.4.17", "typescript": "^5.7.2", - "vite": "^6.3.5", + "vite": "^7.1.1", "vite-tsconfig-paths": "^5.1.4" }, "keywords": [], diff --git a/examples/react/start-large/src/routes/search/searchPlaceholder.tsx b/examples/react/start-large/src/routes/search/searchPlaceholder.tsx index eb7f95c39a..f16813520f 100644 --- a/examples/react/start-large/src/routes/search/searchPlaceholder.tsx +++ b/examples/react/start-large/src/routes/search/searchPlaceholder.tsx @@ -68,7 +68,6 @@ export const Route = createFileRoute('/search/searchPlaceholder')({ return { search, - external, } }, }) diff --git a/examples/react/start-large/vite.config.ts b/examples/react/start-large/vite.config.ts index 1f5fd1961a..f10c86e79f 100644 --- a/examples/react/start-large/vite.config.ts +++ b/examples/react/start-large/vite.config.ts @@ -1,6 +1,7 @@ import { tanstackStart } from '@tanstack/react-start/plugin/vite' import { defineConfig } from 'vite' import tsConfigPaths from 'vite-tsconfig-paths' +import viteReact from '@vitejs/plugin-react' export default defineConfig({ server: { @@ -11,5 +12,6 @@ export default defineConfig({ projects: ['./tsconfig.json'], }), tanstackStart(), + viteReact(), ], }) diff --git a/examples/react/start-material-ui/package.json b/examples/react/start-material-ui/package.json index a83f3644ee..ed49800c48 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.21", + "@tanstack/react-start": "^1.132.0-alpha.22", + "@tanstack/react-router-devtools": "^1.132.0-alpha.21", "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..de5b349a66 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.21", + "@tanstack/react-router-devtools": "^1.132.0-alpha.21", + "@tanstack/react-start": "^1.132.0-alpha.22", "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..440fb3232d 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.21", + "@tanstack/react-router-devtools": "^1.132.0-alpha.21", + "@tanstack/react-start": "^1.132.0-alpha.22", "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..22bcf135c8 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.21", + "@tanstack/react-router-ssr-query": "^1.132.0-alpha.21", + "@tanstack/react-router-devtools": "^1.132.0-alpha.21", + "@tanstack/react-start": "^1.132.0-alpha.22", "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..1eff602c94 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.21", + "@tanstack/react-router-devtools": "^1.132.0-alpha.21", + "@tanstack/react-start": "^1.132.0-alpha.22", "@workos-inc/node": "^7.45.0", "iron-session": "^8.0.4", "jose": "^6.0.10", @@ -26,11 +26,12 @@ "devDependencies": { "@types/react": "^19.0.8", "@types/react-dom": "^19.0.3", + "@vitejs/plugin-react": "^4.3.4", "postcss": "^8.5.1", "autoprefixer": "^10.4.20", "tailwindcss": "^3.4.17", "typescript": "^5.7.2", - "vite": "^6.3.5", + "vite": "^7.1.1", "vite-tsconfig-paths": "^5.1.4" } } diff --git a/examples/react/start-workos/src/authkit/serverFunctions.ts b/examples/react/start-workos/src/authkit/serverFunctions.ts index 8ce62c746b..f41ddb9dd0 100644 --- a/examples/react/start-workos/src/authkit/serverFunctions.ts +++ b/examples/react/start-workos/src/authkit/serverFunctions.ts @@ -31,7 +31,7 @@ export const getSignUpUrl = createServerFn({ method: 'GET' }) return getAuthorizationUrl({ data: { returnPathname, screenHint: 'sign-up' } }); }); -export const signOut = createServerFn({ method: 'POST', response: 'full' }) +export const signOut = createServerFn({ method: 'POST' }) .validator((data?: string) => data) .handler(async ({ data: returnTo }) => { const cookieName = getConfig('cookieName') || 'wos_session'; diff --git a/examples/react/start-workos/src/routes/logout.tsx b/examples/react/start-workos/src/routes/logout.tsx index 41e8bc0b88..401d6cbc99 100644 --- a/examples/react/start-workos/src/routes/logout.tsx +++ b/examples/react/start-workos/src/routes/logout.tsx @@ -3,5 +3,7 @@ import { signOut } from '../authkit/serverFunctions'; export const Route = createFileRoute('/logout')({ preload: false, - loader: () => signOut(), + loader: async () => { + await signOut(); + }, }); diff --git a/examples/react/start-workos/vite.config.ts b/examples/react/start-workos/vite.config.ts index cd888de96e..fce3baa54d 100644 --- a/examples/react/start-workos/vite.config.ts +++ b/examples/react/start-workos/vite.config.ts @@ -1,6 +1,7 @@ import { defineConfig } from 'vite'; import tsConfigPaths from 'vite-tsconfig-paths'; import { tanstackStart } from '@tanstack/react-start/plugin/vite'; +import viteReact from '@vitejs/plugin-react'; export default defineConfig({ server: { @@ -11,5 +12,6 @@ export default defineConfig({ projects: ['./tsconfig.json'], }), tanstackStart(), + viteReact(), ], }); diff --git a/examples/react/view-transitions/package.json b/examples/react/view-transitions/package.json index f5b7a3e8be..08217e11f2 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.21", + "@tanstack/react-router-devtools": "^1.132.0-alpha.21", + "@tanstack/router-plugin": "^1.132.0-alpha.21", "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..d84d8b0f73 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.21", + "@tanstack/react-router-devtools": "^1.132.0-alpha.21", "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..464c7ce469 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.21", + "@tanstack/react-router-devtools": "^1.132.0-alpha.21", + "@tanstack/router-plugin": "^1.132.0-alpha.21", "@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..9e8a23c516 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.21", + "@tanstack/react-router-devtools": "^1.132.0-alpha.21", + "@tanstack/router-plugin": "^1.132.0-alpha.21", "@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..1fbc4e07bf 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.21", + "@tanstack/solid-router-devtools": "^1.132.0-alpha.21", "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..8c95d1d13f 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.21", + "@tanstack/solid-router-devtools": "^1.132.0-alpha.21", "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.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-non-nested-devtools/package.json b/examples/solid/basic-non-nested-devtools/package.json index 8a6e98fffd..e47ef56f86 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.21", + "@tanstack/solid-router-devtools": "^1.132.0-alpha.21", "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..3210649863 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.21", + "@tanstack/solid-router-devtools": "^1.132.0-alpha.21", "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.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-solid-query/package.json b/examples/solid/basic-solid-query/package.json index a8753480b6..92db3bc883 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.21", + "@tanstack/solid-router-devtools": "^1.132.0-alpha.21", "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.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-ssr-streaming-file-based/package.json b/examples/solid/basic-ssr-streaming-file-based/package.json index e510325686..80ee04e80a 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.21", + "@tanstack/solid-router-devtools": "^1.132.0-alpha.21", "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.21", "@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..1dd419009a 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.21", + "@tanstack/solid-router-devtools": "^1.132.0-alpha.21", "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..aa0b8cfe80 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.21", + "@tanstack/solid-router-devtools": "^1.132.0-alpha.21", "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.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/quickstart-file-based/package.json b/examples/solid/quickstart-file-based/package.json index 123e3178d7..a715041f07 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.21", + "@tanstack/solid-router-devtools": "^1.132.0-alpha.21", "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.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/start-bare/package.json b/examples/solid/start-bare/package.json index a4a46cc667..9fea9d1fce 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.21", + "@tanstack/solid-router-devtools": "^1.132.0-alpha.21", + "@tanstack/solid-start": "^1.132.0-alpha.22", "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..f8508e29ef 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.21", + "@tanstack/solid-router-devtools": "^1.132.0-alpha.21", + "@tanstack/solid-start": "^1.132.0-alpha.22", + "@tanstack/start-static-server-functions": "^1.132.0-alpha.21", "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..ce290ecba7 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.21", + "@tanstack/solid-router-devtools": "^1.132.0-alpha.21", + "@tanstack/solid-start": "^1.132.0-alpha.22", "solid-js": "^1.9.5", "redaxios": "^0.5.1", "tailwind-merge": "^2.6.0" @@ -22,8 +22,8 @@ "postcss": "^8.5.1", "tailwindcss": "^3.4.17", "typescript": "^5.7.2", - "vite": "^6.3.5", - "vite-plugin-solid": "^2.11.7", + "vite": "^7.1.1", + "vite-plugin-solid": "^2.11.8", "vite-tsconfig-paths": "^5.1.4" } } diff --git a/examples/solid/start-basic/src/utils/posts.tsx b/examples/solid/start-basic/src/utils/posts.tsx index e29706d38c..22db5ebb5f 100644 --- a/examples/solid/start-basic/src/utils/posts.tsx +++ b/examples/solid/start-basic/src/utils/posts.tsx @@ -8,7 +8,7 @@ export type PostType = { body: string } -export const fetchPost = createServerFn({ method: 'GET', type: 'static' }) +export const fetchPost = createServerFn({ method: 'GET' }) .validator((d: string) => d) .handler(async ({ data }) => { console.info(`Fetching post with id ${data}...`) @@ -28,7 +28,6 @@ export const fetchPost = createServerFn({ method: 'GET', type: 'static' }) export const fetchPosts = createServerFn({ method: 'GET', - type: 'static', }).handler(async () => { console.info('Fetching posts...') return axios diff --git a/examples/solid/start-basic/vite.config.ts b/examples/solid/start-basic/vite.config.ts index 93d987e62a..1a2219f443 100644 --- a/examples/solid/start-basic/vite.config.ts +++ b/examples/solid/start-basic/vite.config.ts @@ -11,7 +11,7 @@ export default defineConfig({ tsConfigPaths({ projects: ['./tsconfig.json'], }), - tanstackStart({ customViteSolidPlugin: true }), + tanstackStart(), viteSolid({ ssr: true }), ], }) diff --git a/labeler-config.yml b/labeler-config.yml index 015ae4ec3a..3fd030023c 100644 --- a/labeler-config.yml +++ b/labeler-config.yml @@ -10,6 +10,9 @@ 'package: history': - changed-files: - any-glob-to-any-file: 'packages/history/**/*' +'package: nitro-v2-vite-plugin': + - changed-files: + - any-glob-to-any-file: 'packages/nitro-v2-vite-plugin/**/*' 'package: react-router': - changed-files: - any-glob-to-any-file: 'packages/react-router/**/*' @@ -25,9 +28,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 +73,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 +85,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..a6af63a493 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,9 @@ "@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:*", + "@tanstack/nitro-v2-vite-plugin": "workspace:*" } } } diff --git a/packages/arktype-adapter/package.json b/packages/arktype-adapter/package.json index 2ac8442be1..e884f515b8 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.21", "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/nitro-v2-vite-plugin/README.md b/packages/nitro-v2-vite-plugin/README.md new file mode 100644 index 0000000000..5882e61120 --- /dev/null +++ b/packages/nitro-v2-vite-plugin/README.md @@ -0,0 +1 @@ +# Experimental Nitro v2 Vite Plugin diff --git a/packages/react-start-plugin/eslint.config.js b/packages/nitro-v2-vite-plugin/eslint.config.js similarity index 100% rename from packages/react-start-plugin/eslint.config.js rename to packages/nitro-v2-vite-plugin/eslint.config.js diff --git a/packages/react-start-plugin/package.json b/packages/nitro-v2-vite-plugin/package.json similarity index 76% rename from packages/react-start-plugin/package.json rename to packages/nitro-v2-vite-plugin/package.json index bc068fc0a6..8a0e66c424 100644 --- a/packages/react-start-plugin/package.json +++ b/packages/nitro-v2-vite-plugin/package.json @@ -1,15 +1,15 @@ { - "name": "@tanstack/react-start-plugin", - "version": "1.131.27", + "name": "@tanstack/nitro-v2-vite-plugin", + "version": "1.132.0-alpha.23", "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" + "directory": "packages/nitro-v2-vite-plugin" }, - "homepage": "https://tanstack.com/start", + "homepage": "https://tanstack.com/router", "funding": { "type": "github", "url": "https://github.com/sponsors/tannerlinsley" @@ -25,9 +25,8 @@ ], "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:unit": "echo 'No unit tests are needed here since we do them in @tanstack/router-plugin!'", "test:eslint": "eslint ./src", "test:types": "pnpm run \"/^test:types:ts[0-9]{2}$/\"", "test:types:ts54": "node ../../node_modules/typescript54/lib/tsc.js", @@ -41,6 +40,7 @@ }, "type": "module", "types": "dist/esm/index.d.ts", + "main": "dist/cjs/index.cjs", "module": "dist/esm/index.js", "exports": { ".": { @@ -57,19 +57,13 @@ "src" ], "engines": { - "node": ">=12" + "node": ">=22.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" + "nitropack": "^2.12.6", + "pathe": "^2.0.3" }, "peerDependencies": { - "@vitejs/plugin-react": ">=4.3.4", - "vite": ">=6.0.0" + "vite": ">=7.0.0" } } diff --git a/packages/nitro-v2-vite-plugin/src/index.ts b/packages/nitro-v2-vite-plugin/src/index.ts new file mode 100644 index 0000000000..541fb868e5 --- /dev/null +++ b/packages/nitro-v2-vite-plugin/src/index.ts @@ -0,0 +1,174 @@ +import { build, copyPublicAssets, createNitro, prepare } from 'nitropack' +import { dirname, resolve } from 'pathe' + +import type { PluginOption, Rollup } from 'vite' +import type { NitroConfig } from 'nitropack' + +let ssrBundle: Rollup.OutputBundle +let ssrEntryFile: string + +export function nitroV2Plugin(nitroConfig?: NitroConfig): Array { + return [ + { + name: 'tanstack-nitro-v2-vite-plugin', + + generateBundle: { + handler(_options, bundle) { + if (this.environment.name !== 'ssr') { + return + } + + // find entry point of ssr bundle + let entryFile: string | undefined + for (const [_name, file] of Object.entries(bundle)) { + if (file.type === 'chunk') { + if (file.isEntry) { + if (entryFile !== undefined) { + this.error( + `Multiple entry points found for service "${this.environment.name}". Only one entry point is allowed.`, + ) + } + entryFile = file.fileName + } + } + } + if (entryFile === undefined) { + this.error( + `No entry point found for service "${this.environment.name}".`, + ) + } + ssrEntryFile = entryFile! + ssrBundle = bundle + }, + }, + + async config(_, env) { + if (env.command !== 'build') { + return + } + + return { + environments: { + ssr: { + consumer: 'server', + build: { + ssr: true, + // we don't write to the file system as the below 'capture-output' plugin will + // capture the output and write it to the virtual file system + write: false, + copyPublicDir: false, + commonjsOptions: { + include: [/node_modules/], + }, + }, + }, + }, + builder: { + sharedPlugins: true, + async buildApp(builder) { + const client = builder.environments.client + const server = builder.environments.ssr + + if (!client) { + throw new Error('Client environment not found') + } + + if (!server) { + throw new Error('SSR environment not found') + } + + await builder.build(client) + await builder.build(server) + + const virtualEntry = '#tanstack/start/entry' + const config: NitroConfig = { + ...nitroConfig, + publicAssets: [ + { + dir: client.config.build.outDir, + baseURL: '/', + maxAge: 31536000, // 1 year + }, + ], + renderer: virtualEntry, + rollupConfig: { + ...nitroConfig?.rollupConfig, + plugins: [virtualBundlePlugin(ssrBundle) as any], + }, + virtual: { + ...nitroConfig?.virtual, + [virtualEntry]: `import { fromWebHandler } from 'h3' + import handler from '${ssrEntryFile}' + export default fromWebHandler(handler.fetch)`, + }, + } + + const nitro = await createNitro(config) + + await prepare(nitro) + await copyPublicAssets(nitro) + await build(nitro) + + await nitro.close() + }, + }, + } + }, + }, + ] +} + +function virtualBundlePlugin(bundle: Rollup.OutputBundle): Rollup.Plugin { + type VirtualModule = { code: string; map: string | null } + let _modules: Map | null = null + + // lazy initialize _modules since at the time of plugin creation, the bundles are not available yet + const getModules = () => { + if (_modules) { + return _modules + } + _modules = new Map() + // group chunks and source maps + for (const [fileName, content] of Object.entries(bundle)) { + if (content.type === 'chunk') { + const virtualModule: VirtualModule = { + code: content.code, + map: null, + } + const maybeMap = bundle[`${fileName}.map`] + if (maybeMap && maybeMap.type === 'asset') { + virtualModule.map = maybeMap.source as string + } + _modules.set(fileName, virtualModule) + _modules.set(resolve(fileName), virtualModule) + } + } + return _modules + } + + return { + name: 'virtual-bundle', + resolveId(id, importer) { + const modules = getModules() + if (modules.has(id)) { + return resolve(id) + } + + if (importer) { + const resolved = resolve(dirname(importer), id) + if (modules.has(resolved)) { + return resolved + } + } + return null + }, + load(id) { + const modules = getModules() + const m = modules.get(id) + if (!m) { + return null + } + return m + }, + } +} diff --git a/packages/nitro-v2-vite-plugin/tsconfig.json b/packages/nitro-v2-vite-plugin/tsconfig.json new file mode 100644 index 0000000000..bd398a8728 --- /dev/null +++ b/packages/nitro-v2-vite-plugin/tsconfig.json @@ -0,0 +1,8 @@ +{ + "extends": "../../tsconfig.json", + "include": ["src", "vite.config.ts", "tests"], + "exclude": ["tests/test-files/**", "tests/snapshots/**"], + "compilerOptions": { + "jsx": "react-jsx" + } +} diff --git a/packages/solid-start-plugin/vite.config.ts b/packages/nitro-v2-vite-plugin/vite.config.ts similarity index 53% rename from packages/solid-start-plugin/vite.config.ts rename to packages/nitro-v2-vite-plugin/vite.config.ts index 2c711fd181..75bb759998 100644 --- a/packages/solid-start-plugin/vite.config.ts +++ b/packages/nitro-v2-vite-plugin/vite.config.ts @@ -1,21 +1,13 @@ import { defineConfig, mergeConfig } from 'vitest/config' import { tanstackViteConfig } from '@tanstack/config/vite' -import packageJson from './package.json' -const config = defineConfig({ - test: { - name: packageJson.name, - dir: './tests', - watch: false, - typecheck: { enabled: true }, - }, -}) +const config = defineConfig({}) export default mergeConfig( config, tanstackViteConfig({ entry: './src/index.ts', srcDir: './src', - outDir: './dist', + exclude: ['./src/tests/'], }), ) diff --git a/packages/react-router-devtools/package.json b/packages/react-router-devtools/package.json index a60807bc08..3469743e9a 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.21", "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..d8f24b5b1d 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.21", "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..6aa5f655d2 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.21", "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({ ` + return `` }) }, dehydrate: async () => { @@ -106,12 +105,21 @@ export function attachRouterServerSsrUtils( _dehydrated = true const p = createControlledPromise() + const trackPlugins = { didRun: false } + const plugins = + ( + router.options.serializationAdapters as + | Array + | undefined + )?.map((t) => makeSsrSerovalPlugin(t, trackPlugins)) ?? [] crossSerializeStream(dehydratedRouter, { - refs: serializationRefs, - // TODO make plugins configurable - plugins: [ReadableStreamPlugin, ShallowErrorPlugin], + refs: new Map(), + plugins: [...plugins, ...defaultSerovalPlugins], onSerialize: (data, initial) => { - const serialized = initial ? `${GLOBAL_TSR}["router"]=` + data : data + let serialized = initial ? GLOBAL_TSR + '.router=' + data : data + if (trackPlugins.didRun) { + serialized = GLOBAL_TSR + '.p(()=>' + serialized + ')' + } router.serverSsr!.injectScript(() => serialized) }, scopeId: SCOPE_ID, diff --git a/packages/router-core/src/ssr/tsrScript.ts b/packages/router-core/src/ssr/tsrScript.ts index bd8c2a0e0f..c399733fd8 100644 --- a/packages/router-core/src/ssr/tsrScript.ts +++ b/packages/router-core/src/ssr/tsrScript.ts @@ -1,7 +1,11 @@ self.$_TSR = { - c: () => { + c() { document.querySelectorAll('.\\$tsr').forEach((o) => { o.remove() }) }, + p(script) { + !this.initialized ? this.buffer.push(script) : script() + }, + buffer: [], } diff --git a/packages/router-core/src/utils.ts b/packages/router-core/src/utils.ts index d446509498..67a30649ae 100644 --- a/packages/router-core/src/utils.ts +++ b/packages/router-core/src/utils.ts @@ -411,47 +411,6 @@ export function createControlledPromise(onResolve?: (value: T) => void) { return controlledPromise } -/** - * - * @deprecated use `jsesc` instead - */ -export function escapeJSON(jsonString: string) { - return jsonString - .replace(/\\/g, '\\\\') // Escape backslashes - .replace(/'/g, "\\'") // Escape single quotes - .replace(/"/g, '\\"') // Escape double quotes -} - -export function shallow(objA: T, objB: T) { - if (Object.is(objA, objB)) { - return true - } - - if ( - typeof objA !== 'object' || - objA === null || - typeof objB !== 'object' || - objB === null - ) { - return false - } - - const keysA = Object.keys(objA) - if (keysA.length !== Object.keys(objB).length) { - return false - } - - for (const item of keysA) { - if ( - !Object.prototype.hasOwnProperty.call(objB, item) || - !Object.is(objA[item as keyof T], objB[item as keyof T]) - ) { - return false - } - } - return true -} - export function isModuleNotFoundError(error: any): boolean { // chrome: "Failed to fetch dynamically imported module: http://localhost:5173/src/routes/posts.index.tsx?tsr-split" // firefox: "error loading dynamically imported module: http://localhost:5173/src/routes/posts.index.tsx?tsr-split" diff --git a/packages/router-core/tests/match-by-path.test.ts b/packages/router-core/tests/match-by-path.test.ts index afc1db3f54..51466ab0d5 100644 --- a/packages/router-core/tests/match-by-path.test.ts +++ b/packages/router-core/tests/match-by-path.test.ts @@ -3,20 +3,20 @@ import { matchByPath } from '../src' describe('default path matching', () => { it.each([ - ['', '', '', {}], - ['', '/', '', {}], - ['', '', '/', {}], - ['', '/', '/', {}], - ['/', '/', '/', {}], - ['/', '/a', '/a', {}], - ['/', '/a/b', '/a/b', {}], - ['/', '/a', '/a/', {}], - ['/', '/a/', '/a/', {}], - ['/', '/a/', '/a', undefined], - ['/', '/b', '/a', undefined], - ])('static %s %s => %s', (base, from, to, result) => { + ['', '', {}], + ['/', '', {}], + ['', '/', {}], + ['/', '/', {}], + ['/', '/', {}], + ['/a', '/a', {}], + ['/a/b', '/a/b', {}], + ['/a', '/a/', {}], + ['/a/', '/a/', {}], + ['/a/', '/a', undefined], + ['/b', '/a', undefined], + ])('static %s %s => %s', (from, to, result) => { expect( - matchByPath(base, from, { to, caseSensitive: true, fuzzy: false }), + matchByPath(from, { to, caseSensitive: true, fuzzy: false }), ).toEqual(result) }) @@ -27,7 +27,7 @@ describe('default path matching', () => { ['/a/1/b/2', '/a/$id/b/$id', { id: '2' }], ])('params %s => %s', (from, to, result) => { expect( - matchByPath('/', from, { to, caseSensitive: true, fuzzy: false }), + matchByPath(from, { to, caseSensitive: true, fuzzy: false }), ).toEqual(result) }) @@ -35,14 +35,13 @@ describe('default path matching', () => { // in the value: basically everything except / and % expect( matchByPath( - '/', '/a/@&é"\'(§è!çà)-_°^¨$*€£`ù=+:;.,?~<>|î©#0123456789\\😀}{', { to: '/a/$id' }, ), ).toEqual({ id: '@&é"\'(§è!çà)-_°^¨$*€£`ù=+:;.,?~<>|î©#0123456789\\😀}{' }) // in the key: basically everything except / and % and $ expect( - matchByPath('/', '/a/1', { + matchByPath('/a/1', { to: '/a/$@&é"\'(§è!çà)-_°^¨*€£`ù=+:;.,?~<>|î©#0123456789\\😀}{', }), ).toEqual({ '@&é"\'(§è!çà)-_°^¨*€£`ù=+:;.,?~<>|î©#0123456789\\😀}{': '1' }) @@ -60,7 +59,7 @@ describe('default path matching', () => { ['/a/1/b/2', '/a/{-$id}/b/{-$id}', { id: '2' }], ])('optional %s => %s', (from, to, result) => { expect( - matchByPath('/', from, { to, caseSensitive: true, fuzzy: false }), + matchByPath(from, { to, caseSensitive: true, fuzzy: false }), ).toEqual(result) }) @@ -71,7 +70,7 @@ describe('default path matching', () => { ['/a/b/c', '/a/$/foo', { _splat: 'b/c', '*': 'b/c' }], ])('wildcard %s => %s', (from, to, result) => { expect( - matchByPath('/', from, { to, caseSensitive: true, fuzzy: false }), + matchByPath(from, { to, caseSensitive: true, fuzzy: false }), ).toEqual(result) }) }) @@ -91,7 +90,7 @@ describe('case insensitive path matching', () => { ['/', '/b', '/A', undefined], ])('static %s %s => %s', (base, from, to, result) => { expect( - matchByPath(base, from, { to, caseSensitive: false, fuzzy: false }), + matchByPath(from, { to, caseSensitive: false, fuzzy: false }), ).toEqual(result) }) @@ -102,7 +101,7 @@ describe('case insensitive path matching', () => { ['/a/1/b/2', '/A/$id/B/$id', { id: '2' }], ])('params %s => %s', (from, to, result) => { expect( - matchByPath('/', from, { to, caseSensitive: false, fuzzy: false }), + matchByPath(from, { to, caseSensitive: false, fuzzy: false }), ).toEqual(result) }) @@ -118,7 +117,7 @@ describe('case insensitive path matching', () => { ['/a/1/b/2', '/A/{-$id}/B/{-$id}', { id: '2' }], ])('optional %s => %s', (from, to, result) => { expect( - matchByPath('/', from, { to, caseSensitive: false, fuzzy: false }), + matchByPath(from, { to, caseSensitive: false, fuzzy: false }), ).toEqual(result) }) @@ -129,7 +128,7 @@ describe('case insensitive path matching', () => { ['/a/b/c', '/A/$/foo', { _splat: 'b/c', '*': 'b/c' }], ])('wildcard %s => %s', (from, to, result) => { expect( - matchByPath('/', from, { to, caseSensitive: false, fuzzy: false }), + matchByPath(from, { to, caseSensitive: false, fuzzy: false }), ).toEqual(result) }) }) @@ -153,9 +152,9 @@ describe('fuzzy path matching', () => { ['/', '/b', '/a', undefined], ['/', '/a', '/b', undefined], ])('static %s %s => %s', (base, from, to, result) => { - expect( - matchByPath(base, from, { to, fuzzy: true, caseSensitive: true }), - ).toEqual(result) + expect(matchByPath(from, { to, fuzzy: true, caseSensitive: true })).toEqual( + result, + ) }) it.each([ @@ -165,9 +164,9 @@ describe('fuzzy path matching', () => { ['/a/1/b/2', '/a/$id/b/$other', { id: '1', other: '2' }], ['/a/1/b/2/c', '/a/$id/b/$other', { id: '1', other: '2', '**': 'c' }], ])('params %s => %s', (from, to, result) => { - expect( - matchByPath('/', from, { to, fuzzy: true, caseSensitive: true }), - ).toEqual(result) + expect(matchByPath(from, { to, fuzzy: true, caseSensitive: true })).toEqual( + result, + ) }) it.each([ @@ -181,9 +180,9 @@ describe('fuzzy path matching', () => { ['/a/b/2/d', '/a/{-$id}/b/{-$other}', { other: '2', '**': 'd' }], ['/a/1/b/2/c', '/a/{-$id}/b/{-$other}', { id: '1', other: '2', '**': 'c' }], ])('optional %s => %s', (from, to, result) => { - expect( - matchByPath('/', from, { to, fuzzy: true, caseSensitive: true }), - ).toEqual(result) + expect(matchByPath(from, { to, fuzzy: true, caseSensitive: true })).toEqual( + result, + ) }) it.each([ @@ -192,8 +191,8 @@ describe('fuzzy path matching', () => { ['/a', '/a/$', { _splat: '', '*': '' }], ['/a/b/c/d', '/a/$/foo', { _splat: 'b/c/d', '*': 'b/c/d' }], ])('wildcard %s => %s', (from, to, result) => { - expect( - matchByPath('/', from, { to, fuzzy: true, caseSensitive: true }), - ).toEqual(result) + expect(matchByPath(from, { to, fuzzy: true, caseSensitive: true })).toEqual( + result, + ) }) }) diff --git a/packages/router-core/tests/optional-path-params-clean.test.ts b/packages/router-core/tests/optional-path-params-clean.test.ts index 57f7d50f2a..f9cbd0c4fd 100644 --- a/packages/router-core/tests/optional-path-params-clean.test.ts +++ b/packages/router-core/tests/optional-path-params-clean.test.ts @@ -99,43 +99,43 @@ describe('Optional Path Parameters - Clean Comprehensive Tests', () => { describe('matchPathname', () => { it('should match optional dynamic params when present', () => { - const result = matchPathname('/', '/posts/tech', { + const result = matchPathname('/posts/tech', { to: '/posts/{-$category}', }) expect(result).toEqual({ category: 'tech' }) }) it('should match optional dynamic params when absent', () => { - const result = matchPathname('/', '/posts', { + const result = matchPathname('/posts', { to: '/posts/{-$category}', }) expect(result).toEqual({}) }) it('should handle multiple optional dynamic params', () => { - const result1 = matchPathname('/', '/posts/tech/hello', { + const result1 = matchPathname('/posts/tech/hello', { to: '/posts/{-$category}/{-$slug}', }) expect(result1).toEqual({ category: 'tech', slug: 'hello' }) - const result2 = matchPathname('/', '/posts/tech', { + const result2 = matchPathname('/posts/tech', { to: '/posts/{-$category}/{-$slug}', }) expect(result2).toEqual({ category: 'tech' }) - const result3 = matchPathname('/', '/posts', { + const result3 = matchPathname('/posts', { to: '/posts/{-$category}/{-$slug}', }) expect(result3).toEqual({}) }) it('should handle mixed required and optional dynamic params', () => { - const result1 = matchPathname('/', '/posts/tech/user/123', { + const result1 = matchPathname('/posts/tech/user/123', { to: '/posts/{-$category}/user/$id', }) expect(result1).toEqual({ category: 'tech', id: '123' }) - const result2 = matchPathname('/', '/posts/user/123', { + const result2 = matchPathname('/posts/user/123', { to: '/posts/{-$category}/user/$id', }) expect(result2).toEqual({ id: '123' }) diff --git a/packages/router-core/tests/optional-path-params.test.ts b/packages/router-core/tests/optional-path-params.test.ts index a34c54bb2f..bf54607300 100644 --- a/packages/router-core/tests/optional-path-params.test.ts +++ b/packages/router-core/tests/optional-path-params.test.ts @@ -389,7 +389,7 @@ describe('Optional Path Parameters', () => { expectedMatchedParams: {}, }, ])('$name', ({ input, matchingOptions, expectedMatchedParams }) => { - expect(matchPathname('/', input, matchingOptions)).toStrictEqual( + expect(matchPathname(input, matchingOptions)).toStrictEqual( expectedMatchedParams, ) }) @@ -422,16 +422,16 @@ describe('Optional Path Parameters', () => { ] tests.forEach(({ input, pattern, expected }) => { - expect(matchPathname('/', input, { to: pattern })).toEqual(expected) + expect(matchPathname(input, { to: pattern })).toEqual(expected) }) }) it('should prioritize more specific routes over optional param routes', () => { // Test that /posts/featured matches a static route, not optional param route - const staticMatch = matchPathname('/', '/posts/featured', { + const staticMatch = matchPathname('/posts/featured', { to: '/posts/featured', }) - const optionalMatch = matchPathname('/', '/posts/featured', { + const optionalMatch = matchPathname('/posts/featured', { to: '/posts/{-$category}', }) @@ -448,7 +448,7 @@ describe('Optional Path Parameters', () => { _splat: 'extra/path', } - expect(matchPathname('/', input, { to: pattern })).toEqual(expected) + expect(matchPathname(input, { to: pattern })).toEqual(expected) }) }) }) diff --git a/packages/router-core/tests/path.test.ts b/packages/router-core/tests/path.test.ts index 2a241bcb77..96458b4259 100644 --- a/packages/router-core/tests/path.test.ts +++ b/packages/router-core/tests/path.test.ts @@ -7,95 +7,12 @@ import { interpolatePath, matchPathname, parsePathname, - removeBasepath, removeTrailingSlash, resolvePath, trimPathLeft, } from '../src/path' import type { Segment as PathSegment } from '../src/path' -describe('removeBasepath', () => { - it.each([ - { - name: '`/` should leave pathname as-is', - basepath: '/', - pathname: '/path', - expected: '/path', - }, - { - name: 'should return empty string if basepath is the same as pathname', - basepath: '/path', - pathname: '/path', - expected: '', - }, - { - name: 'should remove basepath from the beginning of the pathname', - basepath: '/app', - pathname: '/app/path/app', - expected: '/path/app', - }, - { - name: 'should remove multisegment basepath from the beginning of the pathname', - basepath: '/app/new', - pathname: '/app/new/path/app/new', - expected: '/path/app/new', - }, - { - name: 'should remove basepath only in case it matches segments completely', - basepath: '/app', - pathname: '/application', - expected: '/application', - }, - { - name: 'should remove multisegment basepath only in case it matches segments completely', - basepath: '/app/new', - pathname: '/app/new-application', - expected: '/app/new-application', - }, - ])('$name', ({ basepath, pathname, expected }) => { - expect(removeBasepath(basepath, pathname)).toBe(expected) - }) - describe('case sensitivity', () => { - describe('caseSensitive = true', () => { - it.each([ - { - name: 'should not remove basepath from the beginning of the pathname', - basepath: '/app', - pathname: '/App/path/App', - expected: '/App/path/App', - }, - { - name: 'should not remove basepath from the beginning of the pathname with multiple segments', - basepath: '/app/New', - pathname: '/App/New/path/App', - expected: '/App/New/path/App', - }, - ])('$name', ({ basepath, pathname, expected }) => { - expect(removeBasepath(basepath, pathname, true)).toBe(expected) - }) - }) - - describe('caseSensitive = false', () => { - it.each([ - { - name: 'should remove basepath from the beginning of the pathname', - basepath: '/App', - pathname: '/app/path/app', - expected: '/path/app', - }, - { - name: 'should remove multisegment basepath from the beginning of the pathname', - basepath: '/App/New', - pathname: '/app/new/path/app', - expected: '/path/app', - }, - ])('$name', ({ basepath, pathname, expected }) => { - expect(removeBasepath(basepath, pathname, false)).toBe(expected) - }) - }) - }) -}) - describe.each([{ basepath: '/' }, { basepath: '/app' }, { basepath: '/app/' }])( 'removeTrailingSlash with basepath $basepath', ({ basepath }) => { @@ -167,39 +84,32 @@ describe.each([{ basepath: '/' }, { basepath: '/app' }, { basepath: '/app/' }])( describe('resolvePath', () => { describe.each([ - ['/', '/', '/', '/'], - ['/', '/', '/a', '/a'], - ['/', '/', 'a/', '/a'], - ['/', '/', '/a/b', '/a/b'], - ['/', 'a', 'b', '/a/b'], - ['/a/b', 'c', '/a/b/c', '/a/b/c'], - ['/a/b', '/', 'c', '/a/b/c'], - ['/a/b', '/', './c', '/a/b/c'], - ['/', '/', 'a/b', '/a/b'], - ['/', '/', './a/b', '/a/b'], - ['/', '/a/b/c', 'd', '/a/b/c/d'], - ['/', '/a/b/c', './d', '/a/b/c/d'], - ['/', '/a/b/c', './../d', '/a/b/d'], - ['/', '/a/b/c/d', './../d', '/a/b/c/d'], - ['/', '/a/b/c', '../../d', '/a/d'], - ['/', '/a/b/c', '../d', '/a/b/d'], - ['/', '/a/b/c', '..', '/a/b'], - ['/', '/a/b/c', '../..', '/a'], - ['/', '/a/b/c', '../../..', '/'], - ['/', '/a/b/c/', '../../..', '/'], - ['/products', '/', '/products-list', '/products/products-list'], - ['/basepath', '/products', '.', '/basepath/products'], - ])('resolves correctly', (base, a, b, eq) => { - it(`Base: ${base} - ${a} to ${b} === ${eq}`, () => { - expect(resolvePath({ basepath: base, base: a, to: b })).toEqual(eq) + ['/', '/', '/'], + ['/', '/a', '/a'], + ['/', 'a/', '/a'], + ['/', '/a/b', '/a/b'], + ['/a', 'b', '/a/b'], + ['/', 'a/b', '/a/b'], + ['/', './a/b', '/a/b'], + ['/a/b/c', 'd', '/a/b/c/d'], + ['/a/b/c', './d', '/a/b/c/d'], + ['/a/b/c', './../d', '/a/b/d'], + ['/a/b/c/d', './../d', '/a/b/c/d'], + ['/a/b/c', '../../d', '/a/d'], + ['/a/b/c', '../d', '/a/b/d'], + ['/a/b/c', '..', '/a/b'], + ['/a/b/c', '../..', '/a'], + ['/a/b/c', '../../..', '/'], + ['/a/b/c/', '../../..', '/'], + ])('resolves correctly', (a, b, eq) => { + it(`${a} to ${b} === ${eq}`, () => { + expect(resolvePath({ base: a, to: b })).toEqual(eq) }) - it(`Base: ${base} - ${a}/ to ${b} === ${eq} (trailing slash)`, () => { - expect(resolvePath({ basepath: base, base: a + '/', to: b })).toEqual(eq) + it(`${a}/ to ${b} === ${eq} (trailing slash)`, () => { + expect(resolvePath({ base: a + '/', to: b })).toEqual(eq) }) - it(`Base: ${base} - ${a}/ to ${b}/ === ${eq} (trailing slash + trailing slash)`, () => { - expect( - resolvePath({ basepath: base, base: a + '/', to: b + '/' }), - ).toEqual(eq) + it(`${a}/ to ${b}/ === ${eq} (trailing slash + trailing slash)`, () => { + expect(resolvePath({ base: a + '/', to: b + '/' })).toEqual(eq) }) }) describe('trailingSlash', () => { @@ -207,7 +117,6 @@ describe('resolvePath', () => { it('keeps trailing slash', () => { expect( resolvePath({ - basepath: '/', base: '/a/b/c', to: 'd/', trailingSlash: 'always', @@ -217,7 +126,6 @@ describe('resolvePath', () => { it('adds trailing slash', () => { expect( resolvePath({ - basepath: '/', base: '/a/b/c', to: 'd', trailingSlash: 'always', @@ -229,7 +137,6 @@ describe('resolvePath', () => { it('removes trailing slash', () => { expect( resolvePath({ - basepath: '/', base: '/a/b/c', to: 'd/', trailingSlash: 'never', @@ -239,7 +146,6 @@ describe('resolvePath', () => { it('does not add trailing slash', () => { expect( resolvePath({ - basepath: '/', base: '/a/b/c', to: 'd', trailingSlash: 'never', @@ -251,7 +157,6 @@ describe('resolvePath', () => { it('keeps trailing slash', () => { expect( resolvePath({ - basepath: '/', base: '/a/b/c', to: 'd/', trailingSlash: 'preserve', @@ -261,7 +166,6 @@ describe('resolvePath', () => { it('does not add trailing slash', () => { expect( resolvePath({ - basepath: '/', base: '/a/b/c', to: 'd', trailingSlash: 'preserve', @@ -294,11 +198,9 @@ describe('resolvePath', () => { const candidate = base + trimPathLeft(to) expect( resolvePath({ - basepath: '/', base, to: candidate, trailingSlash: 'never', - caseSensitive: false, }), ).toEqual(candidate) }) @@ -324,11 +226,9 @@ describe('resolvePath', () => { const candidate = base + trimPathLeft(to) expect( resolvePath({ - basepath: '/', base, to: candidate, trailingSlash: 'never', - caseSensitive: false, }), ).toEqual(candidate) }) @@ -571,63 +471,6 @@ describe('interpolatePath', () => { }) describe('matchPathname', () => { - describe('basepath matching', () => { - it.each([ - { - name: 'should match when the input is the same as the basepath', - basepath: '/basepath', - input: '/basepath', - matchingOptions: { - to: '/', - }, - expectedMatchedParams: {}, - }, - { - name: 'should match when the input starts with the basepath and `to` is set to the remaining', - basepath: '/basepath', - input: '/basepath/abc', - matchingOptions: { - to: '/abc', - }, - expectedMatchedParams: {}, - }, - { - name: 'should not match when the input is `/` and does not start with the basepath', - basepath: '/basepath', - input: '/', - matchingOptions: { - to: '/', - }, - expectedMatchedParams: undefined, - }, - { - name: 'should not match when the input completely does not start with the basepath', - basepath: '/basepath', - input: '/abc', - matchingOptions: { - to: '/abc', - }, - expectedMatchedParams: undefined, - }, - { - name: 'should not match when the input only partially matches the basepath', - basepath: '/base', - input: '/basepath/abc', - matchingOptions: { - to: '/abc', - }, - expectedMatchedParams: undefined, - }, - ])( - '$name', - ({ basepath, input, matchingOptions, expectedMatchedParams }) => { - expect(matchPathname(basepath, input, matchingOptions)).toStrictEqual( - expectedMatchedParams, - ) - }, - ) - }) - describe('path param(s) matching', () => { it.each([ { @@ -703,7 +546,7 @@ describe('matchPathname', () => { }, }, ])('$name', ({ input, matchingOptions, expectedMatchedParams }) => { - expect(matchPathname('/', input, matchingOptions)).toStrictEqual( + expect(matchPathname(input, matchingOptions)).toStrictEqual( expectedMatchedParams, ) }) @@ -767,7 +610,7 @@ describe('matchPathname', () => { }, }, ])('$name', ({ input, matchingOptions, expectedMatchedParams }) => { - expect(matchPathname('/', input, matchingOptions)).toStrictEqual( + expect(matchPathname(input, matchingOptions)).toStrictEqual( expectedMatchedParams, ) }) @@ -826,7 +669,7 @@ describe('matchPathname', () => { }, }, ])('$name', ({ input, matchingOptions, expectedMatchedParams }) => { - expect(matchPathname('/', input, matchingOptions)).toStrictEqual( + expect(matchPathname(input, matchingOptions)).toStrictEqual( expectedMatchedParams, ) }) diff --git a/packages/router-core/tests/processRouteTree.test.ts b/packages/router-core/tests/processRouteTree.test.ts index 67ffc5a260..b8197a9883 100644 --- a/packages/router-core/tests/processRouteTree.test.ts +++ b/packages/router-core/tests/processRouteTree.test.ts @@ -302,7 +302,6 @@ describe('processRouteTree', () => { // Test actual path matching for `/foo` const matchResult = getMatchedRoutes({ pathname: '/foo', - basepath: '/', caseSensitive: false, routesByPath: result.routesByPath, routesById: result.routesById, diff --git a/packages/router-devtools-core/package.json b/packages/router-devtools-core/package.json index fc91c7e609..757aeb4d85 100644 --- a/packages/router-devtools-core/package.json +++ b/packages/router-devtools-core/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/router-devtools-core", - "version": "1.131.27", + "version": "1.132.0-alpha.21", "description": "Modern and scalable routing for Web applications", "author": "Tanner Linsley", "license": "MIT", @@ -67,7 +67,7 @@ "solid-js": "^1.9.5" }, "devDependencies": { - "vite-plugin-solid": "^2.11.6" + "vite-plugin-solid": "^2.11.8" }, "peerDependencies": { "tiny-invariant": "^1.3.3", diff --git a/packages/router-devtools-core/src/BaseTanStackRouterDevtoolsPanel.tsx b/packages/router-devtools-core/src/BaseTanStackRouterDevtoolsPanel.tsx index a84f318bc6..830e5eda3e 100644 --- a/packages/router-devtools-core/src/BaseTanStackRouterDevtoolsPanel.tsx +++ b/packages/router-devtools-core/src/BaseTanStackRouterDevtoolsPanel.tsx @@ -98,6 +98,8 @@ function RouteComp({ routerState: Accessor< RouterState< Route< + any, + any, any, '/', '/', diff --git a/packages/router-devtools/package.json b/packages/router-devtools/package.json index 6f12d1c94b..fc544d5b30 100644 --- a/packages/router-devtools/package.json +++ b/packages/router-devtools/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/router-devtools", - "version": "1.131.27", + "version": "1.132.0-alpha.21", "description": "Modern and scalable routing for React applications", "author": "Tanner Linsley", "license": "MIT", diff --git a/packages/router-generator/package.json b/packages/router-generator/package.json index 39c4c335a0..8fcbd1fd4c 100644 --- a/packages/router-generator/package.json +++ b/packages/router-generator/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/router-generator", - "version": "1.131.27", + "version": "1.132.0-alpha.21", "description": "Modern and scalable routing for React applications", "author": "Tanner Linsley", "license": "MIT", diff --git a/packages/router-generator/src/generator.ts b/packages/router-generator/src/generator.ts index 122976d417..1880d0adf3 100644 --- a/packages/router-generator/src/generator.ts +++ b/packages/router-generator/src/generator.ts @@ -1,6 +1,6 @@ import path from 'node:path' import * as fsp from 'node:fs/promises' -import { mkdirSync } from 'node:fs' +import { existsSync, mkdirSync } from 'node:fs' import crypto from 'node:crypto' import { deepEqual, rootRouteId } from '@tanstack/router-core' import { logging } from './logger' @@ -194,7 +194,7 @@ export class Generator { this.logger = logging({ disabled: this.config.disableLogging }) this.root = opts.root this.fs = opts.fs || DefaultFileSystem - this.generatedRouteTreePath = path.resolve(this.config.generatedRouteTree) + this.generatedRouteTreePath = this.getGeneratedRouteTreePath() this.targetTemplate = getTargetTemplate(this.config) this.routesDirectoryPath = this.getRoutesDirectoryPath() @@ -212,6 +212,22 @@ export class Generator { }) } + private getGeneratedRouteTreePath() { + const generatedRouteTreePath = path.isAbsolute( + this.config.generatedRouteTree, + ) + ? this.config.generatedRouteTree + : path.resolve(this.root, this.config.generatedRouteTree) + + const generatedRouteTreeDir = path.dirname(generatedRouteTreePath) + + if (!existsSync(generatedRouteTreeDir)) { + mkdirSync(generatedRouteTreeDir, { recursive: true }) + } + + return generatedRouteTreePath + } + private getRoutesDirectoryPath() { return path.isAbsolute(this.config.routesDirectory) ? this.config.routesDirectory diff --git a/packages/router-generator/tests/generator.test.ts b/packages/router-generator/tests/generator.test.ts index dbd5e49540..1c4d921f14 100644 --- a/packages/router-generator/tests/generator.test.ts +++ b/packages/router-generator/tests/generator.test.ts @@ -270,4 +270,56 @@ describe('generator works', async () => { await postprocess(folderName) }, ) + + it('should create directory for routeTree if it does not exist', async () => { + const folderName = 'only-root' + const folderRoot = makeFolderDir(folderName) + let pathCreated = false + + const config = await setupConfig(folderName) + + rewriteConfigByFolderName(folderName, config) + + await preprocess(folderName) + config.generatedRouteTree = join( + folderRoot, + 'generated', + '/routeTree.gen.ts', + ) + const generator = new Generator({ config, root: folderRoot }) + const error = shouldThrow(folderName) + if (error) { + try { + await generator.run() + } catch (e) { + expect(e).toBeInstanceOf(Error) + expect((e as Error).message.startsWith(error)).toBeTruthy() + } + } else { + await generator.run() + + const generatedRouteTree = await getRouteTreeFileText(config) + + await expect(generatedRouteTree).toMatchFileSnapshot( + join( + 'generator', + folderName, + `routeTree.generated.snapshot.${config.disableTypes ? 'js' : 'ts'}`, + ), + ) + + pathCreated = await fs.access(dirname(config.generatedRouteTree)).then( + () => true, + () => false, + ) + + await expect(pathCreated).toBe(true) + } + + await postprocess(folderName) + + if (pathCreated) { + await fs.rm(dirname(config.generatedRouteTree), { recursive: true }) + } + }) }) diff --git a/packages/router-generator/tests/generator/only-root/routeTree.generated.snapshot.ts b/packages/router-generator/tests/generator/only-root/routeTree.generated.snapshot.ts new file mode 100644 index 0000000000..7766df9832 --- /dev/null +++ b/packages/router-generator/tests/generator/only-root/routeTree.generated.snapshot.ts @@ -0,0 +1,35 @@ +/* eslint-disable */ + +// @ts-nocheck + +// noinspection JSUnusedGlobalSymbols + +// This file was automatically generated by TanStack Router. +// You should NOT make any changes in this file as it will be overwritten. +// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified. + +import { Route as rootRouteImport } from './../routes/__root' + +export interface FileRoutesByFullPath {} +export interface FileRoutesByTo {} +export interface FileRoutesById { + __root__: typeof rootRouteImport +} +export interface FileRouteTypes { + fileRoutesByFullPath: FileRoutesByFullPath + fullPaths: never + fileRoutesByTo: FileRoutesByTo + to: never + id: '__root__' + fileRoutesById: FileRoutesById +} +export interface RootRouteChildren {} + +declare module '@tanstack/react-router' { + interface FileRoutesByPath {} +} + +const rootRouteChildren: RootRouteChildren = {} +export const routeTree = rootRouteImport + ._addFileChildren(rootRouteChildren) + ._addFileTypes() diff --git a/packages/router-plugin/package.json b/packages/router-plugin/package.json index 33290cb717..951b7626ff 100644 --- a/packages/router-plugin/package.json +++ b/packages/router-plugin/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/router-plugin", - "version": "1.131.27", + "version": "1.132.0-alpha.21", "description": "Modern and scalable routing for React applications", "author": "Tanner Linsley", "license": "MIT", @@ -127,8 +127,8 @@ "peerDependencies": { "@rsbuild/core": ">=1.0.2", "@tanstack/react-router": "workspace:^", - "vite": ">=5.0.0 || >=6.0.0", - "vite-plugin-solid": "^2.11.2", + "vite": ">=5.0.0 || >=6.0.0 || >=7.0.0", + "vite-plugin-solid": "^2.11.8", "webpack": ">=5.92.0" }, "peerDependenciesMeta": { diff --git a/packages/router-plugin/src/core/router-generator-plugin.ts b/packages/router-plugin/src/core/router-generator-plugin.ts index b283348d57..475125ec71 100644 --- a/packages/router-plugin/src/core/router-generator-plugin.ts +++ b/packages/router-plugin/src/core/router-generator-plugin.ts @@ -66,23 +66,11 @@ export const unpluginRouterGeneratorFactory: UnpluginFactory< event, }) }, - async buildStart() { - await generate() - }, vite: { - configResolved() { + async configResolved() { initConfigAndGenerator() - }, - applyToEnvironment(environment) { - if (userConfig.plugin?.vite?.environmentName) { - return userConfig.plugin.vite.environmentName === environment.name - } - return true - }, - async buildStart() { await generate() }, - sharedDuringBuild: true, }, rspack(compiler) { initConfigAndGenerator() diff --git a/packages/router-ssr-query-core/package.json b/packages/router-ssr-query-core/package.json index 03b14ee5a3..07c49acdb3 100644 --- a/packages/router-ssr-query-core/package.json +++ b/packages/router-ssr-query-core/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/router-ssr-query-core", - "version": "1.131.27", + "version": "1.132.0-alpha.21", "description": "Modern and scalable routing for React applications", "author": "Tanner Linsley", "license": "MIT", diff --git a/packages/router-utils/package.json b/packages/router-utils/package.json index f1e872dc4e..f874a9ea44 100644 --- a/packages/router-utils/package.json +++ b/packages/router-utils/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/router-utils", - "version": "1.131.2", + "version": "1.132.0-alpha.9", "description": "Modern and scalable routing for React applications", "author": "Tanner Linsley", "license": "MIT", @@ -68,7 +68,9 @@ "@babel/parser": "^7.27.5", "@babel/preset-typescript": "^7.27.1", "ansis": "^4.1.0", - "diff": "^8.0.2" + "diff": "^8.0.2", + "fast-glob": "^3.3.3", + "pathe": "^2.0.3" }, "devDependencies": { "@babel/types": "^7.27.6", diff --git a/packages/router-utils/src/ast.ts b/packages/router-utils/src/ast.ts index 829471ad97..812824a121 100644 --- a/packages/router-utils/src/ast.ts +++ b/packages/router-utils/src/ast.ts @@ -8,10 +8,8 @@ export type ParseAstOptions = ParserOptions & { code: string } -export function parseAst({ - code, - ...opts -}: ParseAstOptions): ParseResult<_babel_types.File> { +export type ParseAstResult = ParseResult<_babel_types.File> +export function parseAst({ code, ...opts }: ParseAstOptions): ParseAstResult { return parse(code, { plugins: ['jsx', 'typescript', 'explicitResourceManagement'], sourceType: 'module', diff --git a/packages/router-utils/src/copy-files-plugin.ts b/packages/router-utils/src/copy-files-plugin.ts new file mode 100644 index 0000000000..13cfd31ec4 --- /dev/null +++ b/packages/router-utils/src/copy-files-plugin.ts @@ -0,0 +1,34 @@ +import { copyFile, mkdir } from 'node:fs/promises' +import { dirname, join } from 'pathe' +import fg from 'fast-glob' +import type { Plugin } from 'vite' + +export function copyFilesPlugin({ + fromDir, + toDir, + pattern = '**', +}: { + pattern?: string | Array + fromDir: string + toDir: string +}): Plugin { + return { + name: 'copy-files', + async writeBundle() { + const entries = await fg(pattern, { cwd: fromDir }) + if (entries.length === 0) { + throw new Error( + `No files found matching pattern "${pattern}" in directory "${fromDir}"`, + ) + } + + for (const entry of entries) { + const srcPath = join(fromDir, entry) + const destPath = join(toDir, entry) + // Ensure the destination directory exists + await mkdir(dirname(destPath), { recursive: true }) + await copyFile(srcPath, destPath) + } + }, + } +} diff --git a/packages/router-utils/src/index.ts b/packages/router-utils/src/index.ts index f238e8c695..85c3f38590 100644 --- a/packages/router-utils/src/index.ts +++ b/packages/router-utils/src/index.ts @@ -1,3 +1,5 @@ export { parseAst, generateFromAst } from './ast' -export type { ParseAstOptions, GeneratorResult } from './ast' +export type { ParseAstOptions, ParseAstResult, GeneratorResult } from './ast' export { logDiff } from './logger' + +export { copyFilesPlugin } from './copy-files-plugin' diff --git a/packages/router-vite-plugin/package.json b/packages/router-vite-plugin/package.json index 2827558b43..be41edbd4d 100644 --- a/packages/router-vite-plugin/package.json +++ b/packages/router-vite-plugin/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/router-vite-plugin", - "version": "1.131.27", + "version": "1.132.0-alpha.21", "description": "Modern and scalable routing for React applications", "author": "Tanner Linsley", "license": "MIT", diff --git a/packages/server-functions-plugin/package.json b/packages/server-functions-plugin/package.json index dc5876d26f..9502c6d66c 100644 --- a/packages/server-functions-plugin/package.json +++ b/packages/server-functions-plugin/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/server-functions-plugin", - "version": "1.131.2", + "version": "1.132.0-alpha.9", "description": "Modern and scalable routing for React applications", "author": "Tanner Linsley", "license": "MIT", diff --git a/packages/server-functions-plugin/src/index.ts b/packages/server-functions-plugin/src/index.ts index 8a396252ed..710fe0b2ba 100644 --- a/packages/server-functions-plugin/src/index.ts +++ b/packages/server-functions-plugin/src/index.ts @@ -8,11 +8,7 @@ import type { ReplacerFn, } from '@tanstack/directive-functions-plugin' -export type CreateRpcFn = ( - functionId: string, - serverBase: string, - splitImportFn?: string, -) => any +export type CreateRpcFn = (functionId: string, splitImportFn?: string) => any export type ServerFnPluginOpts = { /** diff --git a/packages/solid-router-devtools/package.json b/packages/solid-router-devtools/package.json index 4cb71c7e53..d0d567b829 100644 --- a/packages/solid-router-devtools/package.json +++ b/packages/solid-router-devtools/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/solid-router-devtools", - "version": "1.131.27", + "version": "1.132.0-alpha.21", "description": "Modern and scalable routing for Solid applications", "author": "Tanner Linsley", "license": "MIT", @@ -70,7 +70,7 @@ }, "devDependencies": { "solid-js": "^1.9.5", - "vite-plugin-solid": "^2.11.6" + "vite-plugin-solid": "^2.11.8" }, "peerDependencies": { "solid-js": "^1.9.5", diff --git a/packages/solid-router/package.json b/packages/solid-router/package.json index b8664d1cb5..33cfd60364 100644 --- a/packages/solid-router/package.json +++ b/packages/solid-router/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/solid-router", - "version": "1.131.27", + "version": "1.132.0-alpha.21", "description": "Modern and scalable routing for Solid applications", "author": "Tanner Linsley", "license": "MIT", @@ -114,7 +114,7 @@ "combinate": "^1.1.11", "eslint-plugin-solid": "^0.14.5", "solid-js": "^1.9.5", - "vite-plugin-solid": "^2.11.2", + "vite-plugin-solid": "^2.11.8", "zod": "^3.23.8" }, "peerDependencies": { diff --git a/packages/solid-router/src/ScriptOnce.tsx b/packages/solid-router/src/ScriptOnce.tsx index 7799f56a8c..681f5fd3cb 100644 --- a/packages/solid-router/src/ScriptOnce.tsx +++ b/packages/solid-router/src/ScriptOnce.tsx @@ -11,8 +11,8 @@ export function ScriptOnce({ return (