A more powerful Next.js router events API. The standard API can only handle one listener per router event (see zeit/next.js#2033).
To install next-router-events
from npm run:
npm install next-router-events
To use router events:
import routerEvents from 'next-router-events'
const logUrl = url => console.log(url)
const alertUrl = url => alert(url)
routerEvents.on('routeChangeComplete', logUrl)
routerEvents.once('routeChangeComplete', alertUrl)
routerEvents.off('routeChangeComplete', logUrl)
See next
router events and tiny-emitter
instance methods.