better-auth

Integrate better-auth with Cloudflare D1 using Drizzle ORM or Kysely adapters.

961|99|Updated Oct 20, 2025
One-click install
npx skills add https://github.com/jezweb/claude-skills --skill better-auth-jezweb
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: better-auth
Source: https://github.com/jezweb/claude-skills/tree/main/skills/better-auth
Command: npx skills add https://github.com/jezweb/claude-skills --skill better-auth-jezweb

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve?

This Skill eliminates the complexity of implementing secure authentication systems from scratch, saving you over 200 hours of development time.

Core Features & Use Cases

  • Cloudflare D1 Integration: Complete authentication with Drizzle ORM or Kysely adapters for D1 databases.
  • Self-Hosted Alternative: Replace expensive services like Clerk with a free, vendor-independent solution.
  • Use Case: Imagine migrating from Clerk to avoid vendor lock-in. Use this Skill to implement the same features (2FA, organizations, social auth) without monthly costs.

Quick Start

Set up better-auth with Cloudflare D1 using Drizzle ORM adapter instead of the non-existent d1Adapter.

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 with Cloudflare D1 and Drizzle ORM?

Authentication with Cloudflare D1 uses Drizzle ORM adapter via drizzleAdapter(db, { provider: 'sqlite' }) instead of a non-existent d1Adapter. This integrates better-auth directly with D1 databases on Cloudflare Workers, eliminating the adapter gap and enabling production authentication without external services.

Can I replace Clerk with a self-hosted authentication solution on Cloudflare?

Yes. Better-auth provides self-hosted authentication on Cloudflare Workers with D1, supporting 2FA, social logins, organizations, and RBAC without vendor lock-in. Migrate from Clerk by using Drizzle or Kysely adapters to manage your own authentication database and user sessions.

What authentication features does better-auth support on Cloudflare Workers?

Better-auth on Cloudflare Workers supports social OAuth, two-factor authentication, passkeys, organizations, RBAC, multi-tenant SaaS, JWT key rotation, SCIM provisioning, and stateless sessions. Kysely integration also available via D1Dialect for alternative ORM setup.

Does better-auth work with Kysely on Cloudflare D1?

Yes. Better-auth integrates with Kysely using D1Dialect for SQLite databases on Cloudflare D1. This provides an alternative to Drizzle ORM while maintaining full support for stateless sessions, OAuth flows, and session serialization on Workers.

How do I handle session management and OAuth flows with better-auth on Workers?

Better-auth manages stateless sessions and OAuth flows with built-in guard rails for session serialization on Cloudflare Workers. TanStack Start cookie plugin integration supports secure cookie handling, while JWT key rotation ensures token security across distributed Worker instances.

What's the difference between using Drizzle and Kysely adapters for better-auth on D1?

Both Drizzle ORM and Kysely adapters enable D1 integration with better-auth. Drizzle uses drizzleAdapter(db, { provider: 'sqlite' }), while Kysely uses D1Dialect. Choose based on your ORM preference; both provide equivalent authentication features and performance on Cloudflare Workers.