payload-auth

payload auth

by payload-auth
payload-auth
Authentication & SSO
v3
>=3.79.1 <4
MIT

Overview

Summary generated from the README

payload-auth swaps Payload's built-in authentication for Better Auth, so the admin panel and your frontend share one session and one user table. It installs a database adapter that uses Payload's Local API and generates collections from the Better Auth schema. Requires Payload 3.79.1 or newer, Better Auth 1.5 or newer, and Next.js.

Features

  • Generates users, sessions, accounts and verifications collections from the Better Auth schema
  • Adds collections for enabled Better Auth plugins such as passkeys, two-factor, organizations and API keys
  • Replaces admin login, signup, forgot password, reset password and two-factor views
  • Defines roles once to feed Payload access control and the Better Auth admin plugin
  • Works with any Payload database adapter through the Local API

Use cases

  • Sign users in with Google on a Next.js site and have the same account recognized in the Payload admin
  • Add passkeys, two-factor or organizations to a Payload project through Better Auth plugins
  • Manage admin and user roles from a single configuration shared by Payload and Better Auth

From the author

The most powerful authentication solution for Payload CMS

Installation

npm i payload-auth

349

Stars

57

Forks

31

Open Issues

4 months ago

Last Updated

21.0k

Weekly Downloads

v3.0.0

npm Version

1.6 MB

Unpacked Size

7

Dependencies

GitHub stars

349+20 since Sep 6

Show data
GitHub stars by day (UTC)
DateStars
Dec 5, 2026349
Dec 4, 2026350
Dec 3, 2026350
Dec 2, 2026350
Dec 1, 2026349
Nov 30, 2026349
Nov 29, 2026349
Nov 28, 2026349
Nov 27, 2026349
Nov 26, 2026349
Nov 25, 2026349
Nov 24, 2026349
Nov 23, 2026349
Nov 22, 2026348
Nov 21, 2026348
Nov 20, 2026348
Nov 19, 2026348
Nov 18, 2026347
Nov 17, 2026346
Nov 16, 2026346
Nov 15, 2026346
Nov 14, 2026346
Nov 13, 2026346
Nov 12, 2026345
Nov 11, 2026345
Nov 10, 2026345
Nov 9, 2026345
Nov 8, 2026345
Nov 7, 2026345
Nov 6, 2026346
Nov 5, 2026346
Nov 4, 2026346
Nov 3, 2026347
Nov 2, 2026347
Nov 1, 2026347
Oct 31, 2026346
Oct 30, 2026346
Oct 29, 2026345
Oct 28, 2026345
Oct 27, 2026344
Oct 26, 2026344
Oct 25, 2026344
Oct 24, 2026344
Oct 23, 2026344
Oct 22, 2026344
Oct 21, 2026340
Oct 20, 2026340
Oct 19, 2026340
Oct 18, 2026339
Oct 17, 2026337
Oct 16, 2026337
Oct 15, 2026337
Oct 14, 2026337
Oct 13, 2026337
Oct 12, 2026337
Oct 11, 2026336
Oct 10, 2026336
Oct 9, 2026335
Oct 8, 2026335
Oct 7, 2026335
Oct 6, 2026335
Oct 5, 2026335
Oct 4, 2026335
Oct 3, 2026334
Oct 2, 2026334
Oct 1, 2026334
Sep 30, 2026333
Sep 29, 2026333
Sep 28, 2026331
Sep 27, 2026331
Sep 26, 2026331
Sep 25, 2026331
Sep 24, 2026331
Sep 23, 2026331
Sep 22, 2026331
Sep 21, 2026329
Sep 20, 2026329
Sep 19, 2026329
Sep 18, 2026329
Sep 17, 2026329
Sep 16, 2026329
Sep 15, 2026329
Sep 14, 2026329
Sep 13, 2026329
Sep 12, 2026329
Sep 11, 2026329
Sep 10, 2026329
Sep 9, 2026329
Sep 8, 2026329
Sep 7, 2026329
Sep 6, 2026329
npm weekly downloads

23.9K+16K since Sep 6

