Skip to main content
The Link component enables client-side navigation without full page reloads. vinext’s implementation provides viewport-based prefetching, locale support, and scroll management.

Import

Basic Usage

API Reference

Props

string | UrlObject
required
The path or URL to navigate to.Can be a string:
Or an object with pathname and query:
string
URL displayed in the browser (for dynamic routes).Legacy pattern — use the href string directly instead:
boolean
default:"false"
Replace the current history entry instead of pushing a new one.
boolean
default:"true"
Enable automatic prefetching when the link enters the viewport.Uses IntersectionObserver with a 250px margin. Set to false to disable:
boolean
default:"true"
Scroll to top after navigation (unless navigating to a hash).
string | false
Locale for i18n routing.
  • locale="fr" — prepend /fr prefix
  • locale={false} — use default locale (no prefix)
  • locale={undefined} — use current locale
(event: NavigateEvent) => void
Called before navigation (Next.js 16+ View Transitions API).Call event.preventDefault() to handle navigation manually:

Standard Anchor Props

All standard <a> attributes are supported:

Prefetching

How It Works

  1. Viewport detection: When a <Link> enters the viewport (+ 250px margin), prefetching begins
  2. App Router: Fetches the .rsc payload and stores in memory cache
  3. Pages Router: Injects a <link rel="prefetch"> tag
  4. Deduplication: Each URL is prefetched only once

Cache TTL

Prefetched entries are valid for 30 seconds. After expiry, the link re-prefetches on next viewport entry.

Disabling Prefetch

Hash-only navigation updates the URL without triggering a full navigation:
Scrolls to the target element using element.scrollIntoView(). External URLs are passed through to the browser:
No prefetching or client-side handling occurs.

useLinkStatus Hook

Track the pending state of a parent <Link>:

Router Integration

App Router

Calls window.__VINEXT_RSC_NAVIGATE__() to fetch and render the new RSC stream.

Pages Router

Dynamically imports the target page module and re-renders the React root.

basePath Support

If basePath is configured in next.config.js, it’s automatically prepended:

Limitations

Shallow routing: The shallow option is not supported in App Router (Next.js removed it).
Middleware rewrites: Links to rewritten paths work correctly, but the browser URL shows the rewrite destination (no masking).

Source

View source code → Implementation: /home/daytona/workspace/source/packages/vinext/src/shims/link.tsx