Skip to content
Agents tracked: 506 Releases (7d): 634 Agent status: 3 with issuesSince last limit reset: Claude 15d · Codex 0d For AI agents: Markdown Updated Nov 26, 2026

NextAuth.js

Complete open-source authentication solution designed for Next.js applications.

Auth and security librariesNPM

GitHubWebsite

1. License

License from npm.

github.com/nextauthjs/next-auth

From the package registry and GitHub, checked daily. Tap a verdict to see its source.How we checkedReport an error

What NextAuth.js does

NextAuth.js is the Next.js package of Auth.js, an open-source auth project that now sits under Better Auth, and its own README steers new projects to Better Auth unless they need a specific gap filled, most notably stateless sessions without a database.

NextAuth.js popularity

75 / 100
Gid Score, #198 overall
9.4M
downloads a week, npm
28.4K
GitHub stars
150
agent projects use it
NextAuth.js: downloads per weeknpm, next-auth 9,439,943
NextAuth.js: GitHub starsnextauthjs/next-auth 28,389

Gid Score measures public popularity and activity, not quality. How the Gid Score is calculated

How NextAuth.js is used

  • NextAuth.js is a dependency in 150 of the 6,258 public GitHub projects set up for AI coding agents that we scanned (3.1% of the 4,867 JavaScript/TypeScript ones), #2 of 141 in auth and security libraries.
  • Counting the projects our scan samples by dependency (Solana 3,067, Ethereum and EVM 1,774, 3D and games 3,130, agent frameworks and SDKs 13,750), it appears in 455; those are left out of every share on this page.
  • The most used alternative in our scan is Better Auth (103 projects).
  • Projects that use it most often also use Next.js (99.3%), Lucide React (83.3%), clsx (82.0%).

By coding agent

87 projects, 2.9%
72 projects, 2.2%
62 projects, 2.5%
11 projects, 2.3%
10 projects, 2.1%
8 projects, 2.9%
6 projects, 1.7%
5 projects, 1.5%

Often used with

In 99.3% of its projects
In 83.3% of its projects
In 82.0% of its projects
In 78.0% of its projects
In 99.3% of its projects
In 97.3% of its projects
In 68.7% of its projects
In 62.7% of its projects

NextAuth.js in practice

Strengths

Encrypted tokens and CSRF checks by default

The README says JWTs are encrypted by default (JWE with A256CBC-HS512). It also says CSRF tokens guard the sign-in and sign-out POST routes. The maintainers write that the default cookie policy "aims for the most restrictive policy appropriate for each cookie."

Works with or without a database

The README says Auth.js "can be used with or without a database." Without one, it describes stateless authentication against backends such as Active Directory or LDAP. With one, it claims built-in support for MySQL, MariaDB, Postgres, Microsoft SQL Server, MongoDB, SQLite and GraphQL, among others.

Built for any OAuth 2.0+ or OIDC service

The README says it is designed to work with any OAuth service that supports 2.0+ or OIDC. It also ships built-in support for many popular sign-in services.

Same setup across Next.js, SvelteKit, Express and Qwik

The homepage shows one pattern in four frameworks. Each passes a <code>providers</code> array to a framework wrapper such as <code>SvelteKitAuth</code>, <code>ExpressAuth</code> or <code>QwikAuth$</code>, and imports providers from that package.

Watch out for

The maintainers point new projects to Better Auth

The README announces that Auth.js has joined Better Auth. It recommends that new projects start with Better Auth unless they hit a specific feature gap, with stateless sessions without a database named as the main one.

Mixed signals on v5

The newest release in the sources is on the 4.x line. An HTML comment in the README, which may be out of date, refers to NextAuth.js v5 as not yet stable. The docs also have a "Migrating to v5" page. Our reading is that it is worth checking which major version a guide assumes before copying from it.

Upgrading to 4.24.15 fails in-flight sign-ins once

OAuth check cookies are now tied to the provider that set them. The release notes warn that sign-ins started before the upgrade fail one time and succeed on retry.

More about NextAuth.js

Head to head
Packages around it
  • next: Next.js framework
  • clsx: className string builder
  • tailwind-merge: Tailwind class conflict merging
  • tailwindcss: Utility-first CSS
  • class-variance-authority: Component style variants
  • lucide-react: Icon set for React
More in Auth and security libraries

Alternatives

NextAuth.js This page

ISCGid 759.4M/wk

Better Auth

Comprehensive authentication framework for TypeScript with multiple strategies.

MITGid 7921.1M/wk

Clerk

Modern authentication and user management SDK for Next.js and React.

MITGid 624.1M/wk

Passport.js

Modular authentication middleware for Node.js supporting OAuth, JWT and local strategies.

MITGid 6910.5M/wk

Compare NextAuth.js with another tool

Get started

Install it.

npm install next-auth

Rules for your agent

Paste into AGENTS.md or CLAUDE.md
## NextAuth.js
- Before adding `next-auth` to a new project, flag that the README recommends Better Auth for new projects unless a specific gap applies, most notably stateless sessions without a database.
- Define config once in `auth.ts` with `NextAuth({ providers: [...] })` and export `auth` and `handlers`. Re-export `handlers` as `GET` and `POST` from `app/api/auth/[...nextauth]/route.ts`.
- To add session fields, use `declare module "next-auth"` module augmentation, not generics. Put JWT fields in `declare module "next-auth/jwt"`.
- When augmenting `Session["user"]`, intersect with `DefaultSession["user"]`, or the default user properties are overwritten.
- Put the module declaration in a file that is included in `tsconfig.json`.
- On the 4.x line, use 4.24.15 or later for the OAuth cookie binding and email normalization fixes. Expect sign-ins in flight during the upgrade to fail once.
- Report suspected vulnerabilities through the Security Policy, not public issues or PRs.