Skip to main content

Link

Type-safe navigation components and utilities for creating links in TanStack Router.

LinkOptions

Configuration options for link navigation.
string
required
The destination path. Can be absolute or relative.
string
The source path for type inference. Enables better autocomplete.
Record<string, any>
Path parameters for the destination route.
Search parameters for the destination route. Can be an object or updater function.
string | (prev) => string
URL hash for the destination.
any | (prev) => any
History state for the navigation.
boolean
Replace current history entry instead of pushing a new one.Default: false
boolean
Reset scroll position when navigating.Default: true
boolean
Wrap navigation in React.startTransition.Default: false
boolean | ViewTransitionOptions
Use View Transition API for navigation animation.
false | 'intent' | 'viewport' | 'render'
When to preload the destination route:
  • false - Don’t preload
  • 'intent' - Preload on hover/focus
  • 'viewport' - Preload when in viewport
  • 'render' - Preload immediately
number
Delay in milliseconds before preloading.Default: 50
boolean
Disable the link navigation.Default: false
string
Standard anchor target attribute (_blank, _self, etc.).
ActiveOptions
Options for determining when the link is active.
React.AnchorHTMLAttributes
Props to apply when the link is active.
React.AnchorHTMLAttributes
Props to apply when the link is inactive.

ActiveOptions

Options for determining link active state.
boolean
Match the path exactly.Default: false
boolean
Include hash in active matching.Default: false
Include search params in active matching.Default: false
The primary navigation component.

useLinkProps Hook

Generate props for custom link components.
Create custom link components with default props.
With custom component:
Programmatic navigation function.
Declarative navigation component.

linkOptions Helper

Type-safe link options without rendering.

Examples

Basic Navigation

Relative Navigation

Search Params

Preloading

Programmatic Navigation