fc-hash-router

The godliest of routers!

Usage no npm install needed!

<script type="module">
  import fcHashRouter from 'https://cdn.skypack.dev/fc-hash-router';
</script>

README

Welcome to fc-hash-router 👋

Version

The godliest of routers!

Demo

OR SANDBOX IT

https://codesandbox.io/s/fc-hash-router-example-3z0bf

Edit fc-hash-router-example

Install

yarn add fc-hash-router -D

Usage

import { HashRouter } from "fc-hash-router";

HashRouter.route(`products/:firstVar/:someVar/bobby/#num/random`, (data) => {
    console.info(data);
});

// Or cooler
HashRouter.route(`products/:firstVar/:someVar/bobby/#num/random`, ({firstVar,someVar,num}) => {
    console.info({firstVar,someVar,num});
});	

Then use normal anchor like this

<a href="#/products/12/22/bobby/123/random">TEST</a>

OR With Javascript

HashRouter.navigate(`/products/12/22/bobby/123/random`);

To unregister a route

HashRouter.routeOff(`new/#userId`);

THAT EASY!

Author

👤 Angel Grablev

Show your support

Give a ⭐️ if this project helped you!


Made by Freedcamp with ❤️