Skip to main content

Crate better_auth

Crate better_auth 

Source
Expand description

§Better Auth - Rust

A comprehensive authentication framework for Rust, inspired by Better-Auth.

§Quick Start

use better_auth::{AuthConfig, AuthSchema, BetterAuth};
use better_auth::plugins::EmailPasswordPlugin;
use better_auth::seaorm::{Database, SeaOrmStore};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let config = AuthConfig::new("your-secret-key-that-is-at-least-32-chars");
    let database = Database::connect("sqlite::memory:").await?;
    let store = SeaOrmStore::<AppAuthSchema>::new(config.clone(), database);

    let auth = BetterAuth::<AppAuthSchema>::new(config)
        .store(store)
        .plugin(EmailPasswordPlugin::new())
        .build()
        .await?;

    Ok(())
}

Modules§

config
Configuration types beyond the root AuthConfig entrypoint.
email
Email provider interfaces and development helpers.
error
Error types and result aliases for Better Auth.
hooks
Request-hook utilities shared across Better Auth integrations.
integrations
Framework integrations.
middleware
Middleware traits and configuration types.
plugin
Plugin authoring interfaces and shared runtime types.
plugins
Built-in plugins and plugin-specific configuration modules.
prelude
Common traits and data types used by handlers, tests, hooks, and direct dispatch.
schema
Schema traits and derive macros for app-owned auth models.
store
Storage traits and cache adapters used by Better Auth.
wire
Wire-facing response view models.

Structs§

AuthBuilder
Initial builder for configuring BetterAuth.
AuthConfig
Main configuration for BetterAuth
BetterAuth

Enums§

AuthError
Authentication framework error types.

Traits§

AuthSchema
App-owned auth schema declaration.

Type Aliases§

AuthResult

Derive Macros§

AuthSchema