Better Auth Studio automatically detects and works with various database adapters from your Better Auth configuration.
Supported Adapters
Studio supports the following database adapters:
- Prisma (
prismaAdapter)
- Drizzle (
drizzleAdapter)
- SQLite (
better-sqlite3)
- PostgreSQL (via Prisma or Drizzle)
- MySQL (via Prisma or Drizzle)
Configuration
The database adapter is configured in your Better Auth instance. Studio automatically reads this configuration from your auth.ts file.
Prisma Setup
import { betterAuth } from "better-auth";
import { prismaAdapter } from "better-auth/adapters/prisma";
import { PrismaClient } from "@prisma/client";
const prisma = new PrismaClient();
export const auth = betterAuth({
database: prismaAdapter(prisma, {
provider: "postgresql", // or "mysql", "sqlite"
}),
// ... other config
});
Drizzle Setup
import { betterAuth } from "better-auth";
import { drizzleAdapter } from "better-auth/adapters/drizzle";
import { db } from "./database";
export const auth = betterAuth({
database: drizzleAdapter(db, {
provider: "pg", // or "mysql", "sqlite"
}),
// ... other config
});
SQLite Setup
import { betterAuth } from "better-auth";
import Database from "better-sqlite3";
export const auth = betterAuth({
database: new Database("./better-auth.db"),
// ... other config
});
Database Configuration Options
The type of database adapter being used (e.g., “drizzle”, “prisma”, “sqlite”)
The specific adapter implementation name
The database provider: "postgresql", "mysql", "sqlite", "pg"
The SQL dialect used by the database
The casing convention for database column names
Enable debug logging for database queries
The database connection URL or connection string
Auto-Detection
Studio automatically detects your database adapter from the Better Auth configuration. You don’t need to configure the adapter separately for Studio.
When you start Studio, it:
- Searches for your
auth.ts configuration file
- Loads the Better Auth instance
- Extracts the database adapter
- Uses the adapter for all database operations
Adapter Interface
Studio extends the internal Better Auth adapter with additional methods:
interface AuthAdapter {
// User operations
createUser(data: any): Promise<any>;
getUsers(): Promise<any[]>;
// Session operations
createSession(data: any): Promise<any>;
getSessions(): Promise<any[]>;
// Organization operations
createOrganization(data: any): Promise<any>;
// Account operations
createAccount(data: any): Promise<any>;
// Verification operations
createVerification(data: any): Promise<any>;
// Generic CRUD operations
findMany<T = any>(options: {
model: string;
where?: any;
limit?: number;
offset?: number;
}): Promise<T[]>;
}
Troubleshooting
If Studio cannot detect your database adapter, ensure:
- Your
auth.ts file exports the auth instance as export const auth or as default export
- The database adapter is properly configured in Better Auth
- You don’t have
import 'server-only' in your auth config (temporarily remove it for CLI usage)
Custom Adapter Paths
If your auth configuration is in a non-standard location, specify it with the --config flag:
pnpm better-auth-studio start --config ./src/lib/auth.ts