1import jwt_decode from "jwt-decode";
2var token = "eyJ0eXAiO...";
3var decoded = jwt_decode(token);
4console.log(decoded);
5
6/* prints: * { foo: "bar", * exp: 1393286893, * iat: 1393268893 } */
1import jwt_decode from "jwt-decode";
2
3var token = "eyJ0eXAiO.../// jwt token";
4var decoded = jwt_decode(token);
5
6console.log(decoded);
7
8/* prints:
9 * { foo: "bar",
10 * exp: 1393286893,
11 * iat: 1393268893 }
12 */
13
14// decode header by passing in options (useful for when you need `kid` to verify a JWT):
15var decodedHeader = jwt_decode(token, { header: true });
16console.log(decodedHeader);
17
18/* prints:
19 * { typ: "JWT",
20 * alg: "HS256" }
21 */