A walkthrough of replacing Payload CMS's built-in email-and-password auth with Better Auth, enabling a Next.js site and its Payload admin panel to share the same authenticated session. The implementation uses Better Auth's Email OTP plugin and a custom Payload auth strategy that extracts the Better Auth session from request headers, looks up the matching user in the Payload Users collection, and optionally bootstraps an initial admin. Disabling Payload's local strategy and injecting custom login/logout components into the admin UI completes the integration.

5m read timeFrom spin.atomicobject.com
Post cover image
Table of contents
Using Payload CMSEnter Better AuthCustom Strategy

Sort: