@nestjs/jwt

Official NestJS module for signing, verifying, and decoding JWTs

Library
npm
v12.0.3
687 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
79 /100 Good
Development Activity 96
Maintenance 72
Community 60
Maturity 60
Momentum 28

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
78 /100 Good
Architecture 80
Code Quality 82
Innovation 65
Learning Curve 85

@nestjs/jwt is the official Nest module wrapping the jsonwebtoken library, exposing a JwtService that any Nest provider can inject to sign, verify, and decode JSON Web Tokens. JwtModule.register()/registerAsync() configure secrets, signing algorithms, and key providers once at the module level, so individual providers don’t need to manage token logic themselves.

It supports both static secrets and dynamic key resolution via a secretOrKeyProvider function (with sync and async variants), plus asymmetric public/private key pairs for algorithms like RS256 — making it a drop-in building block for a Nest application’s authentication layer, typically paired with @nestjs/passport and a JWT strategy.

What You Get

  • A JwtModule.register()/registerAsync() API for configuring JWT secrets, algorithms, and expiry once at the module level
  • An injectable JwtService with sign(), verify(), and decode() methods available anywhere in the Nest dependency graph
  • Support for both static secrets and dynamic key resolution via secretOrKeyProvider (sync and async)
  • Support for asymmetric public/private key pairs for algorithms like RS256
  • Direct pass-through of jsonwebtoken’s sign/verify options, so existing jsonwebtoken configuration transfers directly

Common Use Cases

  • Issuing access tokens after a successful login in a Nest authentication service
  • Verifying bearer tokens inside a custom Nest guard or Passport JWT strategy
  • Rotating or dynamically resolving signing keys per-tenant via secretOrKeyProvider
  • Signing short-lived tokens for password-reset or email-verification links
  • Building a microservice-to-microservice auth handshake using shared or asymmetric JWT signing

Under The Hood

Architecture - The module follows Nest’s standard dynamic-module pattern: lib/jwt.module.ts implements register()/registerAsync() to wire up JwtService as a provider using the options supplied, lib/jwt.providers.ts resolves those options (including async factory/dependency-injected configuration), and lib/jwt.service.ts is a thin @Injectable() wrapper around the underlying jsonwebtoken package’s sign/verify/decode functions, adding support for the secretOrKeyProvider indirection layer.

Tech Stack - TypeScript, built against the @nestjs/common peer dependency (supporting Nest 8 through 11), depending on jsonwebtoken for the actual cryptographic signing/verification. Tests run under Vitest (migrated from Jest), linting via oxlint, and releases are cut with release-it and conventional commits enforced by commitlint.

Code Quality - lib/jwt.service.spec.ts is the primary test file, covering the service’s sign/verify/decode behavior including the async secretOrKeyProvider path; being a thin, focused wrapper around a well-tested underlying library (jsonwebtoken) keeps its own surface area — and therefore its bug surface — intentionally small. The codebase totals under 1,000 lines across lib/, consistent with its scope as a framework-integration module rather than a standalone cryptography implementation.

API Design - The two-touchpoint design (configure JwtModule once, inject JwtService everywhere) matches Nest’s idiomatic dependency-injection style, so using it requires no more boilerplate than any other Nest provider. Passing jsonwebtoken’s native options straight through to sign()/verify() means developers already familiar with that library carry their knowledge over directly rather than learning a new options schema.

Used by 14 apps in this directory

TypeScript
96%
Other

Refly

AI Development · Automation · No Code Platforms

7,537

Build deterministic, versioned agent skills from natural language—run them anywhere from Claude Code to Slack.

View details
68
Repo Health
76
Technical
63
Dependency
Built with
TypeScript 96%
Updated 1 weeks ago
TypeScript
97%
AGPL 3.0

Swetrix

Analytics

1,213

Privacy-first, cookieless web analytics with error tracking, session replays, and performance monitoring — self-host or use Cloud.

View details
87
Repo Health
71
Technical
66
Dependency
Built with
TypeScript 97%
Updated 1 weeks ago
TypeScript
99%
Other

Teable

Databases · No Code Platforms

21,920

A no-code PostgreSQL database with spreadsheet UX, real-time collaboration, and native AI agents — built for teams that outgrow Airtable.

View details
78
Repo Health
76
Technical
62
Dependency
Built with
TypeScript 99%
Updated 6 days ago
HTML
68%
AGPL 3.0

ToolJet

AI Agents · Low Code Platforms · No Code Platforms

41,123

Open-source AI-native platform to build and deploy internal tools, workflows, and AI agents with a visual drag-and-drop builder and 80+ data source integrations.

View details
94
Repo Health
81
Technical
63
Dependency
Built with
HTML 68%
JavaScript 20%
Updated 5 days ago
TypeScript
84%
Other

twenty

CRM

59,615

The open-source CRM you build, ship, and version like the rest of your stack — with customizable objects, AI agents, and a TypeScript SDK.

View details
92
Repo Health
82
Technical
64
Dependency
Built with
TypeScript 84%
MDX 14%
Updated 6 days ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers