Skip to main content
TanStack Router provides multiple ways to navigate between routes: declarative links, programmatic navigation, and redirect functions. The Link component provides type-safe navigation with automatic preloading:
string
required
The destination path. Can be absolute or relative:
object
Path parameters for the destination route:
Search parameters for the URL. Can be an object or updater function:
string
URL hash (without the #):
object
History state (not visible in URL):
string
The source route for type-safe relative navigation:
Use activeProps and inactiveProps to style links based on active state:
Or use activeOptions to customize when a link is considered active:

Preloading

false | 'intent' | 'viewport' | 'render'
Control when to preload the destination route:
  • false - No preloading
  • 'intent' - Preload on hover/touch (default)
  • 'viewport' - Preload when link enters viewport
  • 'render' - Preload immediately when rendered
number
default:"50"
Delay in milliseconds before preloading on hover.

Replace Navigation

boolean
default:"false"
Replace the current history entry instead of pushing a new one:
Disabled links render as spans and don’t navigate.

Programmatic Navigation

Use the useNavigate hook for programmatic navigation:
The navigate function accepts the same options as Link:
You can also navigate from route loaders:
The navigate function in loaders is deprecated. Use redirect() instead (see below).

Redirects

Use the redirect function to redirect during data loading:

Route-Specific Redirects

Each route has a redirect method for relative redirects:

Redirect Options

string
Source route for relative redirects (set automatically with route.redirect()).
string
required
Destination path.
object
Path parameters for the destination.
object
Search parameters for the destination.
string
URL hash for the destination.
boolean
default:"false"
Replace current history entry.
number
HTTP status code for server-side redirects.

History Navigation

Navigate through browser history:

History Methods

Relative Navigation

TanStack Router supports several relative navigation patterns:

Current Route

Parent Routes

Type-Safe Relative Navigation

Specify the from route for full type safety:

Router API

Access the router instance for advanced navigation:

View Transitions

Enable smooth transitions between routes:
Configure transition types:

Scroll Behavior

Hash Scrolling

Automatically scroll to elements with matching IDs:
Customize scroll behavior:

Scroll Restoration

Enable automatic scroll position restoration:

Next Steps

Search Params

Manage URL search parameters

Path Params

Extract and validate path parameters

Type Safety

Configure end-to-end type safety

Loaders

Load data before rendering routes