Skip to content

Nuxt.js

Terminal window
$ yarn create nuxt-app <project-name>

  1. Install with yarn:
Terminal window
$ yarn add @nuxtjs/auth @nuxtjs/axios
  1. Edit nuxt.config.js:
Terminal window
modules: [
'@nuxtjs/auth'
]
  1. Setup auth middleware globally in nuxt.config.js
Terminal window
router: {
middleware: ['auth']
}
  1. Auth strategy example (still in nuxt.config.js)
Terminal window
auth: {
strategies: {
login: { url: '/login', method: 'post', propertyName: 'token' },
user: { url: '/users/me', method: 'get', propertyName: false },
}
}

?> Official documentation