@nestjs/jwt

Official NestJS module for signing, verifying, and decoding JWTs

Library
npm
v12.0.2
688 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
78 /100 Good
Development Activity 96
Maintenance 72
Community 56
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

Amplication

AI Code Assistants · Automation · Developer Tools

16,015

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
58
Repo Health
84
Technical
60
Dependency
Built with
TypeScript 96%
Updated 3 months ago
TypeScript
97%
AGPL 3.0

Bigcapital

Invoicing Finance

3,916

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

View details
90
Repo Health
77
Technical
61
Dependency
Built with
TypeScript 97%
Updated 6 days ago
TypeScript
96%
Other

Cal.diy

Scheduling

48,697

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

View details
91
Repo Health
86
Technical
65
Dependency
Built with
TypeScript 96%
Updated 6 days ago
TypeScript
95%
AGPL 3.0

Docmost

CMS · Collaboration · Note Taking

21,801

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
69
Dependency
Built with
TypeScript 95%
Updated 5 days ago
TypeScript
76%
AGPL 3.0

Ghostfolio

Invoicing Finance

9,367

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
67
Dependency
Built with
TypeScript 76%
HTML 21%
Updated 5 days ago
TypeScript
98%
Other

Hexabot

AI Development · Automation

1,260

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

View details
78
Repo Health
76
Technical
65
Dependency
Built with
TypeScript 98%
Updated 1 weeks ago
TypeScript
67%
MIT

Hoppscotch

Developer Tools

80,529

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
65
Dependency
Built with
TypeScript 67%
Vue 25%
Updated 6 days ago
TypeScript
94%
AGPL 3.0

Laudspeaker

Automation · Marketing

2,626

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

View details
51
Repo Health
66
Technical
62
Dependency
Built with
TypeScript 94%
Updated 2 months ago
TypeScript
98%
Other

Novu

Developer Tools

40,084

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
64
Dependency
Built with
TypeScript 98%
Updated 5 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