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

webcomponent-router

v0.4.3

Published

A library for nested routing using webcomponents

Readme

WebComponent Router

Build Status Coverage Status NPM Version

A library for nested client side routing to be used with a web component architecture. This router is centered around using named tags to hierarchically construct pages. At its core it uses route-recognizer used by Ember's router that heavily influenced this router's DSL. Instead of being bound to a specific framework this router uses simple string attributes to configure it's components and a convention of writing scoped versions of itself to each element injected via their Shadow DOM Slot.

This approach has 2 benefits. Firstly by leveraging the existing slotting mechanism it not only keeps things simple it keeps all elements in the entry elements Light DOM making it easy to traverse nested levels without digging through endless markup. The nested versions provide scoped relative routes. At each level helpers will work relatively using . notation on the path allowing moving components around in the router definition without necessarily having to go and update all your routes. The route definition orchestrates the composition of your whole application.

Routers can be nested as well by provide a root path to indicate which portion of the URL it is responsible for.

import Router from 'webcomponent-router'

// register webcomponents for links and outlets
import 'webcomponent-router/components'

const router = new Router(document.getElementById('main'));

router.map(r => {
  r.index(() => ['user', { userId: 123 }]);
  r.notFound(() => ['index']);
  r.route('user', { path: '/users/:userId', tag: 'pane-user' }, r => {
    r.index(() => ['sets']);
    r.route('sets', {
      path: '/sets', tag: 'pane-sets',
      // dynamic import for code splitting
      onEnter: () => import("../components/pane-sets")
    });
    r.route('set', { path: '/sets/:setId', tag: 'pane-set' });
  });
});

router.start();

router.transitionTo('user.set', {setId: 49});

// Lookup router in some nested context
const router = Router.for(element);
<a is='route-link' name='user.set' params='{setId: 23}'>View Set</a>

<slot>
<!-- Nested Content will be placed here -->
</slot>

Route Link Components listen to both attribute and property setting for 'name', 'params', 'query'. The params and query attributes JSON Parse the object passed. However you can also just set the property.

Install

> npm install webcomponent-router

Test

Run the unit tests:

> npm test