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

colab-router

v0.0.2

Published

Shared page navigation for co:lab sites — moves between pages without a full reload (PJAX today), from the fragments d8e --pjax writes or the pages themselves.

Readme

colab-router

Shared page navigation for sites. A click on a link to another page swaps that page's content in, so the shell around it (nav, footer, a WebGL canvas, a loader that has already run) stays rendered.

How it ships

co:lab sites serve src/ directly with no build step, so node_modules is never reachable from a page. colab-router therefore ships as a single classic script (colab-router.js, global: ColabRouter) that consumers vendor into their own src/script/ with a copy step.

Setup

1. Install

npm install --save-dev colab-router

2. Vendor the script

Add to the consumer's package.json scripts (postinstall keeps the vendored copy in sync with the installed version):

"sync-router": "cp node_modules/colab-router/colab-router.js src/script/colab-router.js",
"postinstall": "npm run sync-router"

Commit src/script/colab-router.js — local dev serves src/ as-is, so the file must exist in the tree, and d8e minifies/hashes it on build like any other script.

3. Build with the fragments

"build": "colab-partial --check && d8e --pjax" (and the same for heroku-postbuild). d8e writes a <page>.json beside every page: its <title> and its <main>, which is what the router swaps. In dev there is none, and the router fetches the page itself and takes the same two things from it, so navigation works the same way without a build.

4. Wire it up

Load it before the app's own scripts, then create the router once:

<script src="./script/colab-router.js"></script>
<script src="./script/app.js"></script>
ColabRouter.create({
    run: (view, hash) => transition(view, hash),
    jump: (hash) => scrollTo(hash),
    skip: ['/asset/']
});
  • run(view, hash) — swap view (the next page's <main>, as HTML) into the document, then land on hash if there is one. Returns a promise if the swap animates; the router waits for it before taking the next click. document.title and the URL are already set when it's called.
  • jump(hash) — a link to an anchor on the page already showing, or to its top (''). A site with its own scroll (a translated #view) scrolls there itself; a plain site can use location.hash.
  • skip — path prefixes the router leaves to the browser. A single link opts out with data-no-router.

Every page's shared markup (nav, footer, the scripts) must be identical, since it is never reloaded — which the partials already guarantee — and every page sits at the same depth under src/, as the partials require.

What the router owns

Catching clicks on same-origin links (not modified clicks, target="_blank", downloads, data-no-router or a skip prefix); the URL rule (/a/b.html is /a/b, /index.html is /, as cleanUrls and the nginx config serve them — ColabRouter.clean(path) is exported for a caller that needs the same rule); one fetch per page, however its links are written; Back and Forward; a missing page showing the site's 404.html in place; and a full load of the link if nothing can be fetched. Nothing assumes the site is served at the root.

Tests

npm test — c3b-lint, then test/colab-router.test.js with Node's built-in runner: the script is loaded against fakes for window, document, history, location, fetch and DOMParser, so each test sees exactly what the router fetched, pushed and handed to the page.

Deploying to npm

  1. FIRST TIME ONLY: run npm login
  2. Bump the version in package.json
  3. Run npm test && npm publish