Better Auth in Rust

Installation

Add Better Auth to your Rust project.

Dependencies

These examples target the current master branch. The DX changes are not yet published as a new crate release. For Axum and a generated SeaORM schema, add:

Cargo.toml
[dependencies]
better-auth = { version = "1.0.0-alpha.3", git = "https://github.com/better-auth-rs/better-auth-rs", branch = "master", features = ["axum", "seaorm2"] }
axum = "0.8"
tokio = { version = "1", features = ["macros", "rt-multi-thread", "net"] }
serde = { version = "1", features = ["derive"] }
serde_json = "1"

Follow the quick-start guide to generate entities, initialize the database, and start a server. Applications own their auth schema and versioned migrations.

Builds require OpenSSL 3.0 or newer, including its development headers. OIDC ML-DSA verification requires OpenSSL 3.5 or newer. The rustls feature changes HTTP transport and retains this signature-verification dependency. The development shell supplies OpenSSL.

Feature flags

FeatureDescription
native-tlsDefault TLS backend for outbound HTTP
rustlsAlternative TLS backend; use default-features = false
axumRoute mounting and session extractors
seaorm2SeaORM store and entity derives
redis-cacheStandalone asynchronous Redis cache adapter

Select exactly one TLS backend. For Rustls:

better-auth = { version = "1.0.0-alpha.3", git = "https://github.com/better-auth-rs/better-auth-rs", branch = "master", default-features = false, features = ["rustls", "axum", "seaorm2"] }

The cache adapters are standalone utilities. Enabling redis-cache does not change session persistence or register a session cache.

Rust toolchain

The project uses Rust 2024. The committed devenv.lock pins the toolchain used for local checks. The project does not currently declare a tested minimum Rust version.

On this page