Derive macros for better-auth entity traits.
Provides #[derive(AuthUser)], #[derive(AuthSession)], etc. to auto-implement
the entity traits from better_auth_core::entity for custom struct types.
Example
use AuthUser;
Derive macros for better-auth entity traits.
Provides #[derive(AuthUser)], #[derive(AuthSession)], etc. to auto-implement
the entity traits from better_auth_core::entity for custom struct types.
use better_auth_derive::AuthUser;
#[derive(Clone, Debug, Serialize, AuthUser)]
pub struct MyUser {
pub id: String,
pub email: Option<String>,
#[auth(field = "name")]
pub display_name: Option<String>,
pub email_verified: bool,
pub image: Option<String>,
pub created_at: DateTime<Utc>,
pub updated_at: DateTime<Utc>,
pub username: Option<String>,
pub display_username: Option<String>,
pub two_factor_enabled: bool,
pub role: Option<String>,
pub banned: bool,
pub ban_reason: Option<String>,
pub ban_expires: Option<DateTime<Utc>>,
pub metadata: HashMap<String, serde_json::Value>,
}