Skip to content

toolmark-monorepo / @toolmark/inertia / navigationTool

Function: navigationTool() ​

navigationTool(o): ToolDefinition<NavigationInput, { url: string; }>

Defined in: packages/inertia/src/navigation.ts:70

Builds the navigation tool (spec §10.1, D23). Input route is an enum of the route keys; run builds the route with params and, for a same-origin GET route, calls visit(url, { method: 'get' }) and returns ok({ url }) immediately — before the page swap disposes the page scope (a changed/manifest follows). GET only: a route whose method is not get (case-insensitive) → refused navigation_failed ("Only GET routes can be navigated; declare a server tool for mutations"); a throwing route, a malformed route result or a URL outside this page's origin → refused navigation_failed. No hints. Register it at the root scope (never inside the inertiaPages page scope), so it survives navigation. The visit receives the canonical absolute URL, and ok({ url }) reports that same canonical href (not the route's raw URL). params with a __proto__/constructor/prototype key are invalid.

Parameters ​

o ​

NavigationToolOptions

Routes, the visit function and optional name/description.

Returns ​

ToolDefinition<NavigationInput, { url: string; }>

A tool definition for tm.register.

Throws ​

TypeError "navigationTool needs at least one route" when routes is empty (or not an object) — such a tool could never succeed.