suika-router
v1.5.4
Published
Suika Router is a lightweight routing library for the Suika framework
Downloads
17
Readme
Suika Router (WIP) is a lightweight routing library for the Suika framework.
Installation
You can use suika-router
as a package on npm
npm install suika@latest suika-router@latest
Documentation
Please follow the documentation at jonwatkins.github.io/suika/.
Usage
import { Component, mount, h } from "suika";
import { createRouter, RouterView, RouterLink } from "suika-router";
const root = document.getElementBytId("app");
class About extends Component {
render() {
return (
<section class="content">
<h1>About Us</h1>
</section>
)
}
}
class Home extends Component {
render() {
return (
<section class="content">
<h1>Hello World</h1>
</section>
)
}
}
const router = createRouter({
mode: 'hash',
routes: [
{ path: '/', component: Home },
{ path: '/about', component: About }
]
})
class App extends Component {
render() {
return (
<div id="container">
<ul class="navigation">
<li><RouterLink to="/">Home</RouterLink></li>
<li><RouterLink to="/about">About</RouterLink></li>
</ul>
<RouterView router={router}>
</div>
);
}
}
mount(App, root);
License
Copyright (c) 2023-present, Jon Watkins