JSFiddle - React, Tailwind, and code Playground
by Vladimir Kutepov
HTML
<script src="https://npmcdn.com/[email protected]/universal-router.js"></script>
JavaScript
const routes = {
path: '/users',
children: [
{ path: '/', action() { return 'Users' } },
{ path: '/create', action() { return 'Create User' } },
{ path: '/add', action() { return 'Add User' } },
{ path: '/:id', action(context) { return `User #${context.params.id}` } },
]
}
UniversalRouter.resolve(routes, '/users/123').then(result => {
document.body.innerHTML = result
})