jwtea is an ultra-lightweight JWT implementation in TypeScript, compiled to Native ESM with minimum dependencies.
Some jwtea
features are:
-
✔️ Native ESM and CommonJS support -
🔨 Types out of the box -
🗜️ 2x smaller bundler size than jsonwebtoken -
⚡ Faster than jsonwebtoken and jose
Install
jwtea requires Node.js 12.4.0 or newer. It is recommended to use pnpm, but you can also use either npm
or yarn
.
# npm
npm i jwtea
# pnpm
pnpm i jwtea
# yarn
yarn add jwtea
Get Started
This library is pretty similiar to node-jsonwebtoken
that we all already know. Just replace commonjs import to esm import and you're good to go.
Synchronous Sign with default algotrithm (HMAC SHA256)
import { sign } from "jwtea"
const token = sign({ foo: "bar" }, "verystrongsecret")
Sign asynchronously
import { sign } from "jwtea"
const token = sign({ foo: "bar" }, "verystrongsecret", (err, token) => {
console.log(token)
})
Verify synchronously
import { verify } from "jwtea"
const decoded = verify(token, "verystrongsecret")
Verify asynchronously
import { verify } from "jwtea"
const decoded = verify(token, "verystrongsecret", (err, payload) => {
console.log(payload)
})
Docs
You can see the documentation here. (WIP)
License
MIT © elianiva