Show data
npm weekly downloads by day (UTC)
DateWeekly downloads
Dec 5, 202623,872
Dec 4, 202623,034
Dec 3, 202621,928
Dec 2, 202622,578
Dec 1, 202624,407
Nov 30, 202623,302
Nov 29, 202621,181
Nov 28, 202619,932
Nov 27, 202619,183
Nov 26, 202619,307
Nov 25, 202619,850
Nov 24, 202617,591
Nov 23, 202617,529
Nov 22, 202618,294
Nov 21, 202619,238
Nov 20, 202620,473
Nov 19, 202620,079
Nov 18, 202618,205
Nov 17, 202617,396
Nov 16, 202617,283
Nov 15, 202617,137
Nov 14, 202616,358
Nov 13, 202616,279
Nov 12, 202616,323
Nov 11, 202615,809
Nov 10, 202615,445
Nov 9, 202615,441
Nov 8, 202615,092
Nov 7, 202614,553
Nov 6, 202613,936
Nov 5, 202613,503
Nov 4, 202613,000
Nov 3, 202612,516
Nov 2, 202611,970
Nov 1, 202610,962
Oct 31, 202610,774
Oct 30, 20269,381
Oct 29, 20267,200
Oct 28, 20265,586
Oct 27, 20265,656
Oct 26, 20265,657
Oct 25, 20265,939
Oct 24, 20265,657
Oct 23, 20264,400
Oct 22, 20266,076
Oct 21, 20267,748
Oct 20, 20267,910
Oct 19, 20267,791
Oct 18, 20267,575
Oct 17, 20267,340
Oct 16, 20268,552
Oct 15, 20268,226
Oct 14, 20268,009
Oct 13, 20268,018
Oct 12, 20268,615
Oct 11, 20268,271
Oct 10, 20268,805
Oct 9, 20269,078
Oct 8, 20269,061
Oct 7, 20268,748
Oct 6, 20268,772
Oct 5, 20268,120
Oct 4, 20268,782
Oct 3, 20268,489
Oct 2, 20268,114
Oct 1, 20267,845
Sep 30, 20267,995
Sep 29, 20267,720
Sep 28, 20267,719
Sep 27, 20266,874
Sep 26, 20267,027
Sep 25, 20268,232
Sep 24, 20269,208
Sep 23, 20269,418
Sep 22, 20269,695
Sep 21, 20269,683
Sep 20, 202615,240
Sep 19, 202617,163
Sep 18, 202616,208
Sep 17, 202615,527
Sep 16, 202615,069
Sep 15, 202615,911
Sep 14, 202616,436
Sep 13, 202611,073
Sep 12, 20268,658
Sep 11, 20268,834
Sep 10, 20268,523
Sep 9, 20268,293
Sep 8, 20267,397
Sep 7, 20267,534
Sep 6, 20267,910

Each point is npm's rolling 7-day download count.

Health Score

70/100Good

Composite score based on GitHub activity, stars, npm downloads, publish recency, dependency count, and package size.

Badge for your README

Payload Directory health badge
Markdown
[![Payload Directory](https://payloaddirectory.dev/badge/944322391-payload-auth.svg)](https://payloaddirectory.dev/plugins/944322391-payload-auth)
HTML
<a href="https://payloaddirectory.dev/plugins/944322391-payload-auth"><img src="https://payloaddirectory.dev/badge/944322391-payload-auth.svg" alt="Payload Directory"></a>
Updated Aug 5, 2026Created Mar 7, 2025Published Aug 5, 2026

README

payload-auth

Better Auth for Payload CMS. One auth system for your admin panel and your app.

payload-auth replaces Payload's built-in authentication with Better Auth. The Payload admin panel and your frontend share the same session, so a user who signs in with Google on your marketing site is the same user Payload sees in the admin panel โ€” no second user table, no bridging code.

๐Ÿ“– Documentation ยท ๐Ÿค– llms.txt

Install

pnpm add payload-auth better-auth

Use

// src/payload.config.ts
import { buildConfig } from 'payload'
import { betterAuthPlugin } from 'payload-auth/better-auth'

export default buildConfig({
  admin: { user: 'users' },
  plugins: [
    betterAuthPlugin({
      users: {
        roles: ['user', 'admin'],
        adminRoles: ['admin'],
      },
      betterAuthOptions: {
        emailAndPassword: { enabled: true },
        socialProviders: {
          google: {
            clientId: process.env.GOOGLE_CLIENT_ID!,
            clientSecret: process.env.GOOGLE_CLIENT_SECRET!,
          },
        },
      },
    }),
  ],
})
// src/app/api/auth/[...all]/route.ts
import configPromise from '@payload-config'
import { toNextJsHandler } from 'better-auth/next-js'
import { getPayloadAuth } from 'payload-auth/better-auth'

const payload = await getPayloadAuth(configPromise)

export const { POST, GET } = toNextJsHandler(payload.betterAuth)

Then regenerate the import map and create the schema:

pnpm payload generate:importmap
pnpm payload migrate:create && pnpm payload migrate

See the installation guide for the full walkthrough.

What it does

  • Generates collections. users, sessions, accounts and verifications are built from the Better Auth schema, plus one collection for every Better Auth plugin you enable โ€” passkeys, two-factors, organizations, API keys, SSO providers and more.
  • Leaves Better Auth alone. The plugin installs a database adapter that speaks Payload's Local API. Every Better Auth endpoint, plugin and client method behaves exactly as its own docs describe.
  • Replaces the admin auth views. Login, signup, forgot password, reset password and two-factor verification are rendered by Better Auth-powered views that respect your enabled login methods.
  • Wires up roles. Define roles once; they feed Payload access control and the Better Auth admin plugin.

Entry points

Import pathContents
payload-auth/better-authPlugin, adapter and types โ€” the usual import
payload-auth/better-auth/pluginPlugin only
payload-auth/better-auth/adapterAdapter only
payload-auth/better-auth/plugin/clientClient components
payload-auth/better-auth/plugin/rscServer components and admin views
payload-auth/shared/payload/fieldsReusable Payload field components

Requirements

RequirementVersion
payload, @payloadcms/next, @payloadcms/ui>=3.79.1 <4
better-auth, @better-auth/core>=1.5.0 <2
next>=15.4.8 <17
react, react-dom>=19.2.1 <20
zod^4.3.6

Any Payload database adapter works โ€” the plugin talks to Payload's Local API, not to your database directly.

Documentation

InstallationInstall and wire up the plugin
How it worksThe architecture
CollectionsWhat gets generated, and how to extend it
Plugin optionsEvery option, with defaults
Better Auth plugin supportWhat is configured automatically
TroubleshootingCommon problems

License

MIT

Similar plugins