Username
Username sign-in is part of EmailPasswordPlugin.
better-auth-rs generate --plugins username -o src/auth_schema.rsApply the schema changes, then enable username support:
use crate::auth_schema::AppAuthSchema;use better_auth::plugins::EmailPasswordPlugin;use better_auth::sqlx::SqlxStore;use better_auth::{AuthConfig, AuthResult, BetterAuth};
async fn build_auth( config: AuthConfig, store: SqlxStore<AppAuthSchema>,) -> AuthResult<BetterAuth<AppAuthSchema>> { BetterAuth::<AppAuthSchema>::new(config) .store(store) .plugin(EmailPasswordPlugin::new().enable_username(true)) .build() .await}Options
Section titled “Options”Sign-in uses /sign-in/username; email signup also accepts a username. The default policy lowercases ASCII usernames and allows 3–30 characters.
Use username_config to change length bounds, normalization, validators, or input policies. Validation order depends on the selected pre/post-normalization policy; see the username implementation for the complete options.
Frontend
Section titled “Frontend”See the official username guide.