Building in Go? See the theAuth Go library docs and the theauth-go repository. Website: theauth.dev. Source: glincker/theauth. Not sure it fits? Read When not to use theAuth.
Pick your track
Add agent auth
Give agents an identity, scoped permissions, delegation and an audit trail. About five minutes.
Add human auth
Sign-up, sign-in, verification and reset with email and password, then add passkeys, OAuth and more. About five minutes.
Agent auth in one screen
Human auth in one screen
What’s in the box
Agent identity as a first-class entity, not an extension of a user.
Resource wildcards with rate limits, time windows, and IP allowlists.
Delegation chains with depth, expiry, and revocation that takes effect on the next call.
Audit log of every decision, with JSON and CSV export.
MCP OAuth 2.1 authorization server, PKCE, DCR and revocation-bound tokens.
Trust scoring per agent from audit history, plus budget policies.
Ten adapters for Node, edge, Workers, Deno, Bun.
Databases: SQLite and Postgres, plus Cloudflare D1. MySQL is not supported. See what is tested.
Web Crypto only in core, no Node-specific APIs.
Devices with their own credentials, enrollment, live revocation and signed offline policy bundles.
Robotics with ROS 2 permissions exported to SROS2 and DDS Security files, plus a gate node for hazardous commands.
How it fits with your stack
theAuth includes human auth, but you do not have to use it. If you already run Clerk, Auth.js, better-auth or your own login, keep it and pass the user ID as the agent’s owner. theAuth’s own methods (see Authentication) cover sign-in forms, password reset and social OAuth when you want one library for both.

theAuth runs inside your own app and infrastructure, with your own database.
Pick your framework
Next.js
App Router and Pages.
Hono
Workers, Deno, Bun.
Express
Classic Node handlers.
Fastify
Plugins and decorators.
NestJS
Guards and decorators.
Nuxt
Server routes.
SvelteKit
Hooks and endpoints.
Astro
Server islands.
The six primitives
Agent identity
Bearer tokens (
ta_..., a prefix kept from before the rename), rotation, expiry. SHA-256 hashed at rest.Permission engine
Resource wildcards, rate limits, time windows, IP allowlists, approval gates.
Delegation
Orchestrator delegates a subset to a sub-agent with depth and expiry. A revoked delegator stops lending permissions.
Audit trail
Every
authorize() writes agent, user, resource, action, result, duration.MCP OAuth 2.1
Spec-compliant AS with PKCE S256, RFC 9728, RFC 7591.
Trust scoring
Score per agent computed from audit history. Budget policies you check and record yourself.
Switching from another auth library
From better-auth
Concepts map, code diffs, data migration SQL.
From Clerk
Hooks, middleware, Clerk data export, rollout plan.
Related
Core concepts
The mental model for agents, permissions, delegation, and audit.
MCP OAuth 2.1
Spec-compliant authorization server for Model Context Protocol tool servers.
Database setup
SQLite, Postgres, and Cloudflare D1 configuration. MySQL is not supported.
Standards alignment
IETF draft claims theAuth tracks and emits on agent JWTs.