Extend Auth

Last updated 3 months ago

If you have plugins that need to access $auth, you can use auth.plugins option.

nuxt.config.js

{
modules: {
'@nuxtjs/auth'
},
auth: {
plugins: [ '~/plugins/auth.js' ]
}
}

plugins/auth.js

export default function ({ app }) {
if (!app.$auth.loggedIn) {
return
}
‚Äč
const username = app.$auth.user.username
}