Skip to main content

Router Link

Router Link is a TanStack Router-aware link component built with MUI's Link. It is created via createLink and renders client-side navigation without a full page reload, with MUI hover underline styling and the next-btn-link class.

Use RouterLink when you want a typed, router-bound link inside a TanStack Router app. For a simpler link with an href prop, see NextLink.

Import

import { RouterLink } from '@js-smart/react-kit';

Basic usage

Mount your app with TanStack Router, then use RouterLink with the to prop:

<RouterLink to="/dashboard">Dashboard</RouterLink>

RouterLink accepts standard MUI Link props such as color, variant, and underline:

<RouterLink to="/settings" color="primary" underline="always">
Settings
</RouterLink>

With route params

Pass TanStack Router link options such as params and search alongside MUI props:

<RouterLink to="/books/$bookId" params={{ bookId: '42' }}>
View book
</RouterLink>

Accessibility

Set aria-label when the visible link text is not descriptive enough for screen readers.

Peer dependencies

RouterLink requires @tanstack/react-router and a registered router instance in your app tree. It also uses @mui/material. See Installation.

Props

RouterLink combines TanStack Router Link props with MUI Link props.

PropTypeDefaultDescription
tostringRequired. Target route path.
paramsobjectRoute params for dynamic segments.
searchobjectURL search/query params.
childrenReactNodeLink content.
classNamestringCSS class. The next-btn-link class is applied by default.
underline'none' | 'hover' | 'always''hover'MUI underline behavior.
colorMUI Link colorMUI link color.
aria-labelstringAccessible label for the link.