Q:

nuxt vue router afterEach guard

How can I set an afterEach handler that executes after route changes in nuxt?  The middleware can be used as an beforeEach, but I could not find a way to implement the afterEach hook. 

A:

You can create a plugin like the following:
// plugins/after-each.js:
export default async ({ app }) => {

  app.router.afterEach((to, from) => {
    // Do something
  });

}

And then reference it in nuxt.config.js:
plugins: [ { src: '~/plugins/after-each.js', mode: 'client' } ]

Note: Since Nuxt.js 2.4, mode has been introduced as option of plugins to specify plugin type, possible value are: client or server.  ssr: false will be adapted to mode: 'client' and deprecated in next major release.