better-auth: Better Auth: The Auth Runtime That Refuses to Stay in One Framework

A deep dive into the TypeScript project turning login, sessions, enterprise identity, and database support into a portable platform instead of a framework plugin.

11 min read · better-auth/better-auth

A central auth engine sits on a white workbench while a browser, an edge worker, and a desktop app feed requests into it through separate channels. Swappable drawers for storage and feature modules slide into the same chassis, showing that one core can serve multiple runtimes.
Better Auth is built like infrastructure, not a framework add-on. The same core contract is meant to survive different runtimes and different persistence layers.
Key Takeaways

Auth That Moves

Most auth libraries fail at the seams. They work until you need a second runtime, a different ORM, a desktop shell, or enterprise features that were never part of the original design. Better Auth is interesting because it seems to start from the opposite assumption: auth should be a portable contract, not a framework trick.

That is why the project reads less like a login helper and more like an operating layer for identity. It tries to keep the core stable while adapters, plugins, and platform-specific packages absorb the mess that usually fractures authentication.

Why Auth Keeps Breaking at the Edges

A brittle bridge made of mismatched planks spans several cliffs labeled with different app environments. One plank cracks under a heavy bundle of authentication features, while smaller modular pieces on the far side continue crossing safely.
Auth projects often begin as a simple bridge and end up as a pile of special cases. Better Auth tries to replace the brittle bridge with a modular span.

The common failure mode is predictable. A library starts with OAuth and cookies, then gets pulled into 2FA, passkeys, organizations, SSO, SCIM, and multi-tenancy. At that point, the original abstraction starts leaking, because it was built for a narrow use case, not a living identity system.

we try to put as much as flexibility as possible as battery included auth solution

Bereket Engida, Creator of Better Auth · What distinguishes this project from authjs? · Issue #94

One Core, Many Attachments

The repository structure makes the strategy obvious. There is a core package, then adapters for Drizzle, Prisma, Kysely, Mongo, and memory, plus plugins for organizations, two-factor auth, passkeys, API keys, and SSO. There are also platform-specific packages and demos for Expo and Electron, which tells you the core is not married to one deployment surface.

This diagram shows the project’s central promise. The same auth contract can run across different runtimes while swapping storage and feature layers underneath.

That modularity is not just neat packaging. It is the difference between a library that tolerates complexity and one that is built to absorb it. Better Auth separates the core auth contract from the concerns that usually contaminate it.

The Trick: Web Standards First

The portability story only works if the core speaks in web-native primitives. Better Auth leans into `Request` and `Response`, and its rules around `Uint8Array` instead of `Buffer` point in the same direction. That matters because Node-specific assumptions are exactly what break auth in edge runtimes and non-Node environments.

// The point is not the exact API shape.
// The point is that the contract stays web-native.

async function handleAuth(request: Request) {
  const session = await auth.getSession({ request });
  if (!session) return new Response("Unauthorized", { status: 401 });

  return new Response(JSON.stringify(session), {
    headers: { "content-type": "application/json" },
  });
}

That design choice explains why the same mental model can stretch across Next.js, edge workers, Electron, and Expo. The framework becomes a delivery surface, not the center of gravity.


The Core Contract Across Runtimes

Better Auth’s architecture can be understood as one contract with three moving parts. The runtime supplies the request, the core handles identity and lifecycle logic, and adapters or plugins fill in persistence and feature depth. The important thing is that each layer stays legible on its own.

That split also reduces the usual incentive to fork behavior per framework. If the same contract survives every surface, then edge, server, and desktop implementations can evolve without rewriting the auth brain each time.

What Makes It More Than Auth.js With Extras

Project shapeFramework portabilityEnterprise featuresStorage flexibilityOperational model
Better AuthDesigned as a portable runtime across frameworks and app surfacesPlugins for orgs, 2FA, passkeys, SSO, SCIM, API keysAdapter-first across multiple ORMs and databasesSelf-hosted infrastructure you own
Auth.js / NextAuthStrong in the web app world, especially Next.js historyPossible, but often assembled through extensions and custom workSupported through adapters, but the story is more framework-centeredOpen-source library to integrate and operate yourself
ClerkPortable only at the app integration layerRich hosted product with polished UXStorage and identity data live in the vendor systemManaged SaaS with strong convenience and vendor lock-in tradeoffs
Auth0Broad identity platformDeep enterprise supportDatabase and identity model are largely vendor-shapedHosted identity infrastructure with high abstraction
Passport.jsFramework-agnostic in the old Node senseMinimal out of the boxDepends on custom strategy and app wiringLow-level middleware style, not a modern platform

The key difference is not just feature count. It is product shape. Better Auth bundles advanced identity capabilities as attachable modules, which makes the whole system feel like infrastructure rather than a toolkit of isolated recipes.

Better Auth looks great! It's an inspiring project!

Balázs Orbán, Auth.js Maintainer · What distinguishes this project from authjs? · Issue #94

That is why comparisons with Clerk or Auth0 miss part of the story. Those products optimize for managed simplicity. Better Auth optimizes for ownership, portability, and a broad feature surface that still lives inside your stack.

Who This Is For, and Who Should Still Skip It

If you are...Better Auth fits when...Skip it when...
A startup building a serious productYou want to own auth, keep data in your stack, and add enterprise features without stitching together five vendorsYou need the fastest possible path to a polished hosted login flow
A platform teamYou need one contract across multiple runtimes and app surfacesYour environments are simple and unlikely to change
A team with regulated or sensitive dataYou want direct control over identity storage and workflowsYou would rather outsource compliance and operational burden to a vendor
A small team with limited ops bandwidthYou can tolerate self-hosting because the product shape mattersYou want almost no maintenance overhead

Better Auth is not the universal answer. Hosted auth still wins when convenience and delegation matter more than control. But if the strategic choice is to own identity as infrastructure, this project is aiming squarely at that problem.

Sources and Notes