mjs-router
v0.2.3
Published
Router for mutableJS library
Downloads
5
Maintainers
Readme
mJS-router
@mutableJS/core based wrapper for the History Web API to create SPA.
FAQ
Can it be used standalone?
In theory yes, but the main idea is to provide reactivity for @mutableJS/core SPAs.
Installation
Install with npm:
npm install @mutablejs/core mjs-router
Install with yarn:
yarn add @mutablejs/core mjs-router
Keep in mind the repository depends on @mutablejs/core
.
Usage/Examples
outside mutableJS apps
import location from 'mjs-router';
// Change URL
location.path.value = '/new-url'; // changes the url and pushes it to the history
// Change hash appendix
location.hash.value = 'some-hash'; // adds #some-hash to the url and pushes new url to the history
// Change URL
location.searcg.value.set('param', 'value'); // adds ?param=value and pushes it to the history
in mutableJS apps
You have additional gadgets:
import { href } from 'mjs-router';
const someLink = <a {...href('/new-url')}>Click me!<a/>; // this prevents the default event handling and pushes /new-url to the history object
Start with your own mutableJS project: Starter-Template repository.
Authors
Feedback
Any feedback? Join our Discord server and reach out to us.
We are open to suggestions, ideas and collaboration.