Navigation

<Link> performs client-side navigation — no full page reload. It renders a real anchor, so modified clicks (new tab, etc.) still work.

JSX
import { Link } from "@opentf/web";

<Link href="/about">About</Link>

The router

The global router is reactive — read its fields directly (no .value):

JSX
import { router } from "@opentf/web";

<nav class={router.pathname === "/" ? "home" : ""}>…</nav>
MemberDescription
router.pathnameCurrent path (reactive).
router.paramsDynamic route params (reactive).
router.queryParsed query string (reactive).
router.localeActive locale when i18n is enabled, else null (reactive).
router.push(path)Navigate, pushing a history entry.
router.replace(path)Navigate, replacing the current entry.
Reactive reads

Reading router.pathname inside a binding (an attribute or {} expression) updates the UI automatically when the route changes.

Localized navigation

When i18n is enabled, the locale lives in the URL path and <Link> automatically keeps navigation in the active locale. Build a localized URL yourself with localizePath — handy for a language switcher:

JSX
import { Link, localizePath, router } from "@opentf/web";

// The current page under another locale:
<Link href={localizePath(router.pathname, "fr")}>Français</Link>

See the Locale Routing guide for the full model (prefix_except_default, per-locale SSG/SSR, detection), and the @opentf/web API reference for localizePath, setLocale, and the other locale exports.