@nestjs/jwt

Official NestJS module for signing, verifying, and decoding JWTs

Library
npm
v11.0.2
687stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
79/100Good
Development Activity100
Maintenance72
Community56
Maturity60
Momentum28

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
78/100Good
Architecture80
Code Quality82
Innovation65
Learning Curve85

@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

Amplication

Developer Tools · AI Code Assistants · Automation

16,010

Create production-ready backend services with your organization's standards baked in — generating NestJS, Prisma, and GraphQL code that you own and control.

View details
61
Repo Health
84
Technical
60
Dependency
Built with
TypeScript96%
Updated 1 months ago
TypeScript
97%
AGPL 3.0

Bigcapital

Invoicing Finance

3,846

Self-hostable double-entry accounting platform with invoicing, inventory, multi-currency, and real-time financial reporting for small and medium businesses.

View details
91
Repo Health
77
Technical
64
Dependency
Built with
TypeScript97%
Updated yesterday
TypeScript
96%
Other

Cal.diy

Scheduling

47,796

The 100% MIT-licensed, community-driven scheduling platform — self-host your own booking infrastructure with no enterprise strings attached.

View details
93
Repo Health
86
Technical
66
Dependency
Built with
TypeScript96%
Updated 1 weeks ago
TypeScript
95%
AGPL 3.0

Docmost

Productivity · Note Taking · Collaboration

21,411

Self-hosted collaborative wiki and knowledge base with real-time editing, diagrams, AI assistance, and enterprise access controls — a modern alternative to Confluence and Notion.

View details
89
Repo Health
70
Technical
71
Dependency
Built with
TypeScript95%
Updated yesterday
TypeScript
74%
AGPL 3.0

Ghostfolio

Invoicing Finance

9,153

Track your stocks, ETFs, and crypto with a privacy-first, self-hostable wealth management platform built for data-driven investors.

View details
93
Repo Health
79
Technical
71
Dependency
Built with
TypeScript74%
HTML23%
Updated yesterday
TypeScript
98%
Other

Hexabot

AI Development · Automation

1,186

Build and run agentic workflows across channels with YAML, tools, and RAG

View details
79
Repo Health
76
Technical
70
Dependency
Built with
TypeScript98%
Updated yesterday
TypeScript
67%
MIT

Hoppscotch

Developer Tools

80,055

A lightweight, offline-capable API development ecosystem for testing HTTP, GraphQL, WebSocket, MQTT, and SSE endpoints across web, desktop, and CLI.

View details
91
Repo Health
83
Technical
66
Dependency
Built with
TypeScript67%
Vue23%
Updated 3 days ago
TypeScript
94%
AGPL 3.0

Laudspeaker

Marketing · Automation

2,618

Open-source customer engagement platform for building visual, event-triggered messaging journeys across email, SMS, push, in-app, and webhooks.

View details
53
Repo Health
66
Technical
64
Dependency
Built with
TypeScript94%
Updated 1 months ago
TypeScript
98%
Other

Novu

Developer Tools

39,615

Open-source communication infrastructure that connects your products and AI agents to every channel your users live on — Inbox, Email, SMS, Push, Chat, and more.

View details
93
Repo Health
80
Technical
65
Dependency
Built with
TypeScript98%
Updated today

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

Search