Link component provides strongly-typed declarative navigation with built-in preloading and active state management.
Link Component
A strongly-typed anchor component for declarative navigation.packages/react-router/src/link.tsx:925-945
Props
The destination route path. Can be absolute (
/posts) or relative (./post).Path parameters for the destination route. Type-safe based on the
to path.Search parameters for the destination. Type-safe based on route’s search schema.
Hash fragment for the destination (e.g.,
#section-1).State object to pass to the destination location.
Replace the current history entry instead of pushing a new one.
Reset scroll position to top on navigation.
The route to navigate from. Used for relative navigation and type inference.
Preloading Props
Controls route preloading strategy:
'intent': Preload on hover or focus'render': Preload when link renders'viewport': Preload when link enters viewporttrue: Alias for ‘intent’false: Disable preloading
Delay in milliseconds before preloading on hover/focus.
Active State Props
Props to apply when the link is active. Styles and classNames are merged.
Props to apply when the link is inactive.
Options for determining active state:
Advanced Props
Mask the URL shown in the browser while navigating to a different route.
Disable the link (prevents navigation and preloading).
Standard anchor target attribute (
_blank, _self, etc.).Perform a full page reload instead of client-side navigation.
Use View Transitions API for navigation animation.
Wrap navigation in React.startTransition.
Bypass any registered navigation blockers.
Control automatic scrolling to hash target.
Children
Link content. Can be a render function receiving active state.
Data Attributes
The Link component automatically sets these data attributes:data-status="active"- When the link is activearia-current="page"- When the link is activedata-transitioning="transitioning"- During navigation transition
useLinkProps Hook
Build anchor-like props for declarative navigation and preloading.packages/react-router/src/link.tsx:43-719
Same options as Link props.
Ref to forward to the element.
React anchor props suitable for
<a> or custom components including:href- Computed URL- Event handlers (onClick, onMouseEnter, etc.)
- Accessibility props (aria-current, role, etc.)
- Active/inactive className and style merged
createLink Function
Creates a typed Link-like component with custom rendering.packages/react-router/src/link.tsx:901-907
The host component to render (e.g., a design-system Link/Button).
A router-aware component with the same API as Link.
linkOptions Function
Validate and reuse navigation options for Link, navigate or redirect.packages/react-router/src/link.tsx:974-976
Navigation options object.
The same options object, but type-checked.
Usage Examples
Basic Navigation
With Parameters
With Search Parameters
Active Styling
With Preloading
Relative Navigation
With Children Function
External Links
With URL Masking
Custom Link Component
Programmatic Props
Type Safety
Link provides full type safety for:- Route paths: Autocomplete and validation of
toprop - Parameters: Type-checked based on the destination route
- Search params: Validated against route’s search schema
- Relative navigation: Correct types based on
fromprop
Performance
The Link component is optimized for performance:- Automatic code splitting: Routes are lazy-loaded on demand
- Smart preloading: Load routes before navigation with configurable strategies
- Minimal re-renders: Only updates when active state changes
- SSR-safe: Renders correct href on server, hydrates without mismatch
Accessibility
Link follows accessibility best practices:- Renders semantic
<a>elements - Sets
aria-current="page"when active - Preserves standard anchor attributes (target, rel, etc.)
- Supports keyboard navigation
- Works with screen readers