@febin52/jwt-decode-lite
v1.0.2
Published
Lightweight, zero-dependency JWT header & payload decoder for edge runtimes & browser.
Maintainers
Readme
🔑 @febin52/jwt-decode-lite
Lightweight, zero-dependency JWT header & payload decoder for Edge runtimes, Cloudflare Workers, Node.js, and browser apps.
Safely parse and decode JSON Web Token (JWT) payloads and headers without pulling in heavy cryptographic node libraries.
🚀 Features
- ⚡ Zero Dependencies: Pure Base64URL string decoding.
- 🌐 Edge Ready: Runs anywhere JavaScript runs (Cloudflare Workers, Vercel Edge, Bun, Deno, Node.js, Browsers).
- 🛡️ Type-Safe: Generic return typing (
jwtDecode<MyPayload>(token)).
📦 Installation
npm install @febin52/jwt-decode-lite💡 Usage
import { jwtDecode } from '@febin52/jwt-decode-lite';
interface UserJwt {
sub: string;
name: string;
exp: number;
}
const token = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIn0.signature';
const payload = jwtDecode<UserJwt>(token);
console.log(payload.name); // 'John Doe'
console.log(payload.sub); // '1234567890'🔗 Links
- NPM Package: https://www.npmjs.com/package/@febin52/jwt-decode-lite
- GitHub Repository: https://github.com/febin52/jwt-decode-lite
- Issue Tracker: https://github.com/febin52/jwt-decode-lite/issues
📄 License
MIT © Febin Francis
