| name | better-auth |
| description | Implementation guide and best practices for Better Auth |
Better Auth Skill
Better Auth is a comprehensive authentication library for TypeScript. It's framework-agnostic and heavily plugin-based.
Quick Start
-
Install:
npm install better-auth
npx @better-auth/cli init
-
Database Setup:
Define your schema (Drizzle/Prisma) according to the docs. Better Auth needs specific tables (user, session, account, verification).
-
Server Configuration (lib/auth.ts):
import { betterAuth } from "better-auth";
import { drizzleAdapter } from "better-auth/adapters/drizzle";
import { db } from "./db";
export const auth = betterAuth({
database: drizzleAdapter(db, {
provider: "pg",
}),
emailAndPassword: {
enabled: true,
},
});
-
Client Configuration (lib/auth-client.ts):
import { createAuthClient } from "better-auth/client";
export const authClient = createAuthClient({
baseURL: process.env.NEXT_PUBLIC_APP_URL,
});
AI Integration
To enable deep integration with Cursor or other AI tools via MCP (Model Context Protocol):
npx @better-auth/cli mcp --cursor
This installs the context server that helps AI understand your specific auth configuration dynamically.
Resources