JS-Router is a very simple routing system build with Typescript.
I highly recommend the installation of es6-string-html, when using VSCode.
const router = new Router();
name | type | default | description |
---|---|---|---|
selector | String | null | selector for root element |
history | Boolean | false | enables navigation with browser control elements |
debug | Boolean | false | enables debug messages in the console |
import home from 'relative/path/to/component.js';
router.get('/home', home);
'home' represents the components that should be rendered when clicking the corresponding link.
export default () => {
/*html*/`
<div>
</div>
`
}
<div data-link="/home">Home</div>
Links can be represented through every HTML-element. The link element has to have the data-link attribute.