Link Component
TheLink component provides type-safe navigation with automatic preloading:
Link Props
string
required
The destination path. Can be absolute or relative:
object
Path parameters for the destination route:
object | function
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:
Styling Active Links
UseactiveProps and inactiveProps to style links based on active state:
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
Programmatic Navigation
Use theuseNavigate hook for programmatic navigation:
Navigate Options
Thenavigate function accepts the same options as Link:
Navigate from Loaders
You can also navigate from route loaders:Redirects
Use theredirect function to redirect during data loading:
Route-Specific Redirects
Each route has aredirect 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 thefrom route for full type safety:
Router API
Access the router instance for advanced navigation:View Transitions
Enable smooth transitions between routes:Scroll Behavior
Hash Scrolling
Automatically scroll to elements with matching IDs: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