jose
jose is a universal, standards-compliant JavaScript library implementing JSON Object Signing and Encryption (JOSE) specifications including JWS (JSON Web Signat…
Installation
npm install jose
yarn add jose
pnpm add jose
Import
import { SignJWT, jwtVerify } from 'jose';Quick Example
import { SignJWT, jwtVerify } from 'jose';
const secret = new TextEncoder().encode(process.env.JWT_SECRET);
const token = await new SignJWT({ userId: 123 })
.setProtectedHeader({ alg: 'HS256' })
.setExpirationTime('1h')
.sign(secret);
const { payload } = await jwtVerify(token, secret);About jose
jose is a universal, standards-compliant JavaScript library implementing JSON Object Signing and Encryption (JOSE) specifications including JWS (JSON Web Signature), JWE (JSON Web Encryption), JWT (JSON Web Tokens), JWK (JSON Web Keys), and JWKS (JSON Web Key Sets). Unlike jsonwebtoken which focuses on JWTs with a simple API, jose provides the complete JOSE specification suite with support for both signing and encrypting tokens. The library works across all JavaScript runtimes — Node.js, browsers, Deno, Bun, Cloudflare Workers, and Edge Runtime — by using the Web Crypto API (SubtleCrypto) as its cryptographic backend rather than Node.js-specific crypto modules. jose supports all standard algorithms including RSA, ECDSA, EdDSA, HMAC for signing, and RSA-OAEP, ECDH-ES, A256GCM for encryption. The library provides functions for creating and verifying JWTs, importing and exporting JWKs, fetching JWKS from remote endpoints with caching, and encrypting JWT payloads for confidentiality. jose has become the recommended JWT library for modern JavaScript development, particularly for edge and serverless environments where the Web Crypto API is the only available cryptographic interface.
Quick Facts
| Package | jose |
| Category | Auth |
| Weekly Downloads | 8M+ |
| License | MIT |
| Install | npm install jose |
Related Packages
jsonwebtoken is the most widely used library for creating and verifying JSON Web Tokens (JWTs) in No…
Passport is the most popular authentication middleware for Node.js, providing a modular framework fo…
bcrypt is a library for hashing passwords using the bcrypt algorithm, which is specifically designed…
Next.js is the leading React framework for building full-stack web applications, developed and maint…
Browse npm Packages by Category
Explore our reference of 200 popular npm packages with install commands, examples, and quick-start guides.