Introduction

A powerful authentication plugin for Payload CMS that enhances and extends the default auth system with modern security features.

payload-better-auth-banner

Better Auth for Payload CMS

You are one plugin away from revolutionizing your Payload CMS authentication system. This plugin seamlessly integrates Better Auth with Payload CMS v3, providing enhanced authentication capabilities.

Why this plugin?

While Payload CMS comes with a solid and extensible authentication system out of the box, it primarily focuses on basic email/password authentication and API keys. Modern applications often require more sophisticated authentication methods and features.

This plugin bridges that gap: Better Auth becomes the authentication engine, Payload stays your database and admin UI, and everything in between - collections, endpoints, admin screens - is generated for you.

Key features

  • Unified Better Auth strategy: email + password, TOTP 2FA, social/OAuth
  • Default email verification and password reset flows (overridable)
  • Session management handled by Better Auth
  • Role-based access control via the Better Auth admin plugin
Two-factor authentication
  • Auto-injected social login buttons in the Payload admin login screen
  • 2FA setup prompt before the dashboard, plus setup/verify views
  • Account-level controls (TwoFactorAccountButton)
Social login
  • Collections auto-generated from your Better Auth options
  • Payload endpoints bridged to Better Auth (/login, /logout, /me, ...)
  • Per-collection overrides via extendsCollections
  • payload.betterAuth instance, fully typed with your own plugin options
  • Auth layer helpers for Next.js (checkers, guards, server actions)
API Reference

Quick start

Add the plugin and its peer dependencies to your Payload project.

Installation Guide

From install to a protected Next.js route, with the most common knobs in one place.

Quick Setup Walkthrough

Set up authentication strategies and other settings.

Configuration Guide

Next.js integration

Better Auth provides a powerful integration with Next.js through the Auth Layer:

Community and support

Credits

Created by Benedetto Abbenanti

On this page