better-auth

Configure TypeScript authentication for Cloudflare Workers with Drizzle ORM or Kysely.

Updated Oct 26, 2025
One-click install
npx skills add https://github.com/Hieubkav/wincellarCloneBackend --skill better-auth-hieubkav
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: better-auth
Source: https://github.com/Hieubkav/wincellarCloneBackend/tree/main/.claude/skills/fullstack/better-auth
Command: npx skills add https://github.com/Hieubkav/wincellarCloneBackend --skill better-auth-hieubkav

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires better-auth, drizzle-orm, drizzle-kit, @cloudflare/workers-types, hono, kysely, kysely-d1, and includes scripts (resource) and references (resource) and assets (resource) components.

What problem does it solve?

Provides production-ready authentication for TypeScript with Cloudflare Workers, including D1 support via Drizzle ORM or Kysely. It’s a self-hosted alternative to Clerk or Auth.js and supports social providers, email/password, magic links, 2FA, passkeys, organizations, and RBAC. Note: CRITICAL: There is no direct d1Adapter()—use Drizzle or Kysely.

Core Features & Use Cases

  • Cloudflare Workers + D1 integration with Drizzle ORM or Kysely
  • Social providers (Google, GitHub, Microsoft, etc.)
  • Email/password with verification and magic links
  • Two-factor authentication and passkeys
  • Organization/multi-tenant RBAC and permissions
  • Migration guides from Clerk and Auth.js
  • Robust session management, rate limiting, and security hardening

Quick Start

Pick Drizzle ORM (recommended) or Kysely with D1, install dependencies, wire up Cloudflare Workers, configure environment vars, and run a sample flow (signup/signin) using the included references.

Frequently Asked Questions about better-auth

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I set up authentication for Cloudflare Workers with D1?

Authentication for Cloudflare Workers with D1 uses better-auth paired with either Drizzle ORM or Kysely adapters. Install dependencies, configure your D1 database, wire up the auth framework in your Workers service, and initialize session management. Note: there is no direct d1Adapter—use Drizzle or Kysely as your database layer.

Can I use better-auth as a self-hosted alternative to Clerk or Auth.js?

Yes. Better-auth is a self-hosted TypeScript authentication framework for Cloudflare Workers that replaces Clerk or Auth.js. It includes social providers, email/password, magic links, 2FA, passkeys, organizations, and RBAC, with built-in migration guides from both platforms.

What authentication methods does better-auth support?

Better-auth supports social providers (Google, GitHub, Microsoft), email/password with verification, magic links, two-factor authentication, passkeys, and organization-based RBAC. It handles session management, OAuth flows, CORS configuration, and JWT token processing natively.

Does better-auth work with Kysely instead of Drizzle ORM?

Yes. Better-auth provides adapters for both Drizzle ORM and Kysely with D1. Choose either based on your preference; Drizzle is recommended, but Kysely is fully supported. Both integrate directly with Cloudflare D1 databases.

Can I implement multi-tenant RBAC with better-auth?

Yes. Better-auth includes organization and multi-tenant support with role-based access control (RBAC) and permissions. Configure organization structures, assign roles, and enforce permissions natively within the framework.

What should I know before migrating from Auth.js or Clerk to better-auth?

Better-auth provides migration guides from both Auth.js and Clerk. Key differences: it's self-hosted on Cloudflare Workers, uses Drizzle or Kysely for D1, and requires manual environment configuration. Session handling and OAuth flows migrate with minimal refactoring.