Expand description
Entity traits for the Better Auth framework.
These traits define the interface that entity types must implement. The framework accesses entity fields through these trait methods, allowing users to define their own entity structs with custom field names and extra fields.
Use #[derive(AuthUser)] etc. from better-auth-derive to auto-implement
these traits, or implement them manually.
§Meta traits
Each entity trait has a corresponding Auth*Meta trait (e.g., AuthUserMeta)
that provides table and column name mappings for SQL generation. The derive
macros automatically implement both the entity trait and the meta trait.
If you implement entity traits manually (without derive macros), you must
also implement the corresponding Auth*Meta trait. An empty impl block is
sufficient to get the default column/table names:
impl AuthUserMeta for MyUser {} // uses default column names
impl AuthSessionMeta for MySession {}Structs§
- Member
User View - Minimal user info for member-related API responses.
Constants§
- PASSWORD_
HASH_ KEY - Metadata key used to store the password hash inside
AuthUser::metadata().
Traits§
- Auth
Account - Trait representing an account entity (OAuth provider linking).
- Auth
Account Meta - SQL column/table metadata for
AuthAccountentities. - Auth
ApiKey - Trait representing an API key entity.
- Auth
ApiKey Meta - SQL column/table metadata for
AuthApiKeyentities. - Auth
Invitation - Trait representing an invitation entity.
- Auth
Invitation Meta - SQL column/table metadata for
AuthInvitationentities. - Auth
Member - Trait representing an organization member entity.
- Auth
Member Meta - SQL column/table metadata for
AuthMemberentities. - Auth
Organization - Trait representing an organization entity.
- Auth
Organization Meta - SQL column/table metadata for
AuthOrganizationentities. - Auth
Passkey - Trait representing a passkey entity.
- Auth
Passkey Meta - SQL column/table metadata for
AuthPasskeyentities. - Auth
Session - Trait representing a session entity.
- Auth
Session Meta - SQL column/table metadata for
AuthSessionentities. - Auth
TwoFactor - Trait representing a two-factor authentication entity.
- Auth
TwoFactor Meta - SQL column/table metadata for
AuthTwoFactorentities. - Auth
User - Trait representing a user entity.
- Auth
User Meta - SQL column/table metadata for
AuthUserentities. - Auth
Verification - Trait representing a verification token entity.
- Auth
Verification Meta - SQL column/table metadata for
AuthVerificationentities.