NextAuth.js

Open-source authentication for Next.js with OAuth, OIDC, email, and passkey sign-in.

Library
npm
v4.24.15
28,366 stars
ISC

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
59 /100 Fair
Development Activity 16
Maintenance 44
Community 76
Maturity 60
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
86 /100 Excellent
Architecture 88
Code Quality 82
Innovation 90
Learning Curve 70

NextAuth.js is the official Auth.js integration for Next.js, providing a complete authentication layer for App Router and Pages Router applications. A single NextAuth() call wires up route handlers, session management, and helpers for signing users in and out, while built-in support for OAuth 2.0, OIDC, email/passwordless, and WebAuthn passkeys covers the sign-in methods most apps need.

Built on standard Web APIs through the @auth/core runtime, it runs anywhere Next.js does — Node.js, serverless, and edge — and works with or without a database via pluggable adapters. It is secure by default, using encrypted JWTs, CSRF protection, and restrictive cookie policies out of the box.

What You Get

  • A single NextAuth() factory that returns route handlers and auth/signIn/signOut helpers
  • Built-in providers for dozens of OAuth/OIDC services plus email and credentials sign-in
  • React client with SessionProvider and useSession for accessing session state anywhere
  • Database adapters for Postgres, MySQL, MongoDB, Prisma, Drizzle, and many more
  • Passkey/WebAuthn support and encrypted, CSRF-protected sessions by default

Common Use Cases

  • Adding social login (GitHub, Google, etc.) to a Next.js application
  • Implementing passwordless email or passkey authentication
  • Protecting App Router pages and API routes with session-aware middleware
  • Persisting users and sessions to a database through an adapter

Under The Hood

Architecture — The public surface lives in packages/next-auth/src, where the NextAuth() factory in index.ts accepts a config (or a request-aware function) and returns { handlers, auth, signIn, signOut, unstable_update }. The handlers.GET/POST delegate to Auth(reqWithEnvURL(req), config) from @auth/core, which does the real OAuth/OIDC/session work; initAuth and setEnvDefaults in src/lib layer Next.js-specific request handling and environment inference on top. The React client in react.tsx ships a SessionProvider and useSession hook that fetch session state from the auth API base URL.

Tech Stack — Written almost entirely in TypeScript (~94% of the repo). The package depends on the workspace @auth/core runtime and declares peer dependencies on next, react, nodemailer, and @simplewebauthn packages (the latter optional for passkeys). The repo is a pnpm + Turborepo monorepo housing packages/core, the many database adapters, and per-framework integrations; the package builds with tsc and generates provider entry points via a shared script.

Code Quality — Tests exist and run on Vitest (actions.test.ts, env.test.ts, middleware-fail-closed.test.ts) alongside Playwright end-to-end suites, using a shared config from packages/utils. The codebase is strongly typed with dedicated types.ts modules, and security-sensitive defaults (encrypted JWE tokens, CSRF, fail-closed middleware) are explicitly covered.

API Design — The developer experience is a highlight: a single NextAuth() call yields everything an app needs, providers are imported by path (e.g. next-auth/providers/github), and environment variables like AUTH_GITHUB_ID are inferred automatically to minimize boilerplate. Documentation is extensive both inline (rich JSDoc module comments) and on the authjs.dev site.

Used by 47 apps in this directory

Python
100%
Other

Sourcebot

AI Code Assistants · Developer Tools · Search

4,005

A self-hosted, AI-powered code search engine that indexes every repo across GitHub, GitLab, Bitbucket, Gitea, Gerrit, and Azure DevOps, so both engineers and coding agents can search, browse, and ask questions about your codebase from one place.

View details
86
Repo Health
83
Technical
61
Dependency
Built with
Python 100%
Updated 1 weeks ago
Python
100%
Other

Sourcebot

AI Code Assistants · Developer Tools · Search

4,005

A self-hosted, AI-powered code search engine that indexes every repo across GitHub, GitLab, Bitbucket, Gitea, Gerrit, and Azure DevOps, so both engineers and coding agents can search, browse, and ask questions about your codebase from one place.

View details
86
Repo Health
83
Technical
61
Dependency
Built with
Python 100%
Updated 1 weeks ago
TypeScript
96%
MIT

SplitPro

Invoicing Finance

1,474

Self-hosted, open source expense splitting with multi-currency, recurring bills, and bank imports — a complete Splitwise replacement you control.

View details
86
Repo Health
77
Technical
69
Dependency
Built with
TypeScript 96%
Updated 1 weeks ago
TypeScript
96%
MIT

SplitPro

Invoicing Finance

1,474

Self-hosted, open source expense splitting with multi-currency, recurring bills, and bank imports — a complete Splitwise replacement you control.

View details
86
Repo Health
77
Technical
69
Dependency
Built with
TypeScript 96%
Updated 1 weeks ago
TypeScript
98%
Apache 2.0

Tianji

Analytics · Monitoring

3,119

Replace Google Analytics, UptimeKuma, and Prometheus with one self-hosted platform that tracks websites, monitors uptime, and reports server health.

View details
86
Repo Health
76
Technical
64
Dependency
Built with
TypeScript 98%
Updated 6 days ago
TypeScript
98%
Apache 2.0

Tianji

Analytics · Monitoring

3,119

Replace Google Analytics, UptimeKuma, and Prometheus with one self-hosted platform that tracks websites, monitors uptime, and reports server health.

View details
86
Repo Health
76
Technical
64
Dependency
Built with
TypeScript 98%
Updated 6 days ago
TypeScript
98%
Apache 2.0

TinaCMS

CMS

13,845

An open-source, Git-backed headless CMS that gives editors a live visual editing UI over Markdown, MDX, JSON, and YAML content while developers keep everything in version control.

View details
92
Repo Health
74
Technical
59
Dependency
Built with
TypeScript 98%
Updated 6 days ago
TypeScript
65%
Other

Typebot

AI Assistants · AI Development · Developer Tools

10,576

Build sophisticated chatbots visually, embed them anywhere without iframes, and own your data — fully self-hostable with a modular block system and 30+ integrations.

View details
94
Repo Health
82
Technical
64
Dependency
Built with
TypeScript 65%
MDX 34%
Updated 6 days ago
TypeScript
65%
Other

Typebot

AI Assistants · AI Development · Developer Tools

10,576

Build sophisticated chatbots visually, embed them anywhere without iframes, and own your data — fully self-hostable with a modular block system and 30+ integrations.

View details
94
Repo Health
82
Technical
64
Dependency
Built with
TypeScript 65%
MDX 34%
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