Install & Download:
# NPM
$ npm i @websanova/vue-auth --saveDescription:
A simple and lightweight authentication library to simplify the authentication task of your Vue.js 2 or Vue.js 3 application.
Basic usage:
1. Import necessary components into your app.
import {createApp} from 'vue';
import {createRouter} from 'vue-router';
import axios from 'axios';
import App from 'App.vue';
import {createAuth} from '@websanova/vue-auth';
import driverAuthBearer from '@websanova/vue-auth/dist/drivers/auth/bearer.esm.js';
import driverHttpAxios from '@websanova/vue-auth/dist/drivers/http/axios.1.x.esm.js';
import driverRouterVueRouter from '@websanova/vue-auth/dist/drivers/router/vue-router.2.x.esm.js';
import driverOAuth2Google from '@websanova/vue-auth/dist/drivers/oauth2/google.esm.js';
import driverOAuth2Facebook from '@websanova/vue-auth/dist/drivers/oauth2/facebook.esm.js';2. Basic usage:
var router = createRouter({
...
})
var auth = createAuth({
plugins: {
http: axios,
router: router
},
drivers: {
http: driverHttpAxios,
auth: driverAuthBearer,
router: driverRouterVueRouter,
oauth2: {
google: driverOAuth2Google,
facebook: driverOAuth2Facebook,
}
},
options: {
rolesKey: 'type',
notFoundRedirect: {name: 'user-account'},
}
});
createApp(App)
.use(router)
.use(auth)
.mount('#app');Preview:

Changelog:
v4.2.0 (10/17/2022)
- Bugfix
v4.1.13 (06/10/2022)
- Do not clear redirect state if no actual redirect
v4.1.12 (03/11/2022)
- Fix unauth routes on token expire
v4.1.9 (01/21/2022)
- fix: add missing types
v4.1.9 (01/12/2022)
- fix: add missing types
v4.1.7 (12/15/2021)
- Update oauth2 params to not prefix unnecessary ampersand.