better-auth

Configure self-hosted authentication for Cloudflare Workers with D1 using Drizzle ORM or Kysely.

Updated Feb 4, 2026
One-click install
npx skills add https://github.com/junaid-ali-ruk/auto-linkedin --skill better-auth-junaid-ali-ruk
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: better-auth
Source: https://github.com/junaid-ali-ruk/auto-linkedin/tree/main/.gemini/skills/better-auth
Command: npx skills add https://github.com/junaid-ali-ruk/auto-linkedin --skill better-auth-junaid-ali-ruk

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve?

This skill provides a comprehensive blueprint and tooling guidance to build secure, self-hosted authentication systems on Cloudflare Workers using D1 with Drizzle ORM or Kysely, including 2FA, SSO, organizations, and RBAC.

Core Features & Use Cases

  • D1-based auth scaffolding: Quick-start setup that wires Drizzle/Kysely to Cloudflare D1 for user, session, and account management.
  • Multi-tenant & RBAC: Organize users into organizations and teams with role-based access controls.
  • OAuth/OIDC & Social Sign-In: Integrates social login providers and OpenID Connect flows with secure session handling.
  • Secure sessions & migrations: Stateless or KV-backed sessions, JWT rotation, and migration guidance for D1 schemas.
  • Use Case: Migrate an existing Clerk-based app to a self-hosted authentication system with organization-wide access control and single sign-on.

Quick Start

Use the included setup script to bootstrap a Cloudflare Worker with better-auth and D1, then customize your OAuth providers and session strategy.

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 on Cloudflare Workers using D1?

To set up self-hosted authentication on Cloudflare Workers with D1, use the provided setup script to bootstrap a project, then configure a Drizzle ORM or Kysely adapter to manage users, sessions, and accounts.

Can I implement multi-tenant RBAC and organization management with Cloudflare D1?

Yes, you can implement multi-tenant RBAC on Cloudflare D1 by organizing users into organizations and teams, applying role-based access controls directly through the better-auth integration with Drizzle or Kysely.

Does better-auth support OAuth, OIDC, and SAML social login for D1?

Yes, better-auth supports OAuth, OIDC, and SAML social login for D1, integrating social providers and OpenID Connect flows with secure stateless or KV-backed session handling.

How do I generate database migrations for auth schemas in Cloudflare D1?

To generate database migrations for auth schemas in Cloudflare D1, use the Drizzle ORM adapter tooling to create and apply schema migrations for user, session, and account tables.

What is the best way to migrate from Clerk to a self-hosted auth system on Workers?

The best way to migrate from Clerk to a self-hosted auth system on Workers is to use this skill to configure D1 adapters, manage organizations, and set up single sign-on with OAuth and SAML.

Can I use Kysely instead of Drizzle ORM for authentication on Cloudflare D1?

Yes, you can use Kysely instead of Drizzle ORM for authentication on Cloudflare D1, as the skill provides adapter configurations and server-side API methods for both query builders.