Better Auth RS
The most comprehensive authentication framework for Rust. Inspired by Better Auth.
[!WARNING] v1 is in alpha. The current release (
1.0.0-alpha.2) is under active development. APIs, wire formats, and database schemas may change without notice between alpha releases, and production use is not recommended yet. Please report issues and feedback on GitHub.
The pinned compatibility target is better-auth@1.4.19. The v1 release
scope covers phases 0-12 in ROADMAP.md, and the TypeScript
runtime plus better-auth/client harness remain the source of truth for
wire behavior.
Features
- Plugin Architecture — compose only the auth features you need
- Type Safety — leverages Rust's type system for compile-time guarantees
- Async First — built on Tokio with full async/await support
- App-Owned SeaORM Schema — auth entities live in your SeaORM model graph
- Framework Integration — first-class Axum support with session extractors
- OpenAPI — auto-generated API specification
- Middleware — CSRF, CORS, rate limiting, body size limits
- Database Hooks — intercept create/update/delete operations
Quick Start
[]
= { = "1.0.0-alpha.2", = ["axum", "seaorm2"] }
Generate the schema scaffolding with the CLI:
Or write it by hand — the AuthEntity derive generates all trait impls:
use ;
use EmailPasswordPlugin;
use ;
use *;
// Only include the fields you need — plugin fields are optional.
// The AuthEntity macro adapts: missing fields return sensible defaults.
// ... session, account, verification entities ...
;
async
Your app owns the auth entities and migrations — Better Auth adapts to whatever schema you define.
Plugins
Better Auth RS ships with a rich set of plugins. Enable only what you need:
| Plugin | Description |
|---|---|
| Email/Password | Sign up/sign in with email & password, username support |
| Session Management | Session listing, revocation, and token refresh |
| Password Management | Password reset, change, and set flows |
| Email Verification | Email verification workflows |
| Account Management | Account linking and unlinking |
| Organization | Multi-tenant organizations with RBAC |
| OAuth | Social sign-in via OAuth 2.0 providers |
| Two-Factor | TOTP-based 2FA with backup codes |
| Passkey | WebAuthn passkey authentication |
| API Key | API key generation, rotation, and revocation |
| Admin | User management and administrative operations |
See the Plugins documentation for usage details.
Feature Flags
| Feature | Description |
|---|---|
axum |
Axum web framework integration |
seaorm2 |
SeaORM database integration |
redis-cache |
Redis session/cache backend |
Crate Structure
| Crate | Description |
|---|---|
better-auth |
Main crate — re-exports and framework integration |
better-auth-core |
Core auth runtime, store, middleware, and error handling |
better-auth-api |
Plugin implementations |
better-auth-seaorm |
SeaORM store, entity traits, and AuthEntity derive macro |
better-auth-cli |
CLI tools (better-auth-rs generate) |
Documentation
Detailed guides and API reference are available in the docs/ directory:
- Contributing
- Alignment Roadmap
- Installation
- Quick Start
- Authentication — Email/Password · Sessions · Email Verification
- Concepts — Configuration · Database · Plugins · Middleware · Hooks
- Plugins — OAuth · Organization · Two-Factor · Passkey · API Key · Admin
- Reference — API Routes · Configuration Options · Errors · Security · OpenAPI
- Integrations — Axum
- Compatibility — Compatibility Harness
Examples
# Axum web server
# PostgreSQL (custom ID types, manual trait impls)
# Full-stack (better-auth frontend + better-auth-rs backend)
See examples/README.md for detailed documentation on each example.
License
Licensed under either of:
at your option.