Skip to content

jaydenseric/next-router-events

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

next-router-events

Build status npm version

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.