Types
TypeScript types for the Payload instance with Better Auth attached, hooks and endpoints, and the generated Better Auth schema.
Payload with Better Auth
import type {
PayloadWithAuth,
PayloadRequestWithBetterAuth,
BetterAuthReturn,
CollectionHookWithBetterAuth,
EndpointWithBetterAuth,
RoleArray,
WithRoleField,
} from '@delmaredigital/payload-better-auth'PayloadWithAuthis a Payload instance withbetterAuthattached. CastgetPayload()to it to reachpayload.betterAuth.apiorpayload.betterAuth.handler.PayloadRequestWithBetterAuth,CollectionHookWithBetterAuthandEndpointWithBetterAuthtype requests, hooks and endpoints that use it.WithRoleField<User, 'roles', string[]>moves the generatedroleproperty to a custom role field.
Generated schema types
import type {
User, BetterAuthSession, Account, Verification,
Apikey, Passkey, Organization, Member, Invitation, Team, TeamMember, TwoFactor,
} from '@delmaredigital/payload-better-auth'These are generated from Better Auth's schema for the plugins the package's type generation covers. ModelKey, PluginId and BetterAuthFullSchema are exported as well.
Option types
PayloadAdapterConfig, BetterAuthCollectionsOptions, BetterAuthPluginOptions, BetterAuthPluginAdminOptions, BetterAuthStrategyOptions, SessionHelperOptions, FirstUserAdminOptions, ApiKeyPermissionsConfig, ApiKeyPermissionConfig, PermissionCheck, RoleCheckConfig, SelfAccessConfig, FieldUpdateConfig and MigrateStringifiedArraysOptions are exported for typing your own wrappers.
Your Payload types
After adding a Better Auth plugin, regenerate your Payload types so payload-types.ts includes the new collections and fields:
payload generate:types
