nexfetch-auth
Framework-agnostic authentication for Python. Inspired by Better Auth.
Works with any ASGI framework. Works with any database. No magic, no lock-in.
from nexfetch_auth import nexfetch_auth
from nexfetch_auth.db.adapters.sqlalchemy import sqlalchemy_adapter
auth = await nexfetch_auth(
secret="your-secret-key",
database=await sqlalchemy_adapter("sqlite+aiosqlite:///auth.db"),
)
app.mount("/api/auth", auth.app)
Why nexfetch-auth?
- One library, any framework — FastAPI, Starlette, Litestar, Django ASGI, or standalone uvicorn
- One library, any database — SQLAlchemy, MongoDB, in-memory, or your own adapter
- Production-ready — sessions, OAuth, rate limiting, CORS, JWT, password reset, email verification
- Service-based architecture — clean separation between transport, business logic, and storage
- Optional dependencies — install only what you use
Features
| Feature | Status |
|---|---|
| Email/password authentication | ✓ |
| OAuth (GitHub, Google, Discord, Microsoft) | ✓ |
| Session management (cookie + JWT) | ✓ |
| Multi-session support | ✓ |
| Token refresh | ✓ |
| Password reset flow | ✓ |
| Email verification flow | ✓ |
| Rate limiting | ✓ |
| CORS validation | ✓ |
| Account linking | ✓ |
| Plugin system | ✓ |
| 2FA / TOTP | Planned |
| Magic links | Planned |
| Passkeys / WebAuthn | Planned |
| Organizations / RBAC | Planned |
Quick install
pip install 'nexfetch-auth[sqlalchemy,fastapi]'