{
 "kind": "tool",
 "slug": "next-auth",
 "path": "tools/next-auth/",
 "name": "NextAuth.js",
 "maker": null,
 "density": "profile",
 "crumbs": [
  [
   "Tools",
   "tools/"
  ],
  [
   "Auth and security libraries",
   "tools/auth-security/"
  ]
 ],
 "lead": "Complete open-source authentication solution designed for Next.js applications.",
 "chips": [
  {
   "label": "Auth and security libraries",
   "path": "tools/auth-security/"
  },
  {
   "label": "NPM"
  }
 ],
 "primary": {
  "label": "Copy install command",
  "copy": "npm install next-auth"
 },
 "links": [
  {
   "label": "GitHub",
   "href": "https://github.com/nextauthjs/next-auth"
  },
  {
   "label": "Website",
   "href": "https://authjs.dev"
  }
 ],
 "track": "New versions, deprecation and license changes on your dashboard",
 "verdicts": [
  {
   "key": "license",
   "label": "License",
   "value": "ISC",
   "status": "yes",
   "sub": "Use it in paid apps",
   "quote": null,
   "note": "License from npm.",
   "src": "https://github.com/nextauthjs/next-auth"
  },
  {
   "key": "maint",
   "label": "Maintained",
   "value": "Maintained",
   "status": "yes",
   "sub": "Last change Jul 22, 2026",
   "note": "Latest GitHub release Jul 20, 2026. ",
   "src": "https://github.com/nextauthjs/next-auth"
  },
  {
   "key": "pop",
   "label": "Used by agents' projects",
   "value": "150 projects",
   "status": "info",
   "sub": "#2 of 141 in its category",
   "note": "Dependency in 150 public GitHub projects set up for AI coding agents that we scanned (2.4%).",
   "src": null
  },
  {
   "key": "agent",
   "label": "Agent access",
   "value": "Install only",
   "status": "info",
   "sub": null,
   "note": "Agent skills for this library in the skills catalog; community skills are written by others, read them before you install.",
   "src": null
  }
 ],
 "vfoot": "From the package registry and GitHub, checked daily.",
 "blocks": [
  {
   "id": "overview",
   "nav": "Overview",
   "h2": "What NextAuth.js does",
   "parts": [
    {
     "t": "prose",
     "text": "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."
    }
   ]
  },
  {
   "id": "popularity",
   "nav": "Popularity",
   "h2": "NextAuth.js popularity",
   "parts": [
    {
     "t": "stats",
     "items": [
      {
       "n": "75",
       "of": "/ 100",
       "l": "Gid Score, #198 overall"
      },
      {
       "n": "9.4M",
       "l": "downloads a week, npm"
      },
      {
       "n": "28.4K",
       "l": "GitHub stars"
      },
      {
       "n": "150",
       "l": "agent projects use it"
      }
     ]
    },
    {
     "t": "small",
     "text": "Gid Score measures public popularity and activity, not quality.",
     "link": "How the Gid Score is calculated",
     "path": "tools/top/"
    }
   ]
  },
  {
   "id": "usage",
   "nav": "How it is used",
   "h2": "How NextAuth.js is used",
   "parts": [
    {
     "t": "list",
     "items": [
      "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%)."
     ]
    },
    {
     "t": "h3",
     "text": "By coding agent"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "87 projects, 2.9%",
       "v": "GitHub Copilot",
       "path": "agents/github-copilot/"
      },
      {
       "l": "72 projects, 2.2%",
       "v": "Claude Code",
       "path": "agents/claude-code/"
      },
      {
       "l": "62 projects, 2.5%",
       "v": "Cursor",
       "path": "agents/cursor/"
      },
      {
       "l": "11 projects, 2.3%",
       "v": "OpenAI Codex",
       "path": "agents/openai-codex/"
      },
      {
       "l": "10 projects, 2.1%",
       "v": "Gemini CLI",
       "path": "agents/gemini-cli/"
      },
      {
       "l": "8 projects, 2.9%",
       "v": "Devin Desktop",
       "path": "agents/devin-desktop/"
      },
      {
       "l": "6 projects, 1.7%",
       "v": "OpenCode",
       "path": "agents/opencode/"
      },
      {
       "l": "5 projects, 1.5%",
       "v": "OpenClaw",
       "path": "agents/openclaw/"
      }
     ]
    },
    {
     "t": "h3",
     "text": "Often used with"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "In 99.3% of its projects",
       "v": "Next.js",
       "path": "tools/next/"
      },
      {
       "l": "In 83.3% of its projects",
       "v": "Lucide React",
       "path": "tools/lucide-react/"
      },
      {
       "l": "In 82.0% of its projects",
       "v": "clsx",
       "path": "tools/clsx/"
      },
      {
       "l": "In 78.0% of its projects",
       "v": "Tailwind Merge",
       "path": "tools/tailwind-merge/"
      },
      {
       "l": "In 99.3% of its projects",
       "v": "React",
       "path": "tools/react/"
      },
      {
       "l": "In 97.3% of its projects",
       "v": "Tailwind CSS",
       "path": "tools/tailwindcss/"
      },
      {
       "l": "In 68.7% of its projects",
       "v": "Class Variance Authority",
       "path": "tools/class-variance-authority/"
      },
      {
       "l": "In 62.7% of its projects",
       "v": "Radix UI",
       "path": "tools/radix-ui/"
      }
     ]
    }
   ]
  },
  {
   "id": "profile",
   "nav": "Profile",
   "h2": "NextAuth.js in practice",
   "parts": [
    {
     "t": "h3",
     "text": "Strengths"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "Encrypted tokens and CSRF checks by default",
       "v": "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.\""
      },
      {
       "l": "Works with or without a database",
       "v": "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."
      },
      {
       "l": "Built for any OAuth 2.0+ or OIDC service",
       "v": "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."
      },
      {
       "l": "Same setup across Next.js, SvelteKit, Express and Qwik",
       "v": "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."
      }
     ]
    },
    {
     "t": "h3",
     "text": "Watch out for"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "The maintainers point new projects to Better Auth",
       "v": "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."
      },
      {
       "l": "Mixed signals on v5",
       "v": "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."
      },
      {
       "l": "Upgrading to 4.24.15 fails in-flight sign-ins once",
       "v": "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."
      }
     ]
    }
   ]
  },
  {
   "id": "more",
   "nav": null,
   "spy_as": "profile",
   "h2": "More about NextAuth.js",
   "parts": [
    {
     "t": "more",
     "items": [
      {
       "title": "Head to head",
       "items": [
        {
         "text": "NextAuth.js vs Better Auth",
         "note": "used together in 3 projects",
         "path": "tools/compare/nextauthjs-vs-better-auth/"
        },
        {
         "text": "NextAuth.js vs Clerk",
         "note": "used together in 5 projects",
         "path": "tools/compare/nextauthjs-vs-clerk/"
        }
       ]
      },
      {
       "title": "Packages around it",
       "items": [
        "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"
       ]
      },
      {
       "title": "More in Auth and security libraries",
       "path": "tools/auth-security/",
       "items": [
        {
         "text": "bcryptjs",
         "path": "tools/bcryptjs/"
        },
        {
         "text": "jsonwebtoken",
         "path": "tools/jsonwebtoken/"
        },
        {
         "text": "cryptography",
         "path": "tools/cryptography/"
        },
        {
         "text": "PyJWT",
         "path": "tools/pyjwt/"
        },
        {
         "text": "jose",
         "path": "tools/jose/"
        },
        {
         "text": "DOMPurify",
         "path": "tools/dompurify/"
        },
        {
         "text": "Helmet",
         "path": "tools/helmet/"
        },
        {
         "text": "bcrypt (JavaScript)",
         "path": "tools/bcrypt-npm/"
        }
       ]
      }
     ]
    }
   ]
  },
  {
   "id": "alternatives",
   "nav": "Alternatives",
   "h2": "Alternatives",
   "parts": [
    {
     "t": "alts",
     "items": [
      {
       "name": "NextAuth.js",
       "me": true,
       "facts": [
        "ISC",
        "Gid 75",
        "9.4M/wk"
       ]
      },
      {
       "name": "Better Auth",
       "why": "Comprehensive authentication framework for TypeScript with multiple strategies.",
       "path": "tools/better-auth/",
       "facts": [
        "MIT",
        "Gid 79",
        "21.1M/wk"
       ]
      },
      {
       "name": "Clerk",
       "why": "Modern authentication and user management SDK for Next.js and React.",
       "path": "tools/clerk/",
       "facts": [
        "MIT",
        "Gid 62",
        "4.1M/wk"
       ]
      },
      {
       "name": "Passport.js",
       "why": "Modular authentication middleware for Node.js supporting OAuth, JWT and local strategies.",
       "path": "tools/passport/",
       "facts": [
        "MIT",
        "Gid 69",
        "10.5M/wk"
       ]
      }
     ],
     "more": "Compare NextAuth.js with another tool",
     "more_path": "tools/compare/"
    }
   ]
  },
  {
   "id": "start",
   "nav": "Get started",
   "h2": "Get started",
   "parts": [
    {
     "t": "install",
     "intro": "Install it.",
     "code": "npm install next-auth"
    },
    {
     "t": "h3",
     "text": "Rules for your agent"
    },
    {
     "t": "rules",
     "label": "Paste into AGENTS.md or CLAUDE.md",
     "text": "## NextAuth.js\n- 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.\n- 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`.\n- To add session fields, use `declare module \"next-auth\"` module augmentation, not generics. Put JWT fields in `declare module \"next-auth/jwt\"`.\n- When augmenting `Session[\"user\"]`, intersect with `DefaultSession[\"user\"]`, or the default user properties are overwritten.\n- Put the module declaration in a file that is included in `tsconfig.json`.\n- 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.\n- Report suspected vulnerabilities through the Security Policy, not public issues or PRs.\n"
    }
   ]
  }
 ],
 "glance": [
  [
   "Package",
   "npm next-auth"
  ],
  [
   "Category",
   "Auth and security libraries"
  ],
  [
   "License",
   "ISC"
  ],
  [
   "Latest version",
   "next-auth@4.24.15, July 20, 2026"
  ],
  [
   "On GitHub since",
   "January 2018"
  ],
  [
   "Gid Score",
   "75.3"
  ],
  [
   "Rank in category",
   "#2 of 141"
  ],
  [
   "GitHub",
   "nextauthjs/next-auth"
  ],
  [
   "Last change",
   "Jul 22, 2026"
  ]
 ],
 "good": [],
 "checked_line": "From the package registry, GitHub and our scan of public agent projects; numbers update daily.",
 "logo": "https://agentgid.com/media/avatars/nextauthjs.png"
}