Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/amanvarshney01/create-better-t-stack/llms.txt

Use this file to discover all available pages before exploring further.

Better-T-Stack provides integrated authentication setup with automatic configuration for your chosen stack.

Authentication Providers

Comprehensive auth framework for TypeScript.

Overview

Better-Auth is a self-hosted, framework-agnostic authentication library that provides a complete authentication solution with maximum flexibility and control.What’s Included:
  • Email/password authentication
  • Social OAuth providers
  • Session management
  • CSRF protection
  • Type-safe API
  • Database schema generation
  • Email verification
  • Password reset flows

Features

Self-Hosted

Full control over your authentication data and infrastructure.

Type-Safe

End-to-end TypeScript support with automatic type inference.

Framework Agnostic

Works with any frontend or backend framework.

Extensible

Plugin system for custom authentication flows.

Frontend Compatibility

Better-Auth is available for:
  • TanStack Router
  • TanStack Start
  • Next.js
  • React Native (Bare, Uniwind, Unistyles)
  • Any frontend when using a compatible backend
When using Convex backend, Better-Auth is only available for specific frontends (see above).

Backend Requirements

Better-Auth requires a backend that is not set to none. It works with:
  • All server frameworks (Hono, Express, Fastify, Elysia)
  • Self (fullstack) mode
  • Convex (limited frontend compatibility)

Database Integration

Better-Auth automatically integrates with your database choice:
  • Creates authentication tables/collections
  • Configures ORM models
  • Sets up migrations
  • Handles schema updates
Supported Databases:
  • SQLite (with Drizzle or Prisma)
  • PostgreSQL (with Drizzle or Prisma)
  • MySQL (with Drizzle or Prisma)
  • MongoDB (with Mongoose or Prisma)

Configuration Example

// packages/auth/src/index.ts
import { betterAuth } from 'better-auth'
import { db } from '@repo/db'

export const auth = betterAuth({
  database: db,
  emailAndPassword: {
    enabled: true,
  },
  socialProviders: {
    github: {
      clientId: process.env.GITHUB_CLIENT_ID,
      clientSecret: process.env.GITHUB_CLIENT_SECRET,
    },
  },
})

Best For

  • Complete control over authentication logic
  • Custom authentication flows
  • Self-hosted requirements
  • Compliance needs (GDPR, HIPAA)
  • No per-user pricing
  • Predictable costs
  • High-volume applications
  • Budget-conscious projects
  • Custom user models
  • Unique authentication flows
  • Integration with existing systems
  • Specialized requirements

Comparison

FeatureBetter-AuthClerk
HostingSelf-hostedManaged
CostFree (infrastructure only)Free tier + paid plans
DatabaseRequiredNot required
CustomizationFull controlLimited to Clerk’s features
UI ComponentsBuild your ownPre-built
Setup ComplexityModerateLow
OrganizationsCustom implementationBuilt-in
MFACustom implementationBuilt-in
User DashboardCustom implementationBuilt-in
Social ProvidersConfigure yourself20+ pre-configured

Choosing Your Auth Provider

1

Check Your Backend

  • Convex: Better-Auth or Clerk
  • Other backends: Better-Auth
  • None: No auth available
2

Evaluate Your Needs

  • Self-hosted: Better-Auth
  • Managed service: Clerk
  • Organizations: Clerk (built-in)
  • Custom flows: Better-Auth
3

Consider Your Budget

  • Cost-sensitive: Better-Auth
  • Time-sensitive: Clerk
  • High volume: Better-Auth
  • Prototype: Either (Clerk faster setup)
4

Check Frontend Compatibility

Some frontends have limited auth options with certain backends (especially Convex).

Integration with Other Features

When you add Polar payments, authentication is automatically integrated:
  • User accounts linked to customer profiles
  • Subscription management
  • Payment history
Better-Auth creates necessary database tables:
  • Users table
  • Sessions table
  • Accounts table (for OAuth)
  • Verification tokens
Clerk doesn’t require database tables (managed externally).
Both providers integrate with your frontend:
  • Route protection
  • Authentication state
  • User profile access
  • Session management

Next Steps

Addons

Enhance your stack with additional features

Deployment

Deploy your authenticated application

Build docs developers (and LLMs) love