🔒
Auth8M+/wkMIT

jose

jose is a universal, standards-compliant JavaScript library implementing JSON Object Signing and Encryption (JOSE) specifications including JWS (JSON Web Signat

Installation

npm
npm install jose
yarn
yarn add jose
pnpm
pnpm add jose

Import

ESM
import { SignJWT, jwtVerify } from 'jose';

Quick Example

usage
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

Packagejose
CategoryAuth
Weekly Downloads8M+
LicenseMIT
Installnpm install jose

Related Packages

Browse npm Packages by Category

Explore our reference of 200 popular npm packages with install commands, examples, and quick-start guides.