Suika Router (WIP) is a lightweight routing library for the Suika framework.
You can use suika-router
as a package on npm
npm install suika@latest suika-router@latest
Please follow the documentation at jonwatkins.github.io/suika/.
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);
Copyright (c) 2023-present, Jon Watkins