@nichoth/catch-routes

Listen for route changes and parse urls in the browser

Stats

stars 🌟issues ⚠️updated 🛠created 🐣size 🏋️‍♀️
01Sep 5, 2018Jul 30, 2018Minified + gzip package size for @nichoth/catch-routes in KB

Readme

catch routes

Listen for route changes and parse urls in the browser.

This is a higher level wrapper around route-event that handles url parsing as well.

install

$ npm install @nichoth/catch-routes

example

var catchRoutes = require('@nichoth/catch-routes')

var { setRoute } = catchRoutes(function onRoute (url) {
    console.log('href', url.href) //  => /some/path?foo=bar
    console.log('pathname', url.pathname) //  => /some/path
    console.log('query', url.query) //  => { foo: 'bar' }
})

// navigate programmatically
setRoute('/hello')

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.