Skip to content
Nuxtjs authentication example
Vue JavaScript
Branch: master
Clone or download
Dan Jacob
Dan Jacob Production setup
Latest commit 2ea26f6 Feb 3, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
assets First commit Feb 3, 2018
components First commit Feb 3, 2018
layouts
middleware First commit Feb 3, 2018
pages Production setup Feb 3, 2018
plugins First commit Feb 3, 2018
static
store Usage comments Feb 3, 2018
.editorconfig First commit Feb 3, 2018
.eslintrc.js
.gitignore First commit Feb 3, 2018
README.md Updated README Feb 3, 2018
nuxt.config.js First commit Feb 3, 2018
package-lock.json Production setup Feb 3, 2018
package.json Production setup Feb 3, 2018
server.js Production setup Feb 3, 2018

README.md

nuxt-auth

Experimenting with authentication and Nuxt.js.

See https://nuxtjs.org/examples/auth-routes/

Instead of running nuxt directly, we use a server.js file to bootstrap the application. We can add a couple of authentication routes there which manage user details (including auth tokens for external API) in a secure cookie.

A nuxtServerInit call in vuex fetches the auth info on page load, and adds it to the store.

The secure view shows example of middleware to prevent page being visible if user is authenticated. The middleware and any pages just access this info directly from tthe vuex store.

Build Setup

# install dependencies
$ npm install # Or yarn install

# serve with hot reload at localhost:3000
$ npm run dev

# build for production and launch server
$ npm run build
$ npm start

# generate static project
$ npm run generate

For detailed explanation on how things work, checkout the Nuxt.js docs.

You can’t perform that action at this time.