Lynx/Modules/Navigation/Link
@sigx/lynx-navigation · Stable · Component library

Link#

Declarative navigation — the JSX flavor of nav.push. Render a <Link to="…"> and a tap pushes (or replaces) that route, with the same per-route param inference as the imperative Nav API.

Import#

TSX
import { Link } from '@sigx/lynx-navigation';

Basic usage#

Link wraps a native <view> that fires nav.push on bindtap. The to prop is a registered route name, and — exactly like nav.pushparams is required if and only if that route declares a params schema. Route names, params and search are all inferred from your augmented Register route map, so a wrong route name or a missing/extra param is a TypeScript error.

TSX
import { Link } from '@sigx/lynx-navigation';

// `profile` declares a params schema → `params` is required.
<Link to="profile" params={{ id: 'alice' }} search={{ tab: 'about' }}>
  Open Alice
</Link>;

// `home` has no params schema → `params` is forbidden.
<Link to="home">Go home</Link>;

Replacing instead of pushing#

Pass replace to navigate with nav.replace rather than nav.push — useful for "reset" style links that should not add a back-stack entry.

TSX
import { Link } from '@sigx/lynx-navigation';

<Link to="home" replace>Reset</Link>;

Because Link resolves the navigator from context, it must be rendered inside a NavigationRoot subtree — see Usage for the full setup.

Props#

PropTypeDescription
toRouteIdThe target route name. Must be a registered route; inferred from your augmented Register route map.
paramsRouteParams<K>Route params. Required exactly when the route to declares a params schema; forbidden otherwise.
searchRouteSearch<K>Optional typed search / query params for the route.
replacebooleanNavigate with nav.replace instead of nav.push (no new back-stack entry).
childrenunknownThe link content rendered inside the native <view>.

The full prop type is LinkPropsLinkPropsByRoute & { replace?: boolean; children?: unknown }, where LinkPropsByRoute conditionally requires params per route. It mirrors the per-route overloads of Nav.push.

See also#

  • Usage — the typed-routes setup and the imperative useNav API.
  • API referenceLink, LinkProps, Nav and every related type.