Skip to content

redirect Type Error After Upgrade to v1.168.5 #7063

@SajiBeats

Description

@SajiBeats

Which project does this relate to?

Router

Describe the bug

Package: @tanstack/react-router
Versions affected: 1.168.5 (works in 1.166.3)

After upgrading @tanstack/react-router from 1.166.3 to 1.168.5, the redirect function no longer accepts href alone for external redirects.

Previously, external redirects worked correctly using:

if (condition) {
  redirect({ href: "http://external.com", throw: true });
}

However, after upgrading, TypeScript raises an error indicating that the to property is required.

Your Example Website or App

N/A — reproducible by installing @tanstack/react-router@1.168.5 and running tsc --noEmit on the route file that contains redirect function.

Steps to Reproduce the Bug or Issue

  1. Install @tanstack/react-router@1.166.3
  2. Use:
redirect({ href: "http://external.com", throw: true });

→ Works fine
3. Upgrade to @tanstack/react-router@1.168.5
4. Same code now results in a TypeScript error requiring to

Expected behavior

The redirect function should continue to support external redirects using only the href property (as in previous versions), or at least not require to when href is provided.

Screenshots or Videos

TypeScript error:

Property 'to' is missing in type '{ href: string; throw: true; }'

This suggests that to is now required even when performing an external redirect with href.

Platform

  • Router / Start Version: @tanstack/react-router@1.168.5 / @tanstack/react-start@1.167.10
  • Bundler: vite@7.3.0

Additional context

The upgrade was done to use the new server handlers feature:

createRouteFile("/path")({
  server: {
    handlers: {}
  }
})

This works as expected, but introduces the redirect typing issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions