JSFiddle - React, Tailwind, and code Playground
by Vladimir Kutepov
HTML
<script src="https://unpkg.com/[email protected]/universal-router.min.js"></script>
JavaScript
const path = '/test';
const routes = {
path: '/test',
children: [
{
path: '/',
action() {
return {
title: 'test',
chunk: 'test',
component: '<p>This is a test!</p>',
};
},
},
],
};
const router = new UniversalRouter(routes);
router
.resolve(path)
.then(route => {
document.body.innerHTML = route.component;
})
.catch(error => {
document.body.innerHTML = error;
});