vue.js - how to write global router-function in nuxt.js - Stack Overflow

PHOTO EMBED

Wed Sep 22 2021 08:35:37 GMT+0000 (Coordinated Universal Time)

Saved by @olasunkanmi

//create route plugin
export default ({ app }) => {
   // Every time the route changes (fired on initialization too)
   app.router.afterEach((to, from) => {
     //do something to validate
   })
}


// add to nuxt.config.js file
plugins: ['~/plugins/route']
content_copyCOPY

https://stackoverflow.com/questions/45509472/how-to-write-global-router-function-in-nuxt-js