Link
Text link with inline, nav, muted, standalone and plain variants: underlined at rest or on hover so it never relies on colour, external and new-tab handling, aria-current, render for router links, an opt-in onFollow that routes plain clicks and gives agents a follow action, and fast navigation on a primary mouse press (fast={false} or data-no-fast-link to opt out); FastLinkRegion and useFastLink do the same for plain anchors.
Example
Press and hold each link with the mouse. The fast link follows the moment the button goes down; the other waits until you let go. Tab to them and press Enter to follow with the keyboard.
Nothing followed yet.
Read the installation guide first, then browse the UI SDK docs (opens in a new tab).
Installation
class-variance-authority@0.7.1@fast-link/core@0.0.2lucide-reactUsage
Use Link for every anchor: inline in prose, nav and muted in lists, standalone for a call to action, plain inside a styled row or card. Pass onFollow for client-side routing. Same-origin links follow on a primary mouse press, not on release; fast={false} opts a link out, data-no-fast-link on an ancestor (or <body>) a region or the app, and FastLinkRegion gives plain anchors the same behaviour. In a hash router, #/ links follow on press too (through onFollow or location.hash) while other # links stay in-page anchors; data-fast-link-hash-prefix on an ancestor, or FastLinkRegion hashPrefix, sets another prefix.
API reference
FastLinkRegion
Takes PartProps<"div"> &.
Link
| Prop | Type | Default |
|---|---|---|
children | ReactNode | – |
variant`inline` is underlined at rest, `nav` and `muted` on hover; `plain` adds no look, not even the focus ring. | "inline" | "nav" | "muted" | "standalone" | "plain" | – |
externalAdds a trailing icon and `rel="noopener noreferrer"`; opens in the same tab unless `newTab`. | boolean | – |
newTab`target="_blank"`, announced to screen readers with `newTabLabel`. | boolean | – |
newTabLabel | string | – |
current`true` is `aria-current="page"`; a string is another `aria-current` token. | boolean | Exclude<AriaAttributes["aria-current"], boolean | "true" | "false"> | – |
onFollowTakes over a plain click (modified clicks stay native) and gives agents a `follow` action; without it agents don't see the link. | LinkOptions["onFollow"] | – |
onNavigateClient-side routing without an agent action: a primary mouse press, a plain click or Enter call it; modified clicks stay native. `onFollow` wins over it. | (href: string, event: Event) => void | – |
onIntentFires on a 65 ms hover, focus, or a mouse or pen press, to preload; it can fire more than once per visit. | (href: string) => void | – |
fastFollows a same-origin link on mouse press, for navigation only (WCAG 2.5.2: a press can't be cancelled). Off for `external`, and without `onFollow` also with `render` or `onClick`; `data-no-fast-link` on an ancestor turns a region off. @defaultValue true | boolean | – |
Also takes <a> attributes and render except children.
Other exports
hashPrefixAttributeisHashRouteuseFastLinkisModifiedLinkPressisPlainClicklinklinkVariantsuseLinkIntenttype FastLinkOptionstype FastLinkRegionPropstype LinkFollowDetailstype LinkOptionstype LinkPropstype LinkVariantAccessibility
- Fast links are for navigation only: a press can't be cancelled by moving away (WCAG 2.5.2 Pointer Cancellation), which Back undoes for a page change but not for an action. Keep actions on buttons, and give a link that confirms or changes something fast={false}; set data-no-fast-link on <body> where 2.5.2 must hold strictly.
- Keyboard, touch and pen activation, modified and middle clicks, new-tab, download and external links and in-page anchors (#section) stay native.
- Inline links are underlined at rest and the others on hover, so a link never relies on colour alone.
- newTab adds an sr-only note, overridable with newTabLabel; external adds rel="noopener noreferrer" and an icon.
- current sets aria-current, page by default or any other token such as location.
Agent actions
UI SDK has no link part, so plain links are invisible to agents. A Link with onFollow is a primitive with a follow action that calls onFollow, exactly as a plain click does; the app decides what following means.
Runs agent.snapshot() from @ui-sdk/react/agent on the live preview above.