alfama-router
v1.0.2
Published
alfama router
Downloads
9
Readme
alfama Router
Router for alfama inspired by react-router
npm: npm i alfama-router
cdn: https://cdn.jsdelivr.net/npm/alfama-router/+esm
Example
/** @jsx h **/
import { component, h, render } from "alfama";
import { Link, Route, Switch, BrowserRouter } from "alfama-router";
export const Layout = component<{}>("Layout", (props, {}) => {
return (
<BrowserRouter>
<div>
<ul>
<li>
<Link href="/">Home</Link>
</li>
<li>
<Link href="/about">About</Link>
</li>
</ul>
<Switch>
<Route path="" component={Home} />
<Route path="about" component={About} />
</Switch>
</div>
</BrowserRouter>
);
});
export const Home = component<{}>("Home", (props, {}) => {
return <div>Home</div>;
});
export const About = component<{}>("About", (props, {}) => {
return <div>About</div>;
});
render(<Layout />, document.body);