To be able to decode JWT token with JS you need to install jsonwebtoken package.
The best way to install it is through an npm package installer:
$npminstalljsonwebtoken
jsonwebtoken usage
First, you need to import the jsonwebtoken package:
constjwt=require('jsonwebtoken');
Second, we need to read and store a public key (used to decrypt a token). You need to get it from a dashboard beforehand and store somewhere near your project (./keys/id_rsa.pub).
constPUBLIC_KEY=fs.readFileSync('/path/to/public/key_public.pem'); // get public key
Then, we need to implement a function to verify a token using a public key: