Better-Auth for Typescript!

Quick Take: Better Auth, a new framework-agnostic authentication and authorization library for TypeScript, has just landed. It bundles advanced features like 2FA, multi-tenancy, and social sign-on out-of-the-box, aiming to be the comprehensive, self-hosted solution that runs directly within your app. This gives you full control over your user data without the complexity of rolling your own auth or paying per-user fees to third-party services.


πŸš€ The Crunch

🎯 Why This Matters: Tired of wrestling with incomplete auth libraries or pricey, data-siloing third-party services? Better Auth just landed to solve what it calls the “half-solved problem” of auth in TypeScript. It’s a comprehensive, self-hosted framework that gives you full control, advanced features out-of-the-box, and zero per-user costs, letting you focus on your app, not your auth.

🌐
Framework Freedom
It’s framework-agnostic. Use it with Next.js, SvelteKit, Hono, Express, Elysia, and more. No being locked into a specific ecosystem.
πŸ›‘οΈ
Batteries-Included Security
Get advanced features like 2FA, multi-tenancy, multi-session support, social sign-on, and a built-in rate limiter right out of the box.
🏠
Own Your Users & Data
Better Auth runs inside your app and uses your database. Your user data stays with you, not on a third-party server. No per-user fees, ever.
πŸ”Œ
Extensible with Plugins
Need more? The plugin ecosystem allows you to add more capabilities like passkeys or magic links without forking the library or writing complex workarounds.

⚑ Developer Tip: Get started in minutes for a quick evaluation. Install with npm install better-auth, set your BETTER_AUTH_SECRET and BETTER_AUTH_URL in a .env file, create your auth.ts instance with the simple SQLite adapter for instant setup, and run npx @better-auth/cli migrate. This gives you a fully functional auth system to play with in under 5 minutes.

Critical Caveats & Considerations

  • It’s New: This is a fresh open-source project. While built on solid principles, it hasn’t been battle-tested for years like some alternatives. Use with informed caution.
  • You Are The Host: The benefit of owning your data is also a responsibility. You are responsible for your database and application security.
  • Database Setup Required: It’s not zero-config. You must provide a database and configure the appropriate adapter (though SQLite makes this trivial for local dev).
  • CLI for Schema Management: Don’t forget to run the CLI’s migrate or generate command to create the necessary database tables for Better Auth to function.

πŸ”¬ The Dive

The Philosophy: Taking Back Control of Auth. Better Auth was born from a common developer frustration: authentication in the TypeScript world often feels like a choice between incomplete open-source tools and expensive, inflexible managed services. The project’s core belief is that developers deserve a comprehensive, framework-agnostic solution that they can fully own and control, without having to reinvent the wheel or hand over their user data.

πŸ’‘ “Authentication in the TypeScript ecosystem has long been a half-solved problem… I believe we can do better as a communityβ€”hence, Better Auth.”

How It Stacks Up: The Core Value Proposition

Better Auth positions itself as the sweet spot between rolling your own solution and relying on external services. It directly addresses the pain points of the main alternatives:

  • vs. Other Auth Libraries: Where others might only offer basic email/password flows, Better Auth includes advanced features like 2FA and multi-tenancy from the start. Its plugin system also provides a clear path for extension without forking.

  • vs. Self-Hosted Servers (like Keycloak): It eliminates operational overhead. Because Better Auth runs within your application, there’s no separate auth server to deploy, monitor, or maintain.

  • vs. Managed Services (like Auth0, Clerk): The biggest win is data ownership and cost. Your users live in your database, not a third-party’s, and you don’t face escalating per-user billing as you scale.

Getting Hands-On: The 5-Step Setup

Your Quickstart Guide

  • Install the Package: Pull the library into your project with your favorite package manager: npm install better-auth.
  • Set Environment Variables: Create a .env file and add your BETTER_AUTH_SECRET and the base BETTER_AUTH_URL of your application.
  • Create & Configure the Instance: In a new auth.ts file, import betterAuth and initialize it.
  • Migrate Your Database: Run the simple CLI command to automatically create the required tables in your database.
  • Mount the API Handler: Finally, create a catch-all API route in your framework and use the provided helper function to handle all auth requests.

TLDR; Vibe Check: Better Auth is the new, framework-agnostic TypeScript auth library that aims to be the last one you’ll need. It’s self-hosted, packed with features out-of-the-box, and lets you own your user data without the usual dev headaches or per-user fees.

Tom Furlanis
Researcher. Narrative designer. Wannabe Developer.
Twenty years ago, Tom was coding his 1st web applications in PHP. But then he left it all to pursue studies in humanities. Now, two decades later, empowered by his coding assistants, a degree in AI ethics and a plethora of unrealized dreams, Tom is determined to develop his apps. Developer heaven or bust? Stay tuned to discover!