next-router-events
v2.1.0
Published
A more powerful Next.js router events API.
Downloads
3,431
Readme
next-router-events
A more powerful Next.js router events API. The standard API can only handle one listener per router event (see zeit/next.js#2033).
Setup
To install next-router-events
from npm run:
npm install next-router-events
Usage
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.