Skip to main content
better-auth is a solid human-auth library. If your product now needs AI agents as first-class entities, an MCP OAuth 2.1 server, GDPR compliance exports, or trust scoring per agent, KavachOS is worth the switch. If you rely on an OAuth provider that better-auth covers but KavachOS does not ship first-class (we have 17 plus a generic OIDC factory as of 2026-04), you may want to wait.

Concepts map

Server migration

Next.js App Router

Hono

Database adapter

better-auth supports Prisma, Drizzle, Mongoose, and others. KavachOS uses Drizzle exclusively. A Prisma adapter is on our roadmap; if you are Prisma-only today, that is the main blocker.
KavachOS runs its own schema migrations. You do not pass your Drizzle db instance; pass the connection URL and KavachOS manages its own tables. See data migration below for how to move existing rows.

Client SDK

For React, swap the hook import:

OAuth providers

GitHub, Google, and Discord side-by-side:
For a provider not in our first-class list, use the generic factory:

Breaking differences

Session tokens

better-auth and KavachOS use different token structures. An existing session token from better-auth will not be accepted by KavachOS and vice versa. To avoid signing everyone out on cutover day, use our cookieAuth adapter to accept both token formats during a transition window:
Run both token paths for 30 days. Once traffic drops to near-zero on the old tokens, remove the cookieAuth adapter. If your better-auth app set secure: false in a staging environment, check your baseUrl. KavachOS infers Secure from the URL scheme: https:// turns the flag on, plain http:// leaves it off.

@better-auth/agent-auth

If you use @better-auth/agent-auth, none of its config maps 1:1. That package is a thin wrapper; KavachOS replaces it with a native AgentIdentity entity, built-in delegation, ephemeral sessions, and the MCP OAuth server. Start with the agents quickstart rather than trying to adapt your existing agent-auth config.

Data migration

better-auth and KavachOS share a similar base schema, but column names differ in a few places. Run this SQL after you have applied KavachOS migrations to the same database (adjust the schema name if needed):
Column names in better-auth can vary depending on your adapter and any custom fields you added. Run SELECT column_name FROM information_schema.columns WHERE table_name = 'user' against your database to confirm the exact names before running the migration.

Rollback

Keep better-auth running behind a feature flag while you roll out KavachOS to a percentage of traffic.
Set KAVACHOS_ROLLOUT=10 to start at 10%, then raise it over days as you validate sessions in the KavachOS tables. The cookieAuth adapter described above keeps existing users signed in during the overlap.

FAQ

Does KavachOS support all the OAuth providers better-auth has? No. As of 2026-04 we ship 17 first-class providers: Apple, Atlassian, Discord, Dropbox, Figma, GitHub, GitLab, Google, LinkedIn, Microsoft, Notion, Reddit, Slack, Spotify, Twitch, Twitter/X, Zoom. Any provider with a standard OAuth 2.0 authorization code flow works via the generic provider factory, but you write the config by hand. If a specific provider matters to you, open an issue. Is Prisma supported? Yes. Install @kavachos/prisma and pass a PrismaClient as the database backend. See the Prisma adapter docs for the setup. Do I need to install an MCP plugin? No. MCP OAuth 2.1 is built into KavachOS core. Pass a mcp config block to createKavach and enable it in your adapter. Can I run better-auth and KavachOS side by side? Yes. Use the cookieAuth adapter to accept better-auth sessions inside KavachOS, and route traffic with a feature flag as shown above. Will my users have to sign in again? With the cookieAuth adapter, no. KavachOS will accept existing better-auth sessions and issue new KavachOS tokens on the next request. Without the adapter, yes, existing tokens will be rejected.
Last modified on April 29, 2026