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

@ncpa0cpl/vrouter

v0.0.14

Published

Client side router for vanilla js

Downloads

60

Readme

VRouter

A framework independent router for JavaScript.

Basic Usage

import { router } from "@ncpa0cpl/vrouter";
import { renderAboutUsPage, renderHomePage } from "./pages";

// define the routes
const AppRouter = router({
  paramNames: [],
  subroutes: (define) => ({
    home: define({
      paramNames: [],
      title: "Home Page",
      default: true,
      component() {
        return renderHomePage(); // return a HTMLElement
      },
    }),
    about: define({
      paramNames: [],
      title: "About Us",
      component() {
        return renderAboutUsPage(); // return a HTMLElement
      },
    }),
  }),
});

// mount the router on the page
document.body.appendChild(AppRouter.rootElement());

// navigate to the about us page
AppRouter.nav.about.$open();

Query Parameters (slugs)

// define a route with a arbitrary string in the URL
const AppRouter = router({
  paramNames: [],
  subroutes: (define) => ({
    posts: define({
      paramNames: [],
      subroutes: (define) => ({
        postID: define({
          slug: true,
          component(ctx) {
            const slugValue = ctx.slug.get();
            // listen to slug changes
            ctx.slug.add(() => {
              console.log(ctx.slug.get());
            });

            return renderPostPage();
          },
        }),
      }),
    }),
  }),
});

// navigate to the post page
AppRouter.nav.posts.postID("123").$open();

Search Parameters

// define a route with search parameters
const AppRouter = router({
  paramNames: [],
  subroutes: (define) => ({
    search: define({
      searchParams: ["q"],
      component(ctx) {
        const searchValue = ctx.params.get().q;
        // listen to search parameter changes
        ctx.params.add(({ q }) => {
          console.log(q);
        });

        return renderSearchPage();
      },
    }),
  }),
});

// navigate to the search page
AppRouter.nav.search.$open({ q: "search query" });

Replace routes and Nested routes

Routes defined in the router can have one of two modes, replace or nest-routes. A replace mode route will replace its Element with the active child Route if there is one, while a nest-routes mode route will append the active child Route Element to a outlet Element, which can be accessed through the Route context.

const AppRouter = router({
  paramNames: [],
  mode: "nest-routes",
  component(ctx) {
    const layout = document.createElement("div");
    layout.append(ctx.out()); // append the Outlet Element to the layout div
    return layout;
  },
  subroutes: (define) => ({
    home: define({
      paramNames: [],
      title: "Home Page",
      default: true,
      component() {
        const homeContainer = document.createElement("div");
        // this div will be appended to the layout div created above when this route is opened
        return homeContainer;
      },
    }),
  }),
});