better-auth

Configure self-hosted authentication for Cloudflare Workers with D1.

16|7|Updated Nov 20, 2025
One-click install
npx skills add https://github.com/jackspace/ClaudeSkillz --skill better-auth-jackspace
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: better-auth
Source: https://github.com/jackspace/ClaudeSkillz/tree/main/skills/better-auth
Command: npx skills add https://github.com/jackspace/ClaudeSkillz --skill better-auth-jackspace

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve?

This Skill provides comprehensive, self-hosted authentication and authorization patterns for Cloudflare Workers + D1, enabling complex security scenarios without vendor lock-in.

Core Features & Use Cases

  • Cloudflare Workers + D1 integration patterns
  • Social providers and 2FA, orgs, and RBAC
  • Migration guides from Clerk and Auth.js
  • Protected routes and middleware patterns

Quick Start

Install better-auth, wire up a D1/PostgreSQL adapter, and implement a few authentication patterns (email/password, social login, 2FA) in your app.

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 self-hosted authentication for Cloudflare Workers?

Self-hosted authentication for Cloudflare Workers uses better-auth with D1 database integration. Install better-auth, configure a D1 adapter, and wire up authentication patterns like email/password or social login directly in your Worker environment without vendor lock-in.

Can I use better-auth with Cloudflare D1 for multi-tenant RBAC?

Yes. Better-auth provides first-class D1 support with built-in patterns for organizations, role-based access control, and multi-tenant setups. Configure org structures and roles in your D1 schema, then apply middleware to protect routes by role.

How do I migrate from Clerk or Auth.js to a self-hosted solution?

Better-auth includes migration guides from Clerk and Auth.js. These guides cover adapter setup, session management, JWT handling, and client/server patterns across Workers, Next.js API routes, and React clients to ease the transition.

What authentication features does better-auth support?

Better-auth supports email/password authentication, social provider login, two-factor authentication, passkeys, and organization management with RBAC. All features run self-hosted on Cloudflare Workers without external dependencies.

Does better-auth work with Next.js or only Cloudflare Workers?

Better-auth works with Cloudflare Workers as its primary runtime and integrates with Next.js API routes and React clients. It handles OAuth flows, session management, and protected routes across both serverless and traditional Node.js stacks.

How do I implement two-factor authentication with better-auth?

Better-auth includes 2FA patterns for D1 and Workers environments. Configure 2FA in your authentication flow, store verification secrets in D1, and implement middleware to enforce 2FA checks before granting access to protected resources.