Simple router that uses the Navigation API
npm install navigation-routerClient-side routing using the Navigation API.
This module relies on the experimental Navigation API and URLPattern API.
These APIs are not available in all browsers! Yet!
Check browser support:
- Navigation API
- URLPattern API
``js
import NavigationRouter from 'navigation-router'
const router = new NavigationRouter()
router.add('/', async (route) => {
console.log('handling route', route)
})
router.add('/posts/:id', async (route) => {
console.log('handling route', route.params.id, route)
})
router.on('change', (event) => {
console.log('route changed', event.detail)
})
router.on('404', (event) => {
console.log('404', event.detail)
})
``