npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@vizejs/router

v0.818.0

Published

Strongly typed SSR router foundations for Vize applications

Readme

@vizejs/router

Experimental: the route table, SSR handoff shape, and generated metadata contract may change during the Vize alpha line.

The package is released on npm as @vizejs/router; the route and navigation contracts remain experimental throughout the Vize alpha line.

@vizejs/router provides the first typed route-table kernel for Vize applications. It is intentionally SSR-safe: matching and serialization do not touch browser globals, timers, or reactive scope state.

import { createRouterMatcher, defineRoutes } from "@vizejs/router";

const routes = defineRoutes([
  { name: "home", path: "/", component: "./routes/home.vue" },
  { name: "user", path: "/users/:id/:tab?", component: "./routes/user.vue" },
] as const);

const router = createRouterMatcher(routes);
const match = router.match("/users/42/settings?from=ssr");

router.resolve("user", { id: "42" });

A string location is an in-app reference. match, navigate, and the activation URL given to hydrateRouteState report no match when it resolves to another origin (//host/path, an absolute URL) or cannot be parsed or decoded; pass a URL object for an absolute URL such as a request URL. History adapters receive the normalised path, query, and hash, never the caller's raw string. resolve rejects a param that is empty or a ./.. segment, so a built path names its own route.

Route components are declared as .vue specifiers. JavaScript render-function component sources are not part of this package surface.

SSR integrations can pass serializeRouteMatch(match, data) through their own safe serialization channel, then call hydrateRouteState(routes, state, currentUrl) during client activation. Hydration rematches the pathname against the current table and checks route identity, decoded params, query, and hash. Malformed or stale handoffs return undefined; match and load the current URL afresh in that case. The optional third argument checks the activation URL without reading browser globals. Omitting it reconciles the serialized pathname and params only; it cannot detect navigation since the server render. Query key order is ignored, while repeated-value order is preserved.

Navigation lifecycle

createRouter(routes, adapters) adds cancellable guards, loaders, redirects, stale-result custody, history commits, and explicit focus/scroll/announcement effects without reading browser globals. Integrations provide the browser or native adapters they support; missing adapters are deliberate no-ops rather than implicit global access.

import { createRouter } from "@vizejs/router";

const router = createRouter(routes, {
  history: {
    push: (url, leaving) => history.pushState(leaving, "", url),
    replace: (url, leaving) => history.replaceState(leaving, "", url),
  },
  announce: (title) => announceRoute(title),
});

router.beforeEach(({ to }) => (to.meta.requiresAuth && !session.value ? "/login" : undefined));
await router.navigate({ name: "user", params: { id: "42" } });

Starting a second navigation aborts the first one. A late loader result is reported as stale and cannot replace current state. Explicit cancellation reports cancelled; loader/guard failures report error and retain the route's optional .vue error boundary. History traversal passes saved scroll/focus values through navigate(..., { history: "pop", scroll, focus }).

File routes and evidence

createFileRoutes maps index.vue, [id].vue, [[tab]].vue, and [...slug].vue into explicit route records. Each source can override its generated name/path while retaining the same manifest, SSR, and navigation contracts. vp run --filter './npm/compose/router' bench records cold table construction, warm matching, warm navigation, and a 1,000-route table in one machine-readable row.