simple-spa-router-ts

1.0.1 • Public • Published

simple-spa-router-ts

Basic router written in one class. Useful for small projects/prototyping.

Example

import Router from "router";

const router = new Router({
    mode: "hash",  // hash or history
    root: "/",
});

// Add routes + logic to handle route changes
router
    .addRoute(/about/, () => {
        // Route to about page: /#/about/
    })
    .addRoute(/blog\/post/, () => {
        // Regex to handle all URLs starting with /#/blog/post/
    })
    .addRoute("", () => {
        // Route to homepage: /#/
    });

Readme

Keywords

none

Package Sidebar

Install

npm i simple-spa-router-ts

Weekly Downloads

2

Version

1.0.1

License

MIT

Unpacked Size

39.1 kB

Total Files

6

Last publish

Collaborators

  • nazimali