@nestjs/passport

The official NestJS integration module for the Passport authentication middleware

Library
npm
v11.0.5
556stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
84/100Excellent
Development Activity100
Maintenance84
Community64
Maturity60
Momentum28

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
75/100Good
Architecture78
Code Quality82
Innovation60
Learning Curve80

@nestjs/passport is the official bridge between the NestJS framework and Passport, the widely-used Node.js authentication middleware with hundreds of strategy plugins (local, JWT, OAuth providers, SAML, and more). It wraps Passport’s callback-based strategy pattern in NestJS-idiomatic constructs — an AuthGuard and a PassportStrategy mixin — so authentication logic can be declared with decorators and dependency injection instead of manually wiring Express middleware.

The module itself is intentionally small: its job is to adapt Passport’s strategy.authenticate() lifecycle into NestJS’s guard and request-lifecycle model, letting any of Passport’s existing strategy packages be dropped into a Nest application with a few lines of glue code.

What You Get

  • AuthGuard('strategy-name') - a guard factory that authenticates incoming requests using any registered Passport strategy
  • PassportStrategy mixin - lets you define a custom strategy class as an injectable Nest provider that extends a Passport strategy
  • PassportModule - registers Passport strategies with Nest’s module system, with register() and registerAsync() for static and dynamic configuration
  • Compatibility with the full Passport strategy ecosystem (local, JWT, Google, GitHub, SAML, and hundreds of others)
  • TypeScript types for strategy options and validated user payloads

Common Use Cases

  • Adding username/password (local strategy) login to a NestJS REST or GraphQL API
  • Protecting routes with JWT bearer-token authentication via passport-jwt
  • Wiring up third-party OAuth login (Google, GitHub, etc.) using existing Passport strategy packages
  • Building a multi-strategy auth setup (e.g. local login plus JWT-protected API routes) in one Nest application

Under The Hood

Architecture The package is a thin adapter layer, roughly 428 lines across lib/: abstract.strategy.ts and passport.module.ts provide the module wiring, auth.guard.ts implements AuthGuard() as a Nest CanActivate guard that instantiates and invokes a named Passport strategy, and passport/ holds the strategy mixin machinery that lets a class extend both a Passport strategy and participate in Nest’s provider system. Tech Stack Built in TypeScript against @nestjs/common as a peer dependency and passport itself (supporting ^0.5.0 through ^0.7.0), with no other runtime dependencies — it deliberately stays a pass-through layer rather than reimplementing any authentication logic. Code Quality Tests live under test/with-register and test/without-register, explicitly covering both the static (register()) and dynamic module registration code paths, run via Vitest with coverage reporting (test:cov) — a structure that shows the two registration modes are treated as first-class, independently-tested behaviors rather than one being an afterthought. API Design The AuthGuard('name') factory and PassportStrategy mixin map directly onto NestJS’s existing guard and provider conventions, so a developer already familiar with Nest’s DI and decorators needs to learn almost nothing new to add authentication — the main friction is understanding Passport’s own strategy configuration, which this package doesn’t abstract away.

Used by 15 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
64%
Other

NocoDB

No Code Platforms · Databases · Low Code Platforms

64,586

Turn any SQL database into a collaborative no-code spreadsheet with automatic REST APIs and real-time views.

View details
91
Repo Health
77
Technical
64
Dependency
Built with
TypeScript64%
Vue31%
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