![require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages](https://cdn.sanity.io/images/cgdhsj6q/production/be8ab80c8efa5907bc341c6fefe9aa20d239d890-1600x1097.png?w=400&fit=max&auto=format)
Security News
require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
hpsweb-vuejs-jwt
Advanced tools
Lightweight JWT handler for Vue.js 2.
Install using npm:
$ npm install hpsweb-vuejs-jwt --save
Or install using yarn:
$ yarn add hpsweb-vuejs-jwt
Import and register Vue plugin:
import Vue from "vue";
import VueJWT from "hpsweb-vuejs-jwt";
Vue.use(VueJWT, options);
Available options are described below.
In your Vue.js components, simply call one of these methods:
// Return true / false - check if a JWT token is stored in cookies or local storage
this.$jwt.hasToken();
// Or
this.$jwt.hasToken("customStorageKey");
// Return token from cookies or local storage
this.$jwt.getToken();
// Or
this.$jwt.getToken("customStorageKey");
// Checking if the JWT Token is expired
this.$jwt.isExpired();
// Or
this.$jwt.isExpired("customStorageKey");
// Decode JWT token and return payload
this.$jwt.decode();
// Or
this.$jwt.decode(null, null, "customStorageKey");
You can also specify a custom token and sign key:
this.$jwt.decode(customToken, secretKey);
// Or
this.$jwt.decode(customToken, secretKey, "customStorageKey");
You can also specify a custom token and sign key:
this.$jwt.isExpired(customToken, secretKey);
// Or
this.$jwt.isExpired(customToken, secretKey, "customStorageKey");
$jwt object is also available outside of components using Vue object:
import Vue from "vue";
const payload = Vue.$jwt.decode();
signKey (optional) : Token signature public key - to be provided only if you want to verify signature when decoding token
storage (default: localStorage) : cookie | localStorage
keyName (default: auth_token) : name of the key used to fetch token from cookie or local storage
ignoreExpiration (default: false) : set true to ignore expiration date
ignoreNotBefore (default: false) : set true to ignore 'not before' date
audience (default: null) : you can specify a string if you want to validate token audience property
issuer (default: null) : you can specify a string if you want to validate token issuer
subject (default: null) : you can specify a string if you want to validate token subject
FAQs
Lightweight JWT library for Vue.js 2
We found that hpsweb-vuejs-jwt demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.