payload-auth

Using with AI agents

Feed these docs to Cursor, Claude Code, Copilot or any other coding agent.

Every page on this site is published as plain Markdown alongside its HTML, so a coding agent can read the documentation directly instead of scraping rendered pages.

Endpoints

URLContents
/llms.txtIndex of every page with titles, descriptions and URLs
/llms-full.txtThe entire documentation as one Markdown document
/docs/<path>.mdA single page as Markdown

Start an agent with /llms.txt so it can see the structure, then let it fetch the specific pages it needs. /llms-full.txt is the one-shot option when you would rather paste everything into a single context window.

curl https://payload-auth.dev/llms.txt
curl https://payload-auth.dev/docs/reference/plugin-options.md

Content negotiation

Requesting a docs page with a Markdown Accept header returns Markdown rather than HTML, so an agent's default fetch tool gets clean content without any special URL handling:

curl -H "Accept: text/markdown" https://payload-auth.dev/docs/getting-started/installation

Appending .md to any docs URL does the same thing.

Copy from the page

Every page has a Copy Markdown button and a view-options menu in its header, for grabbing the source of the page you are reading and pasting it into a chat.

Wiring it into your editor

Add the documentation to your project's CLAUDE.md or AGENTS.md:

AGENTS.md
## Authentication

This project uses `payload-auth` — Better Auth running on Payload CMS.

Documentation: https://payload-auth.dev/llms.txt
Full text: https://payload-auth.dev/llms-full.txt

Rules:
- Auth collections (`users`, `sessions`, `accounts`, `verifications`) are generated by
  the plugin. Do not declare them by hand; extend them with `collectionOverrides`.
- Never set `database` in `betterAuthOptions` — the plugin supplies the adapter.
- `nextCookies()` must be the last entry in the Better Auth `plugins` array.
- `user.role` is a string array, not a string.
- Re-run `payload generate:importmap` after changing login methods or Better Auth plugins.

Facts worth pinning

Agents trained before this integration existed tend to make the same handful of mistakes. These are the corrections worth stating explicitly:

  • The auth collections are generated. users, sessions, accounts, verifications and admin-invitations are injected by the plugin. Writing them by hand duplicates work and usually conflicts.
  • database is not a valid option. The exported BetterAuthOptions type has it removed; the plugin supplies the Payload adapter.
  • role is an array. It is a Payload multi-select, so ['admin'], not 'admin'.
  • Foreign keys are relationships. In Payload queries use user, not userId, on sessions and accounts. Better Auth code still uses userId.
  • nextCookies() goes last.
  • admin.loginMethods is UI only. It changes which buttons the admin views render; it does not enable or disable providers.
  • Import from payload-auth/better-auth, not from payload-auth/better-auth/plugin, for ordinary use.
  • getPayloadAuth<Config>(configPromise) is how you get a typed payload.betterAuth.

Better Auth's own docs

payload-auth does not change Better Auth's API, so for anything about endpoints, client methods or plugin options, Better Auth's documentation is authoritative:

https://www.better-auth.com/llms.txt

Give an agent both sources: this site for the Payload integration, Better Auth's for the auth surface itself.

On this page