better-auth by secondsky/claude-skills
npx skills add https://github.com/secondsky/claude-skills --skill better-auth状态:生产就绪 最后更新:2025-12-26 包:better-auth@1.4.9(仅支持ESM) 依赖项:Drizzle ORM 或 Kysely(D1必需)
选项1:Drizzle ORM(推荐)
bun add better-auth drizzle-orm drizzle-kit
选项2:Kysely
bun add better-auth kysely @noxharmonium/kysely-d1
better-auth v1.4.0+ 仅支持ESM。请确保:
package.json:
{
"type": "module"
}
从 v1.3.x 升级? 加载 references/migration-guide-1.4.0.md
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
better-auth 没有直接的 d1Adapter()。您必须使用以下之一:
drizzleAdapter()// ❌ 错误 - 这个不存在
import { d1Adapter } from 'better-auth/adapters/d1'
// ✅ 正确 - 使用 Drizzle
import { drizzleAdapter } from 'better-auth/adapters/drizzle'
import { drizzle } from 'drizzle-orm/d1'
1. 创建 D1 数据库:
wrangler d1 create my-app-db
2. 定义模式(src/db/schema.ts):
import { integer, sqliteTable, text } from "drizzle-orm/sqlite-core";
export const user = sqliteTable("user", {
id: text().primaryKey(),
name: text().notNull(),
email: text().notNull().unique(),
emailVerified: integer({ mode: "boolean" }).notNull().default(false),
image: text(),
});
export const session = sqliteTable("session", {
id: text().primaryKey(),
userId: text().notNull().references(() => user.id, { onDelete: "cascade" }),
token: text().notNull(),
expiresAt: integer({ mode: "timestamp" }).notNull(),
});
// 完整模式请参见 references/database-schema.ts
3. 初始化认证(src/auth.ts):
import { betterAuth } from "better-auth";
import { drizzleAdapter } from "better-auth/adapters/drizzle";
import { drizzle } from "drizzle-orm/d1";
import * as schema from "./db/schema";
export function createAuth(env: { DB: D1Database; BETTER_AUTH_SECRET: string }) {
const db = drizzle(env.DB, { schema });
return betterAuth({
baseURL: env.BETTER_AUTH_URL,
secret: env.BETTER_AUTH_SECRET,
database: drizzleAdapter(db, { provider: "sqlite" }),
emailAndPassword: { enabled: true },
});
}
4. 创建 Worker(src/index.ts):
import { Hono } from "hono";
import { createAuth } from "./auth";
const app = new Hono<{ Bindings: Env }>();
app.all("/api/auth/*", async (c) => {
const auth = createAuth(c.env);
return auth.handler(c.req.raw);
});
export default app;
5. 部署:
bunx drizzle-kit generate
wrangler d1 migrations apply my-app-db --remote
wrangler deploy
关于代码示例和语法,请始终查阅 better-auth.com/docs。
这是一个新的/空项目吗?
├─ 是 → 新项目设置
│ 1. 确定框架(Next.js、Nuxt、Workers 等)
│ 2. 选择数据库(D1、PostgreSQL、MongoDB、MySQL)
│ 3. 安装 better-auth + Drizzle/Kysely
│ 4. 创建 auth.ts + auth-client.ts
│ 5. 设置路由处理器(参见上面的快速开始)
│ 6. 运行迁移(D1 使用 Drizzle Kit)
│ 7. 通过插件添加功能(2FA、组织等)
│
└─ 否 → 项目已有认证系统吗?
├─ 是 → 迁移/增强
│ • 审计当前认证系统的不足
│ • 规划增量迁移
│ • 迁移指南请参见 references/framework-comparison.md
│
└─ 否 → 为现有项目添加认证
1. 分析项目结构
2. 安装 better-auth + 适配器
3. 创建认证配置(参见快速开始)
4. 将路由处理器添加到现有路由
5. 运行模式迁移
6. 集成到现有页面/组件中
✅ 使用 Drizzle/Kysely 适配器(d1Adapter 不存在)
✅ 使用 Drizzle Kit 进行迁移(不是 better-auth migrate)
✅ 通过 wrangler secret put 设置 BETTER_AUTH_SECRET
✅ 配置 CORS 时使用 credentials: true
✅ OAuth 回调 URL 必须完全匹配(不能有尾部斜杠)
✅ 在 wrangler dev 之前将迁移应用到本地 D1
✅ 在模式中使用 camelCase 列名
❌ 对 D1 使用 d1Adapter 或 better-auth migrate
❌ 忘记 CORS 凭据或 OAuth URL 不匹配
❌ 使用 snake_case 列而不使用 CamelCasePlugin
❌ 跳过本地迁移或硬编码密钥
❌ 不实现 sendVerificationEmail
仅支持ESM(不支持 CommonJS):
// package.json 必需
{ "type": "module" }
API 重命名:
forgetPassword → requestPasswordReset/account-info → GET /account-info回调函数签名:
// v1.3.x:request 参数
sendVerificationEmail: async ({ user, url, request }) => {}
// v1.4.0+:ctx 参数
sendVerificationEmail: async ({ user, url, ctx }) => {}
从 <1.4.0 升级时加载 references/migration-guide-1.4.0.md
自 v1.4.3 以来的关键新增功能:
backgroundTasks 配置,用于延迟邮件发送better-auth CLI,包含项目脚手架详细实现指南请加载 references/v1.4-features.md。
| 变量 | 用途 | 示例 |
|---|---|---|
BETTER_AUTH_SECRET | 加密密钥(最少 32 个字符) | 生成:openssl rand -base64 32 |
BETTER_AUTH_URL | 基础 URL | https://example.com 或 http://localhost:8787 |
DATABASE_URL | 数据库连接(D1 可选) | PostgreSQL/MySQL 连接字符串 |
注意:如果未设置环境变量,仅在配置中定义 baseURL/secret。
| 命令 | 用途 |
|---|---|
npx @better-auth/cli@latest migrate | 应用模式(仅限内置 Kysely 适配器) |
npx @better-auth/cli@latest generate | 为 Prisma/Drizzle 生成模式 |
bunx drizzle-kit generate | D1:使用此命令生成 Drizzle 迁移 |
wrangler d1 migrations apply DB_NAME | D1:使用此命令应用迁移 |
添加/更改插件后重新运行。
| 选项 | 说明 |
|---|---|
appName | 可选的显示名称 |
baseURL | 仅当未设置 BETTER_AUTH_URL 时 |
basePath | 默认 /api/auth。设置为 / 表示根路径。 |
secret | 仅当未设置 BETTER_AUTH_SECRET 时(最少 32 个字符) |
database | 必需 用于大多数功能。D1 使用 drizzleAdapter() 或 Kysely |
secondaryStorage | 用于会话和速率限制的 Redis/KV |
emailAndPassword | { enabled: true } 以激活 |
socialProviders | { google: { clientId, clientSecret }, ... } |
plugins | 插件数组(从专用路径导入) |
trustedOrigins | 跨域请求的 CSRF 白名单 |
从专用路径导入以实现 tree-shaking:
import { twoFactor } from "better-auth/plugins/two-factor"
import { organization } from "better-auth/plugins/organization"
import { passkey } from "@better-auth/passkey" // 独立包
不要使用 from "better-auth/plugins"。
问题:尝试使用不存在的 d1Adapter
解决方案:改用 drizzleAdapter 或 Kysely(参见上面的快速开始)
问题:better-auth migrate 对 D1 无效
解决方案:使用 bunx drizzle-kit generate,然后使用 wrangler d1 migrations apply
问题:数据库使用 email_verified 但 better-auth 期望 emailVerified
解决方案:在模式中使用 camelCase 或在 Kysely 中添加 CamelCasePlugin
问题:Access-Control-Allow-Origin 错误,Cookie 未发送
解决方案:配置 CORS 时使用 credentials: true 和正确的来源
问题:社交登录失败,提示 "redirect_uri_mismatch"
解决方案:确保完全匹配:https://yourdomain.com/api/auth/callback/google
所有 15 个错误的详细解决方案请加载 references/error-catalog.md。
何时使用:无需社交提供商的基本认证 快速模式:
// 客户端
await authClient.signIn.email({
email: "user@example.com",
password: "password123",
});
// 服务器端 - 在配置中启用
emailAndPassword: {
enabled: true,
requireEmailVerification: true,
}
加载:references/setup-guide.md → 第 5 步
何时使用:允许用户使用社交账户登录 支持:Google、GitHub、Microsoft、Apple、Discord、TikTok、Twitch、Spotify、LinkedIn、Slack、Reddit、Facebook、Twitter/X、Patreon、Vercel、Kick 等 30 多个。 快速模式:
// 客户端
await authClient.signIn.social({
provider: "google",
callbackURL: "/dashboard",
});
// 服务器配置
socialProviders: {
google: {
clientId: env.GOOGLE_CLIENT_ID,
clientSecret: env.GOOGLE_CLIENT_SECRET,
scope: ["openid", "email", "profile"],
},
}
加载:references/setup-guide.md → 第 5 步
何时使用:需要验证用户是否已认证 快速模式:
app.get("/api/protected", async (c) => {
const auth = createAuth(c.env);
const session = await auth.api.getSession({
headers: c.req.raw.headers,
});
if (!session) {
return c.json({ error: "Unauthorized" }, 401);
}
return c.json({ data: "protected", user: session.user });
});
加载:references/cloudflare-worker-drizzle.ts
何时使用:构建具有团队/组织的 SaaS
加载:references/advanced-features.md → 组织与团队
何时使用:需要使用 2FA/TOTP 增强安全性
加载:references/advanced-features.md → 双因素认证
当出现以下情况时加载 references/setup-guide.md:
当出现以下情况时加载 references/error-catalog.md:
当出现以下情况时加载 references/advanced-features.md:
当出现以下情况时加载 references/cloudflare-worker-drizzle.ts:
当出现以下情况时加载 references/cloudflare-worker-kysely.ts:
当出现以下情况时加载 references/database-schema.ts:
当出现以下情况时加载 references/react-client-hooks.tsx:
当出现以下情况时加载 references/configuration-guide.md:
当出现以下情况时加载 references/framework-comparison.md:
当出现以下情况时加载 references/migration-guide-1.4.0.md:
forgetPassword 错误或 ESM 问题当出现以下情况时加载 references/v1.4-features.md:
当出现以下情况时加载 references/nextjs/README.md:
当出现以下情况时加载 references/nextjs/postgres-example.ts:
当出现以下情况时加载 references/frameworks/nextjs.md:
当出现以下情况时加载 references/frameworks/nuxt.md:
当出现以下情况时加载 references/frameworks/remix.md:
当出现以下情况时加载 references/frameworks/sveltekit.md:
当出现以下情况时加载 references/frameworks/api-frameworks.md:
当出现以下情况时加载 references/frameworks/expo-mobile.md:
当出现以下情况时加载 references/databases/postgresql.md:
当出现以下情况时加载 references/databases/mongodb.md:
当出现以下情况时加载 references/databases/mysql.md:
当出现以下情况时加载 references/plugins/authentication.md:
当出现以下情况时加载 references/plugins/enterprise.md:
当出现以下情况时加载 references/plugins/api-tokens.md:
当出现以下情况时加载 references/plugins/payments.md:
快速配置(v1.4.0+ 仅支持ESM):
export const auth = betterAuth({
baseURL: env.BETTER_AUTH_URL,
secret: env.BETTER_AUTH_SECRET,
database: drizzleAdapter(db, { provider: "sqlite" }),
});
以下情况请加载 references/configuration-guide.md:
创建认证客户端(src/lib/auth-client.ts):
import { createAuthClient } from "better-auth/client";
export const authClient = createAuthClient({
baseURL: import.meta.env.VITE_API_URL || "http://localhost:8787",
});
在 React 中使用:
import { authClient } from "@/lib/auth-client";
export function UserProfile() {
const { data: session, isPending } = authClient.useSession();
if (isPending) return <div>加载中...</div>;
if (!session) return <div>未认证</div>;
return (
<div>
<p>欢迎,{session.user.email}</p>
<button onClick={() => authClient.signOut()}>退出登录</button>
</div>
);
}
必需:
better-auth@^1.4.9 - 核心认证框架(仅支持ESM)选择一种适配器:
drizzle-orm@^0.44.7 + drizzle-kit@^0.31.7(推荐)kysely@^0.28.8 + @noxharmonium/kysely-d1@^0.4.0(替代方案)可选:
@cloudflare/workers-types - Workers 的 TypeScript 类型hono@^4.0.0 - 用于路由的 Web 框架@better-auth/passkey - 通行密钥插件(v1.4.0+,独立包)@better-auth/api-key - API 密钥认证(v1.4.0+)本技能专注于 Cloudflare Workers + D1。better-auth 还支持:
框架(共 18 个):Next.js、Nuxt、Remix、SvelteKit、Astro、Express、NestJS、Fastify、Elysia、Expo 等。
数据库(9 个适配器):PostgreSQL、MongoDB、MySQL、Prisma、MS SQL 等。
额外插件:匿名认证、邮箱 OTP、JWT、多会话、OIDC 提供商、支付集成(Stripe、Polar)。
对于非 Cloudflare 设置,请加载相应的框架或数据库参考文件,或查阅官方文档:https://better-auth.com/docs
以下情况请加载 references/framework-comparison.md:
已验证可用的仓库(全部使用 Drizzle 或 Kysely):
注意:检查每个仓库的 better-auth 版本。使用 v1.3.x 的仓库需要升级到 v1.4.0+(参见 references/migration-guide-1.4.0.md)。没有仓库使用直接的 d1Adapter - 全部需要 Drizzle/Kysely。
"type": "module")- v1.4.0+ 必需有问题?遇到问题?
references/error-catalog.md 获取所有 15 个错误及其解决方案references/setup-guide.md 获取完整的 8 步设置references/advanced-features.md 获取 2FA、组织等更多信息每周安装量
80
仓库
GitHub 星标数
90
首次出现
2026年1月24日
安全审计
安装于
claude-code67
gemini-cli65
codex63
opencode63
cursor61
github-copilot60
Status : Production Ready Last Updated : 2025-12-26 Package : better-auth@1.4.9 (ESM-only) Dependencies : Drizzle ORM or Kysely (required for D1)
Option 1: Drizzle ORM (Recommended)
bun add better-auth drizzle-orm drizzle-kit
Option 2: Kysely
bun add better-auth kysely @noxharmonium/kysely-d1
better-auth v1.4.0+ is ESM-only. Ensure:
package.json :
{
"type": "module"
}
Upgrading from v1.3.x? Load references/migration-guide-1.4.0.md
better-auth DOES NOT have a direct d1Adapter(). You MUST use either:
drizzleAdapter()// ❌ WRONG - This doesn't exist
import { d1Adapter } from 'better-auth/adapters/d1'
// ✅ CORRECT - Use Drizzle
import { drizzleAdapter } from 'better-auth/adapters/drizzle'
import { drizzle } from 'drizzle-orm/d1'
1. Create D1 Database:
wrangler d1 create my-app-db
2. Define Schema (src/db/schema.ts):
import { integer, sqliteTable, text } from "drizzle-orm/sqlite-core";
export const user = sqliteTable("user", {
id: text().primaryKey(),
name: text().notNull(),
email: text().notNull().unique(),
emailVerified: integer({ mode: "boolean" }).notNull().default(false),
image: text(),
});
export const session = sqliteTable("session", {
id: text().primaryKey(),
userId: text().notNull().references(() => user.id, { onDelete: "cascade" }),
token: text().notNull(),
expiresAt: integer({ mode: "timestamp" }).notNull(),
});
// See references/database-schema.ts for complete schema
3. Initialize Auth (src/auth.ts):
import { betterAuth } from "better-auth";
import { drizzleAdapter } from "better-auth/adapters/drizzle";
import { drizzle } from "drizzle-orm/d1";
import * as schema from "./db/schema";
export function createAuth(env: { DB: D1Database; BETTER_AUTH_SECRET: string }) {
const db = drizzle(env.DB, { schema });
return betterAuth({
baseURL: env.BETTER_AUTH_URL,
secret: env.BETTER_AUTH_SECRET,
database: drizzleAdapter(db, { provider: "sqlite" }),
emailAndPassword: { enabled: true },
});
}
4. Create Worker (src/index.ts):
import { Hono } from "hono";
import { createAuth } from "./auth";
const app = new Hono<{ Bindings: Env }>();
app.all("/api/auth/*", async (c) => {
const auth = createAuth(c.env);
return auth.handler(c.req.raw);
});
export default app;
5. Deploy:
bunx drizzle-kit generate
wrangler d1 migrations apply my-app-db --remote
wrangler deploy
For code examples and syntax, always consultbetter-auth.com/docs.
Is this a new/empty project?
├─ YES → New project setup
│ 1. Identify framework (Next.js, Nuxt, Workers, etc.)
│ 2. Choose database (D1, PostgreSQL, MongoDB, MySQL)
│ 3. Install better-auth + Drizzle/Kysely
│ 4. Create auth.ts + auth-client.ts
│ 5. Set up route handler (see Quick Start above)
│ 6. Run migrations (Drizzle Kit for D1)
│ 7. Add features via plugins (2FA, organizations, etc.)
│
└─ NO → Does project have existing auth?
├─ YES → Migration/enhancement
│ • Audit current auth for gaps
│ • Plan incremental migration
│ • See references/framework-comparison.md for migration guides
│
└─ NO → Add auth to existing project
1. Analyze project structure
2. Install better-auth + adapter
3. Create auth config (see Quick Start)
4. Add route handler to existing routes
5. Run schema migrations
6. Integrate into existing pages/components
✅ Use Drizzle/Kysely adapter (d1Adapter doesn't exist) ✅ Use Drizzle Kit for migrations (not better-auth migrate) ✅ Set BETTER_AUTH_SECRET via wrangler secret put ✅ Configure CORS with credentials: true ✅ Match OAuth callback URLs exactly (no trailing slash) ✅ Apply migrations to local D1 before wrangler dev ✅ Use camelCase column names in schema
❌ Use d1Adapter or better-auth migrate with D1 ❌ Forget CORS credentials or mismatch OAuth URLs ❌ Use snake_case columns without CamelCasePlugin ❌ Skip local migrations or hardcode secrets ❌ Leave sendVerificationEmail unimplemented
ESM-only (no CommonJS):
// package.json required
{ "type": "module" }
API Renames :
forgetPassword → requestPasswordReset/account-info → GET /account-infoCallback Signatures :
// v1.3.x: request parameter
sendVerificationEmail: async ({ user, url, request }) => {}
// v1.4.0+: ctx parameter
sendVerificationEmail: async ({ user, url, ctx }) => {}
Loadreferences/migration-guide-1.4.0.md when upgrading from <1.4.0
Key additions since v1.4.3 :
backgroundTasks config to defer email sendingbetter-auth CLI with project scaffoldingLoadreferences/v1.4-features.md for detailed implementation guides.
| Variable | Purpose | Example |
|---|---|---|
BETTER_AUTH_SECRET | Encryption secret (min 32 chars) | Generate: openssl rand -base64 32 |
BETTER_AUTH_URL | Base URL | https://example.com or http://localhost:8787 |
DATABASE_URL | Database connection (optional for D1) | PostgreSQL/MySQL connection string |
Note : Only define baseURL/secret in config if env vars are NOT set.
| Command | Purpose |
|---|---|
npx @better-auth/cli@latest migrate | Apply schema (built-in Kysely adapter only) |
npx @better-auth/cli@latest generate | Generate schema for Prisma/Drizzle |
bunx drizzle-kit generate | D1: Use this to generate Drizzle migrations |
wrangler d1 migrations apply DB_NAME | D1: Use this to apply migrations |
Re-run after adding/changing plugins.
| Option | Notes |
|---|---|
appName | Optional display name |
baseURL | Only if BETTER_AUTH_URL not set |
basePath | Default /api/auth. Set / for root. |
secret | Only if BETTER_AUTH_SECRET not set (min 32 chars) |
Import from dedicated paths for tree-shaking:
import { twoFactor } from "better-auth/plugins/two-factor"
import { organization } from "better-auth/plugins/organization"
import { passkey } from "@better-auth/passkey" // Separate package
NOT from "better-auth/plugins".
Problem : Trying to use non-existent d1Adapter Solution : Use drizzleAdapter or Kysely instead (see Quick Start above)
Problem : better-auth migrate doesn't work with D1 Solution : Use bunx drizzle-kit generate then wrangler d1 migrations apply
Problem : Database uses email_verified but better-auth expects emailVerified Solution : Use camelCase in schema or add CamelCasePlugin to Kysely
Problem : Access-Control-Allow-Origin errors, cookies not sent Solution : Configure CORS with credentials: true and correct origins
Problem : Social sign-in fails with "redirect_uri_mismatch" Solution : Ensure exact match: https://yourdomain.com/api/auth/callback/google
Loadreferences/error-catalog.md for all 15 errors with detailed solutions.
When : Basic authentication without social providers Quick Pattern :
// Client
await authClient.signIn.email({
email: "user@example.com",
password: "password123",
});
// Server - enable in config
emailAndPassword: {
enabled: true,
requireEmailVerification: true,
}
Load : references/setup-guide.md → Step 5
When : Allow users to sign in with social accounts Supported : Google, GitHub, Microsoft, Apple, Discord, TikTok, Twitch, Spotify, LinkedIn, Slack, Reddit, Facebook, Twitter/X, Patreon, Vercel, Kick, and 30+ more. Quick Pattern :
// Client
await authClient.signIn.social({
provider: "google",
callbackURL: "/dashboard",
});
// Server config
socialProviders: {
google: {
clientId: env.GOOGLE_CLIENT_ID,
clientSecret: env.GOOGLE_CLIENT_SECRET,
scope: ["openid", "email", "profile"],
},
}
Load : references/setup-guide.md → Step 5
When : Need to verify user is authenticated Quick Pattern :
app.get("/api/protected", async (c) => {
const auth = createAuth(c.env);
const session = await auth.api.getSession({
headers: c.req.raw.headers,
});
if (!session) {
return c.json({ error: "Unauthorized" }, 401);
}
return c.json({ data: "protected", user: session.user });
});
Load : references/cloudflare-worker-drizzle.ts
When : Building SaaS with teams/organizations Load : references/advanced-features.md → Organizations & Teams
When : Need extra security with 2FA/TOTP Load : references/advanced-features.md → Two-Factor Authentication
Loadreferences/setup-guide.md when:
Loadreferences/error-catalog.md when:
Loadreferences/advanced-features.md when:
Loadreferences/cloudflare-worker-drizzle.ts when:
Loadreferences/cloudflare-worker-kysely.ts when:
Loadreferences/database-schema.ts when:
Loadreferences/react-client-hooks.tsx when:
Loadreferences/configuration-guide.md when:
Loadreferences/framework-comparison.md when:
Loadreferences/migration-guide-1.4.0.md when:
forgetPassword errors or ESM issuesLoadreferences/v1.4-features.md when:
Loadreferences/nextjs/README.md when:
Loadreferences/nextjs/postgres-example.ts when:
Loadreferences/frameworks/nextjs.md when:
Loadreferences/frameworks/nuxt.md when:
Loadreferences/frameworks/remix.md when:
Loadreferences/frameworks/sveltekit.md when:
Loadreferences/frameworks/api-frameworks.md when:
Loadreferences/frameworks/expo-mobile.md when:
Loadreferences/databases/postgresql.md when:
Loadreferences/databases/mongodb.md when:
Loadreferences/databases/mysql.md when:
Loadreferences/plugins/authentication.md when:
Loadreferences/plugins/enterprise.md when:
Loadreferences/plugins/api-tokens.md when:
Loadreferences/plugins/payments.md when:
Quick Config (ESM-only in v1.4.0+):
export const auth = betterAuth({
baseURL: env.BETTER_AUTH_URL,
secret: env.BETTER_AUTH_SECRET,
database: drizzleAdapter(db, { provider: "sqlite" }),
});
Loadreferences/configuration-guide.md for:
Create auth client (src/lib/auth-client.ts):
import { createAuthClient } from "better-auth/client";
export const authClient = createAuthClient({
baseURL: import.meta.env.VITE_API_URL || "http://localhost:8787",
});
Use in React :
import { authClient } from "@/lib/auth-client";
export function UserProfile() {
const { data: session, isPending } = authClient.useSession();
if (isPending) return <div>Loading...</div>;
if (!session) return <div>Not authenticated</div>;
return (
<div>
<p>Welcome, {session.user.email}</p>
<button onClick={() => authClient.signOut()}>Sign Out</button>
</div>
);
}
Required :
better-auth@^1.4.9 - Core authentication framework (ESM-only)Choose ONE adapter :
drizzle-orm@^0.44.7 + drizzle-kit@^0.31.7 (recommended)kysely@^0.28.8 + @noxharmonium/kysely-d1@^0.4.0 (alternative)Optional :
@cloudflare/workers-types - TypeScript types for Workershono@^4.0.0 - Web framework for routing@better-auth/passkey - Passkey plugin (v1.4.0+, separate package)@better-auth/api-key - API key auth (v1.4.0+)This skill focuses on Cloudflare Workers + D1. better-auth also supports:
Frameworks (18 total): Next.js, Nuxt, Remix, SvelteKit, Astro, Express, NestJS, Fastify, Elysia, Expo, and more.
Databases (9 adapters): PostgreSQL, MongoDB, MySQL, Prisma, MS SQL, and others.
Additional Plugins : Anonymous auth, Email OTP, JWT, Multi-Session, OIDC Provider, payment integrations (Stripe, Polar).
For non-Cloudflare setups , load the appropriate framework or database reference file, or consult the official docs: https://better-auth.com/docs
Loadreferences/framework-comparison.md for:
Verified working repositories (all use Drizzle or Kysely):
Note : Check each repo's better-auth version. Repos on v1.3.x need v1.4.0+ migration (see references/migration-guide-1.4.0.md). None use a direct d1Adapter - all require Drizzle/Kysely.
"type": "module" in package.json) - v1.4.0+ requiredQuestions? Issues?
references/error-catalog.md for all 15 errors and solutionsreferences/setup-guide.md for complete 8-step setupreferences/advanced-features.md for 2FA, organizations, and moreWeekly Installs
80
Repository
GitHub Stars
90
First Seen
Jan 24, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
claude-code67
gemini-cli65
codex63
opencode63
cursor61
github-copilot60
Azure RBAC 权限管理工具:查找最小角色、创建自定义角色与自动化分配
142,000 周安装
AI引导抗体工程优化:从先导物到临床候选物的全流程解决方案
158 周安装
iOS Core Location 问题诊断指南 - 位置更新、后台定位、授权问题排查
159 周安装
Tone.js 教程:使用 Web Audio API 在浏览器中构建交互式音乐应用
160 周安装
sciomc:AI驱动的并行研究代理,自动化分解与验证复杂研究目标
168 周安装
Playwright CLI:无需编码的浏览器自动化测试工具 - 快速上手与安全指南
161 周安装
Spec测试套件生成工具 - 自动化编排smoke/regression/targeted测试用例,提升软件质量
70 周安装
database | Required for most features. Use drizzleAdapter() or Kysely for D1 |
secondaryStorage | Redis/KV for sessions & rate limits |
emailAndPassword | { enabled: true } to activate |
socialProviders | { google: { clientId, clientSecret }, ... } |
plugins | Array of plugins (import from dedicated paths) |
trustedOrigins | CSRF whitelist for cross-origin requests |