A tiny (238 bytes
) routing utility for listening to route changes in single page applications.
npm install @analytics/router-utils
import onRouteChange from '@analytics/router-utils'
import analytics from './analytics'
onRouteChange((newRoutePath) => {
console.log('new route path', newRoutePath)
// trigger page view
analytics.page()
})