MCPcopy Index your code
hub / github.com/b3nab/payload-better-auth

github.com/b3nab/payload-better-auth @v0.11.2

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.11.2 ↗ · + Follow
845 symbols 2,398 edges 412 files 2 documented · 0% updated 31d ago★ 74
What it actually does AI analysis from the code graph — generated when you open this
loading…
README
<img src="https://github.com/b3nab/payload-better-auth/raw/v0.11.2/banner.png" alt="Banner">

Payload Better Auth Plugin

You are one plugin away to revolutionize your PayloadCMS's auth.




<a href="https://payload-better-auth.abbenanti.com"><strong>Learn more »</strong></a>








<a href="https://payload-better-auth.abbenanti.com/docs">Docs</a>
·
<a href="https://github.com/b3nab/payload-better-auth/issues">Issues</a>

Ask DeepWiki GitHub stars npm version npm

⚠️ ATTENTION: If you want a preview access to the plugin, you should contact the author (in private) and request access to the private registry.

A plugin that integrates Better Auth with Payload CMS v3, providing enhanced authentication capabilities. This plugin is thought to be used in production, with real users, so to be rock solid well tested and reliable. 🗿

Description

The @b3nab/payload-better-auth plugin wraps the better-auth library to seamleassly integrate advanced authentication features into Payload CMS v3. It enhanches developer productivity and user experience by offering more sophisticated authentication methods beyond Payload's built-in auth system. Definitely it's a better-way 🤓 to manage authentication for Payload CMS v3.

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. This serves many use cases well, but modern applications often require more sophisticated authentication methods and features.

Features

The goal is to seamlessly integrate better-auth in your Payload CMS v3 application, providing a robust and feature-rich authentication system with a focus on user experience and developer productivity.

  • Basic integration - Out of the box 🤝
  • Integration with Better Auth
  • Automatic Collections creation
  • Automatic Better Auth API Endpoints creation
  • Payload Adapter as Better Auth database
  • Better Integration 🤓
  • 2FA TOTP-based for Admin Panel
  • Easily extend Collections using Payload-like collection's config

Installation

pnpm add @b3nab/payload-better-auth

Quick Start

Into your payload.config.ts file, add the plugin:

import { buildConfig } from "payload";
import { betterAuthPlugin } from "@b3nab/payload-better-auth";

export default buildConfig({
  // ... other config

  plugins: [
    betterAuthPlugin({
      // Better Auth Config. https://www.better-auth.com/docs/reference/options
      betterAuth: {
        // used by two factor plugin as an issuer and other things
        appName: "My App",
        // better-auth secret - you can omit it if your env variable is named `BETTER_AUTH_SECRET`
        /** you can generate a good secret
         * using the following command:
         * @example
         * openssl rand -base64 32
         */
        secret: process.env.BETTER_AUTH_SECRET,
      },
    }),
  ],
  // ... other config
});

Roadmap (TODOs)

  • [ ] Payload Auth Endpoints - Needs to replace all remaining payload default auth endpoints

Important Notes

  1. This plugin may perform operations that could affect your application and database
  2. Maintainers are not responsible for issues that may occur
  3. Contributions via issues and PRs are highly encouraged

Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'feat: add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Credits

Created and maintained by Benedetto Abbenanti.

This project would not be possible without the following open-source projects:

Extension points exported contracts — how you extend this code

Config (Interface)
(no doc)
packages/payload-better-auth/dev/payload-types.ts
ObjectType (Interface)
(no doc)
apps/docs/components/type-table.tsx
ProcessEnv (Interface)
(no doc)
apps/demo/src/environment.d.ts
UserAuthOperations (Interface)
(no doc)
packages/payload-better-auth/dev/payload-types.ts
CodeBlockProps (Interface)
(no doc)
apps/docs/components/code.tsx
Config (Interface)
(no doc)
apps/demo/src/payload-types.ts
Post (Interface)
(no doc)
packages/payload-better-auth/dev/payload-types.ts
TabsProps (Interface)
(no doc)
apps/docs/components/tabs.tsx

Core symbols most depended-on inside this repo

cn
called by 190
packages/payload-better-auth/dev/lib/utils.ts
cn
called by 44
apps/demo/src/utilities/ui.ts
cn
called by 37
apps/docs/lib/utils.ts
createLucideIcon
called by 32
apps/docs/components/icons.tsx
debugLog
called by 25
packages/payload-better-auth/src/payload-utilities/uploads/fetchAPI-multipart/utilities.ts
getPayload
called by 21
packages/payload-better-auth/src/singleton.payload.ts
getCollectionName
called by 12
packages/payload-better-auth/src/better-auth/payload-adapter.ts
getPayloadFieldName
called by 12
packages/payload-better-auth/src/better-auth/payload-adapter.ts

Shape

Function 676
Interface 145
Method 20
Class 4

Languages

TypeScript100%

Modules by API surface

apps/demo/src/payload-types.ts63 symbols
packages/payload-better-auth/dev/payload-types.ts40 symbols
packages/payload-better-auth/src/better-auth/payload-adapter.ts24 symbols
packages/payload-better-auth/src/payload-utilities/uploads/fetchAPI-multipart/utilities.ts16 symbols
packages/payload-better-auth/dev/helpers/NextRESTClient.ts13 symbols
apps/demo/src/helpers/NextRESTClient.ts13 symbols
packages/payload-better-auth/dev/components/ui/menubar.tsx11 symbols
packages/payload-better-auth/dev/app/_(demo)/dashboard/user-card.tsx11 symbols
packages/payload-better-auth/dev/components/ui/command.tsx10 symbols
apps/docs/components/tabs.tsx10 symbols
packages/payload-better-auth/dev/hooks/use-toast.ts9 symbols
packages/payload-better-auth/dev/components/ui/dropdown-menu.tsx9 symbols

For agents

$ claude mcp add payload-better-auth \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page