Hiroshima is a routing library inspired by the style of the D3.js monks, out of need for a short-term working replacement for the great React Router. It is designed to be simplistic and flexible while keeping the API clean and rigid.
import {Router} from 'hiroshima';
function routes(router) {
router.group(App).call(function(router) {
router.index(Home);
router.dir('about').index(About);
router.dir('users').call(function(router) {
router.index(Users);
router.param('user_id', /\d+/).index(User);
router.else(BadUser);
});
router.else(NotFound);
});
}
const router = new Router().call(routes);
router.match('/'); // {components: [App, Home]}
router.match('/about'); // {components: [App, About]}
router.match('/users'); // {components: [App, Users]}
router.match('/users/123'); // {components: [App, User], params: {user_id: '123'}}
router.match('/users/foo'); // {components: [App, BadUser]}
router.match('/foo'); // {components: [App, NotFound]}
TODO