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
string
required
The destination route path. Can be absolute (
/posts) or relative (./post).TParams
Path parameters for the destination route. Type-safe based on the
to path.TSearch
Search parameters for the destination. Type-safe based on route’s search schema.
string
Hash fragment for the destination (e.g.,
#section-1).TState
State object to pass to the destination location.
boolean
default:"false"
Replace the current history entry instead of pushing a new one.
boolean
default:"true"
Reset scroll position to top on navigation.
string
The route to navigate from. Used for relative navigation and type inference.
Preloading Props
'intent' | 'render' | 'viewport' | boolean
default:"false"
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
number
default:"0"
Delay in milliseconds before preloading on hover/focus.
Active State Props
React.AnchorHTMLAttributes | () => React.AnchorHTMLAttributes
Props to apply when the link is active. Styles and classNames are merged.
React.AnchorHTMLAttributes | () => React.AnchorHTMLAttributes
Props to apply when the link is inactive.
ActiveOptions
Options for determining active state:
Advanced Props
MaskOptions
Mask the URL shown in the browser while navigating to a different route.
boolean
default:"false"
Disable the link (prevents navigation and preloading).
string
Standard anchor target attribute (
_blank, _self, etc.).boolean
default:"false"
Perform a full page reload instead of client-side navigation.
boolean
Use View Transitions API for navigation animation.
boolean
Wrap navigation in React.startTransition.
boolean
default:"false"
Bypass any registered navigation blockers.
boolean | ScrollIntoViewOptions
default:"true"
Control automatic scrolling to hash target.
Children
React.ReactNode | (state) => React.ReactNode
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
UseLinkPropsOptions
required
Same options as Link props.
React.ForwardedRef<Element>
Ref to forward to the element.
React.ComponentPropsWithRef<'a'>
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
React.Component
required
The host component to render (e.g., a design-system Link/Button).
LinkComponent
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
LinkOptions
required
Navigation options object.
LinkOptions
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