A single page web application router

Usage no npm install needed!

<script type="module">
  import afModulesRouter from 'https://cdn.skypack.dev/@af-modules/router';


AF Router CCC

Greenkeeper badge Build Status Coverage Status

AF Router is a single page application router. It allows to easily attach listeners to state changes.


npm i --save @af-modules/router

How to Use

import Router from '@af-modules/router';

        path: ['/', '/home'],
        onEnter: (path) => {...},   
        onLeave: (path) => {...},
        isPersistent: true,
        path: '/home/details',
        onEnter: (path) => {...},
        onLeave: (path) => {...},
        isPersistent: true,




Router.init([{ path: string, onEnter: Function, onLeave: Function, isPersistent: boolean }]);

The init() method initializes the router. An array of objects can be specified to define the initial states.


Restores the state of the application the last time it was open. Call this method if users should be able to return to the application in the same state they left.