Skip to Content
Delmare Digital

Security management

The two-factor, passkey and API key management screens the plugin adds to the admin, and what turns each one on.

The plugin adds management UI for the Better Auth plugins you enable. Two-factor and passkeys are per-user settings, so they appear on the user's own document. API keys are an admin-level feature, so they get their own view and sidebar link.

UIWhere it appearsRequires
Two-factor authenticationA field on the auth collection's edit viewtwoFactor()
PasskeysA field on the auth collection's edit viewpasskey() from @better-auth/passkey
API keysAdmin view at /admin/security/api-keys, linked in the sidebarapiKey() from @better-auth/api-key

Turning it on

The plugin detects enabled Better Auth plugins from admin.betterAuthOptions. Pass the same options you give betterAuth():

src/payload.config.ts
createBetterAuthPlugin({
  createAuth,
  admin: {
    betterAuthOptions,
  },
})

Without admin.betterAuthOptions, no management UI is added.

  • admin.enableManagementUI: false turns all of it off (default true).
  • admin.managementPaths.apiKeys moves the API keys view (default '/security/api-keys').
  • admin.apiKey configures which collections appear in the permission picker and who may manage keys. See API keys.

Building your own

The pieces are exported for custom screens:

ExportFrom
TwoFactorManagementClient, SecurityNavLinks@delmaredigital/payload-better-auth/components/management
TwoFactorView, TwoFactorSetupViewWrapper@delmaredigital/payload-better-auth/rsc
PasskeysManagementClient, PasskeysField@delmaredigital/payload-better-auth/components/passkey
PasskeysView@delmaredigital/payload-better-auth/rsc/passkey
ApiKeysManagementClient@delmaredigital/payload-better-auth/components/api-key
ApiKeysView@delmaredigital/payload-better-auth/rsc/api-key
TwoFactorField@delmaredigital/payload-better-auth/components
detectEnabledPlugins@delmaredigital/payload-better-auth/management
Edit this page on GitHub

On this page