* fix(react-router): prevent hydration warning for async/defer scripts
Strip async, defer, and src attributes from script tags during client-side hydration to match the server-rendered output and prevent React hydration mismatch warnings.
* test(react-router): add unit and e2e tests for async script hydration
Adds unit tests to verify server output includes async/defer attributes, and e2e tests to verify no hydration warnings occur on the client.
---------
Co-authored-by: Manuel Schiller <manuel.schiller@caligano.de>
* fix: pass pathname to global request middleware in createStartHandler
The two `executeMiddleware` calls for global request middleware in
`createStartHandler` were missing the `pathname` property, causing it
to be `undefined` at runtime despite `RequestServerOptions` declaring
it as `pathname: string`.
- Add `pathname: url.pathname` to server function middleware execution
- Add `pathname: url.pathname` to page request middleware execution
The route-level middleware in `handleServerRoutes` already passes
`pathname` correctly.
Closes TanStack/router#6647
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* test: add regression test for pathname in global request middleware (#6647)
Add e2e tests to server-functions-global-middleware verifying that
pathname is correctly passed to global request middleware in
createStartHandler.
- Add pathnameMiddleware that captures pathname from server callback
- Add dedicated pathname-middleware route and test page
- Verify pathname value on both SSR and client-side navigation
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* refactor: remove unnecessary `as any` cast from pathname middleware test
The middleware type system correctly infers `requestMiddlewarePathname`
on the context, so the explicit cast is not needed.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* ci: apply automated fixes
---------
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
* fix: shared virtual module for code-split routes
When a route file has module-level bindings (variables, functions, classes) referenced by **both** split and non-split route properties, the bindings are duplicated — initialized independently in the reference file and in each virtual split file. This breaks singletons, causes double side effects, and wastes bundle size.
```tsx
const collection = { name: 'todos', preload: async () => {} }
export const Route = createFileRoute('/todos')({
loader: async () => {
await collection.preload()
}, // stays in reference
component: () => <div>{collection.name}</div>, // split to virtual
})
```
In this example, `collection` is initialized in **both** the reference file (because `loader` references it) and the `?tsr-split=component` virtual file (because the component references it). Two separate instances exist at runtime.
To solve this issue, this PR introduces a third virtual module `route.tsx?tsr-shared=1` that contains shared bindings. Both the reference and virtual files import from it.
When `sharedBindings` is empty (the common case — component-only helpers, loader-only code), no shared module exists and the system works exactly as today.
The reference transform runs first and will emit a static import of `?tsr-shared=1` **only when needed**. Since split chunks are only discovered via the reference file's emitted `import('...?tsr-split=...')`, the bundler will always process/evaluate the reference module first. Result: the shared module is evaluated once and then reused by any later-loaded split chunk.
* fix: optimize match retrieval by using a Map for previous matches
* feat: add strict false parameter handling and related routes
* replace params only when routeParams is fully parsed
---------
Co-authored-by: Nico Lynzaad <nlynzaad@zylangroup.com>
Co-authored-by: Nico Lynzaad <44094871+nlynzaad@users.noreply.github.com>
* add test to verify redirect
* handle redirect
* update tests
* cleanup unused code in decodePath
* use 308 instead of 302
* redirect is not relevant in spa mode
* fix: do not pass signal into server function
* fix test
* ci: apply automated fixes
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>