Skip to content

@isorouter/vue

Vue 3 adapter. Requires Vue ≥ 3.4. For a walkthrough see the Vue guide.

sh
npm install @isorouter/vue

Exports

ExportKindDescription
createRouterfunctioncreateCoreRouter with the component type fixed to Vue's Component.
RouterViewcomponentRoot component — calls start/stop, renders matched component or loading/notFound/error slots.
OutletcomponentRenders the next component in the matched chain; nothing if no child.
LinkcomponentA plain <a> intercepted by the Navigation API.
useRoutercomposableThe Router instance.
useRouterStatecomposableShallowRef<RouterSnapshot>; fresh reference on every commit.
useParamscomposableComputedRef<Record<string, string>>.
useLocationcomposableComputedRef<URL>.
useNavigatecomposable(to, opts?) => void delegating to router.navigate.
lazyfunctionRe-exported from @isorouter/core.

Types

Core re-exports: BeforeLoad, GuardContext, Href, NavTarget, RouteConfig, RouterOptions, RouterSnapshot.

<RouterView> slots

SlotShown when
loadingno matched root component yet; no error/notFound applies.
notFoundsnapshot.status === "not-found".
errorsnapshot.status === "error" — receives { error: snapshot.error }.

href, activeClass (default "active", applied as the element's class), exact. Sets aria-current="page" when active; default slot is rendered as the link's children. Must be used within <RouterView>. See Links & active state.

Composables

All must be used within <RouterView> (they inject the provided router). useRouterState()'s subscription is torn down automatically via onScopeDispose.

Bridge primitive: shallowRef(snapshot) + subscribe — the snapshot is already immutable, so shallow-ref replacement is exactly right (no deep proxy).

Released under the MIT License.