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

rooterjs

v1.0.0

Published

History-based Client-Side Router

Readme

Rooter

Rooter is a small, but potentially useful, client-side routing library with small API that is backed by browser's History API.

Sample usage

Here we will create new instance of router by calling rooter function which can accept optional argument that is id of root DOM element in which all views are going to be rendered. If element is passed smooth transition will be applied on route change.

var router = rooter("app");

To configure type and duration of transition you can use configureTransition method to which you pass plain JavaScript object with effect, time and applyAfter properties. Time should be in milliseconds.

router.configureTransition({
  time: 400,
  effect: "ease-in",
  applyAfter: 200
});

After instantiation we can add routes by calling when method on provided object. It looks like this, also it supports chaining.

router.when("/", function() {
  // custom logic
});

Router also support URL parameters all of which are decoded with browser decodeURIComponent function before being passed to attached handler.

router.when("/user/:id", function(params) {
  console.log(params); // which for example could contain { id: "1" } 
});

Middleware functions are another part of router. They are optional but if you want to add them you can do so by passing an array with desired functions as second argument.

function authenticate() {
  // logic
}

router.when("/profile/:id/edit", [authenticate], function(params) {
  if(authenticated) {
    // proceed
  } else {
    router.redirect("/login");
  }
});

If you want to namespace routes you can use appropriately named namespace method.

router.namespace("user")

To handle 404 pages you can use notFound method by providing to it a custom function. Defaults to empty function.

route.notFound(function() {
  // for instance view.render("notfound");
});

Last step after adding desired routes and setting up error handling is to call start function which will monitor for changes on window.location property.

router.start();

If you want to remove certain route you would call remove method and pass path to it...

router.remove("/secret");

To empty whole object you can call router.flush().