Routing

From Esposter/Esposter · View interactive version

Routing is an AI agent skill from the GitHub repository Esposter/Esposter. Apply when adding links, navigating in code, reading route params/query, syncing tabs to the URL, or writing pages with dynamic or optional route segments. Esposter's routing — how links, navigation, route reads, navigation state and dynamic segments are written in apps/web.

How to use this skill

Skill file

Routing

Links — `NuxtLink` / `NuxtInvisibleLink` or `:to`, Never a Raw `<a>`

A link is NuxtLink, NuxtInvisibleLink or a library component's :to, never a raw <a> (vue/no-restricted-html-elements), with its target from RoutePath (references/links.md). A route is RoutePath's wherever it is written, a test's address or a template string as much as a link, so a rename moves every reader; routing/no-route-literal (scripts/src/oxlint/routing.ts) reports a string spelling one of its paths, read off RoutePath itself.

Imperative Navigation — `navigateTo`

navigateTo(target, options), always awaited or returned — never router.push (vue/no-restricted-syntax); a single-expression inline handler already returns it (references/navigate-to.md).

Route Reads — a Page's Own `useRoute()`, `useRouter().currentRoute` Everywhere Else

A page reads its own segments through useRoute() — the one place the call is allowed, and a page's only route read, since a page navigates with navigateTo; the page override in oxlint.config.ts enforces it. The typed router narrows a page's no-argument useRoute() to that page's params, so route.params.id is a string with no helper and no cast:

const route = useRoute();
const { id } = route.params;

Everywhere else useRoute() is banned — a component, composable or store reads useRouter().currentRoute, destructured, because a ref reached through router. does not auto-unwrap in a template while currentRoute does.

Where Navigation State Lives — `references/navigation-state.md`

Decide by what the value is: part of what the page shows (a filter, a page number, a tab) → the URL; how the visitor got here (a breadcrumb trail, a drill-down) → the history entry, written in one router.afterEach hook and never at each link; what the visitor prefers → localStorage through the LocalStorageKey registry. The history-entry mechanics, and why nothing reactive may enter it, are in references/navigation-state.md.

Route-Synced Tabs — `references/route-synced-tabs.md`

UiTabs state syncs to the URL through useEnumRouteQuery(TAB_QUERY_PARAMETER_KEY, FooTabs, FooTab.Default), never a plain ref, so the active tab survives a refresh and is linkable; each value set exposes its value Set beside it.

Optional / Nested Segments — `references/nested-segments.md`

One page serving optional or nested segments is keyed by the stable segment only and validates its params in definePageMeta({ validate }); the stable segment is read once off the page's useRoute(), the changing one through a computed, and what validate cannot know before load is checked after it with showError.

Static Paths — Never a Page's

A file in public/ or a Nitro publicAssets mount never sits at a path a page answers: the server serves the static path first, so the page works when linked to and breaks on a reload (a directory redirects to its trailing-slash form, which no page matches). Mount asset data under a prefix no page uses, as data/<feature>/ does; configuration/nitro.test.ts resolves every static path through the router and fails on a match.

Deep Dives

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.