Link
Router-integrated localized link anchors.
The Link and NavLink primitives extend standard HTML anchor links by integrating language locales, base directories, and SPA route navigation.
You almost never need them in MDX content — regular Markdown links work fine there. Reach for Link / NavLink only inside custom React components where you want:
- SPA-style route transitions (no full page reload).
- Automatic locale + version prefixing on internal
href. - Active-state styling via the
NavLink's render function.
Both render as a normal <a> under the hood.
Import
import { Link, NavLink } from 'boltdocs/primitives'
Quick Start
Create localized, SPA-aware routing links:
import { Link, NavLink } from 'boltdocs/primitives'
export default function SidebarNav() {
return (
<div className="flex flex-col gap-2">
{/* 1. Standard localized navigation */}
<Link href="/getting-started" className="text-primary-500 hover:underline">
Getting Started
</Link>
{/* 2. NavLink with automatic active state highlighting */}
<NavLink
href="/api/config-reference"
className={({ isActive }) =>
`px-3 py-1 rounded text-sm ${isActive ? 'bg-primary-500 text-white' : 'text-muted hover:bg-soft'}`
}
>
Config Reference
</NavLink>
</div>
)
}
Under-the-Hood Mechanics
- Localization: Direct
hrefstrings (like/getting-started) are automatically parsed and translated through theuseLocalizedTohook. For instance, on a Spanish localized page,/getting-startedis transformed to/es/getting-startedtransparently. - SPA Routing: Internal link clicks intercept default browser navigation to perform fast client-side routing, preventing full page reloads.
Component Props
Link Props
Inherits all standard HTML anchor (<a>) element attributes:
| Property | Type | Default | Description |
|---|---|---|---|
href | string | undefined | Target destination route path (e.g. /docs/getting-started). |
prefetch | 'hover' | 'none' | 'hover' | Preloading strategy for router link targets. |
NavLink Props
Extends standard Link properties:
| Property | Type | Default | Description |
|---|---|---|---|
href | string | undefined | Target destination path. |
end | boolean | false | If set to true, the link is only highlighted active when the route paths match exactly. |
className | string | ((props: { isActive: boolean }) => string) | undefined | Style class name, supporting conditional logic functions. |
children | ReactNode | ((props: { isActive: boolean }) => ReactNode) | undefined | Child nodes, supporting conditional rendering functions. |
Pitfalls
NavLink's render function isn't React-stateful. TheisActiveboolean is evaluated synchronously per render. Don't trigger heavy side-effects in the function body — use it only for class-name computation.- Hard-coding locales in
hrefdefeats the hook. If the user is on/es/docs/guideand you pass a raw/docs/guidehref,useLocalizedTore-localizes it. If you want a non-localized link, prefix withhttps://or use a plain<a>. end={true}matters for index pages. Without it,/docsis "active" when the current path is/docs/installation. Useendwhenever the link points to a section root.
Last updated on July 27, 2026