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 🙏

© 2025 – Pkg Stats / Ryan Hefner

rebel-router

v0.7.0

Published

A lightweight JavaScript router written for ultra-modern applications where web components are first class citizens

Downloads

11

Readme

Note: Currently this is very much a work in progress. I'm working hard to add more desirable features such as History API support and getting the router field testing in real world applications.

##Features

  • Light-weight
  • Zero dependencies
  • Nested routes
  • Animation support
  • Built on web components

##Examples

##Platform Support

While some browsers do not support the full specification for web components you will need to include the webcomponents.js pollyfill.

| | | | | | | |:---:|:---:|:---:|:---:|:---:|:---:| | Latest* ✔ | Latest ✔ | Latest ✔ | IE 11 ✔ | Latest ✔ | Latest* ✔ | *Includes both Mobile & Desktop versions.

#Why?

The latest features of JavaScript (ES2015-17) provide solutions to problems web developers have been struggling with for years. This includes native support for modules, true encapsulation with web components and a reliance on monolithic frameworks to really build anything scalable. Rebel-router allows the developer to write web components which represent views and provides an easy way to tie these views to a URL path with easy access to any parameters. This provides some flexible structure in writing vanilla JavaScript applications without frameworks.

#Getting started

Rebel-router is designed to be used when building applications using the latest version of JavaScript and will need transpiling down to ES5 using babel or similar.

  1. Install rebel-router into your project from npm

npm install rebel-router

  1. Create your views as web components
#home.js
export class HomePage extends HTMLElement {
    createdCallback() {
        this.template = `<p>This is my home page.</p>`;
    }
    attachedCallback() {
        this.render();
    }
    render() {
        this.innerHTML = this.template;
    }
}

document.registerElement("home-page", HomePage);
#about.js
export class AboutPage extends HTMLElement {
    createdCallback() {
        this.template = `<p>This is my about page.</p>`;
    }
    attachedCallback() {
        this.render();
    }
    render() {
        this.innerHTML = this.template;
    }
}
document.registerElement("about-page", AboutPage);
  1. Import your views into your main application file to register the elements.
#app.js
import {HomePage} from './home.js';
import {AboutPage} from './about.js';
  1. Add the router and specify configuration in your HTML file
    <rebel-router animation="true" shadow="false" inherit="false">
        <route path="/about" component="about-page"></route>
        <route path="/info"><p>This is a simple info page.</p></route>
        <default component="home-page"></default>
    </rebel-router>

A simple tutorial on how to get started with rebel-router can be found here.

#Usage

This section of the document details the API for rebel-router.

##<rebel-router></rebel-router>

This element is used to insert a pre-configured router instance into the DOM.

###Attributes

| Attribute Name | Required | Type | Example | Default | Comments | | -------------- | -------- | ------- | ----------- | ------- | ----------------------------------------------------------------------- | | animation | No | Boolean | true | false | Whether or not to enable animation for route transitions. | | shadow | No | Boolean | false | false | Whether or not the router should be encapsulated within the shadow DOM. | | inherit | No | Boolean | false | true | Whether or not the router should inherit a parent routes path. |

###Children

Configuration is specified via child elements of <rebel-router>.

###<route></route>

####Attributes

| Attribute Name | Required | Type | Example | Comments | | -------------- | -------- | ------- | ----------- | ----------------------------------------------------------------------------------- | | path | Yes | String | /user/{id} | The path to which the specified template or component should be rendered. | | component | No | String | about-page | The registered element name of the component to be rendered for the specified path. |

####Children

If you do not wish to use a component to render your view for the specified path you are able to add arbitrary HTML to be used as the template.

###<default></default>

###Attributes

| Attribute Name | Required | Type | Example | Comments | | -------------- | -------- | ------- | ----------- | ----------------------------------------------------------------------------------- | | component | No | String | home-page | The registered element name of the component to be rendered for the specified path. |

####Children

As with the route element you are also able to add arbitrary HTML to be used as the template.

###Example

<rebel-router animation="true" shadow="false" inherit="false">
    <route path="/info" component="info-page"></route>
    <route path="/resources/{resource}" component="resources-list"></route>
    <route path="/resource/people/{id}" component="people-resource"></route>
    <route path="/resource/starships/{id}" component="starships-resource"></route>
    <route path="/resource/vehicles/{id}" component="vehicles-resource"></route>
    <route path="/resource/species/{id}" component="species-resource"></route>
    <route path="/resource/planets/{id}" component="planets-resource"></route>
    <route path="/test/{id}">
        <p>This is a simple page template which can access the route params: ${id}.</p>
    </route>
    <default component="home-page"></default>
</rebel-router>

##<rebel-back-a></rebel-back-a>

An extended HTML anchor element which is used to trigger a back animation for router instances which have animation enabled.

###Attributes

| Attribute Name | Required | Type | Example | Comments | | -------------- | -------- | ------ | ----------- | ----------------------------------------------------- | | href | Yes | String | #/users | The path of the route the anchor element should navigate too. |

###Example

    <a href="#/user/1" is="rebel-back-a"><span class="icon icon-arrow-left2"></span> Back</a>

#To Do

  • History API Support - Where as I've not yet found any real need for this this router is aimed at ultra-modern applications now that the History API is widely supported this will be one of the next features added
  • Intercept transition - A nice feature of many routers is the ability to do work and resolve when finished before a route transition completes allowing you to set-up data from the next page
  • Write a comprehensive test suite to test all aspects of rebel-router and associated elements