Install with NPM or Yarn
npm install jwt-decode
//or
yarn add jwt-decode
//or
yarn add jwt-decode
Import package:
import { jwtDecode } from “jwt-decode”;
Usage
const token = “eyJ0eXAiO…/// jwt token”;
// Returns with the JwtPayload type or any type
// const decodedJwt = jwtDecode<JwtPayload>(token);
const decodedJwt: any = jwtDecode(token);
// Returns with the JwtPayload type or any type
// const decodedJwt = jwtDecode<JwtPayload>(token);
const decodedJwt: any = jwtDecode(token);
//example print expiration date
console.log(decodedJwt.exp);