Skip to Content
Delmare Digital

Overview

Use Better Auth as the authentication layer for Payload CMS, with Payload collections as the auth database and a ready-made admin login.

@delmaredigital/payload-better-auth connects Better Auth to Payload CMS. Better Auth handles sign-in, sessions, OAuth, two-factor, passkeys and API keys; Payload stores every auth record in its own collections and authenticates requests through a Payload auth strategy.

The package has three parts:

  • A Better Auth database adapter (payloadAdapter) that reads and writes through Payload's Local API, so auth data lives in your Payload database (Postgres, SQLite or MongoDB).
  • A collection generator (betterAuthCollections) that builds Payload collections from the installed Better Auth schema, including every Better Auth plugin you enable.
  • A Payload plugin and auth strategy (createBetterAuthPlugin, betterAuthStrategy) that mounts Better Auth's endpoints under Payload's API route, validates sessions on every Payload request and replaces the admin login with one that supports password, magic link, email OTP, social, passkey and two-factor sign-in.

When to use it

Use it when you want Better Auth's feature set (OAuth and OIDC providers, organizations, two-factor, passkeys, API keys) in a Payload project, and you want one database and one admin for content and users.

It is a thin adapter: Better Auth configuration stays standard Better Auth configuration, and the plugin reads it to generate collections and to decide which admin UI to show.

Requirements at a glance

DependencyVersion
payload, @payloadcms/next, @payloadcms/ui>=3.90.0 <4
better-auth>=1.7.7 <2
next>=16.4.1 <17
react>=19.2.1 <20
Node>=22.23.4

Payload 4 beta is supported on a separate release line. See Payload 4.

Starter template

dd-starter is a Payload project with this plugin already wired up.

Next steps

Edit this page on GitHub

On this page