[PR #7519] [MERGED] feat: add built-in support for D1Database #7371

Closed
opened 2026-03-13 13:33:43 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/7519
Author: @bytaesu
Created: 1/21/2026
Status: Merged
Merged: 2/28/2026
Merged by: @himself65

Base: canaryHead: 2026-01-21/feat/cloudflare-d1-database


📝 Commits (7)

  • fe94a70 feat: add built-in support for D1Database
  • 3664ff3 fix: adjust detection condition
  • 0895ce6 fix: add cf-workers-types to peerDeps to resolve build error
  • e023a04 fix: use Kysely built-in SQLite classes for D1 dialect
  • 6afcd0a docs: streamline Cloudflare D1 guides and remove duplication
  • a9ecdf4 fix: handle numAffectedRows for zero affected rows in D1 dialect
  • 5c3c629 fix: throw descriptive error for unsupported D1 transactions

📊 Changes

8 files changed (+340 additions, -266 deletions)

View changed files

📝 docs/content/docs/concepts/database.mdx (+35 -113)
📝 docs/content/docs/integrations/hono.mdx (+1 -135)
📝 packages/core/package.json (+7 -0)
📝 packages/core/src/types/init-options.ts (+2 -0)
📝 packages/kysely-adapter/package.json (+1 -0)
packages/kysely-adapter/src/d1-sqlite-dialect.ts (+243 -0)
📝 packages/kysely-adapter/src/dialect.ts (+12 -0)
📝 pnpm-lock.yaml (+39 -18)

📄 Description

auth ts-17

Summary by cubic

Adds built-in support for Cloudflare D1Database so BetterAuth runs natively on Cloudflare Workers with a Kysely dialect and auto-detection. Removes the need for custom adapters and resolves Worker types build issues.

  • New Features

    • Added D1SqliteDialect for Kysely (queries, transactions, introspection).
    • Auto-detects D1 via batch/exec/prepare in getKyselyDatabaseType and createKyselyAdapter; BetterAuthOptions.database accepts D1Database.
  • Dependencies

    • Added @cloudflare/workers-types: optional peerDependency in core and devDependency in kysely-adapter.

Written for commit 313bbcae5ba5d6d79fe2a2f01a57c592685be2cb. Summary will update on new commits.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/better-auth/better-auth/pull/7519 **Author:** [@bytaesu](https://github.com/bytaesu) **Created:** 1/21/2026 **Status:** ✅ Merged **Merged:** 2/28/2026 **Merged by:** [@himself65](https://github.com/himself65) **Base:** `canary` ← **Head:** `2026-01-21/feat/cloudflare-d1-database` --- ### 📝 Commits (7) - [`fe94a70`](https://github.com/better-auth/better-auth/commit/fe94a70ec3433d442c86dc91f12fe6fe108770ef) feat: add built-in support for D1Database - [`3664ff3`](https://github.com/better-auth/better-auth/commit/3664ff398587f221c189dbe71d15bd97923905b7) fix: adjust detection condition - [`0895ce6`](https://github.com/better-auth/better-auth/commit/0895ce6f640b8b61004a58abc30fb316e3d43250) fix: add cf-workers-types to peerDeps to resolve build error - [`e023a04`](https://github.com/better-auth/better-auth/commit/e023a048ddc321029b2d9e019057c5918b31bf1d) fix: use Kysely built-in SQLite classes for D1 dialect - [`6afcd0a`](https://github.com/better-auth/better-auth/commit/6afcd0a24add808f762927f90d008e15a4650f1b) docs: streamline Cloudflare D1 guides and remove duplication - [`a9ecdf4`](https://github.com/better-auth/better-auth/commit/a9ecdf483872a2a2a39446cfcfdfcd4fc6c4c48e) fix: handle numAffectedRows for zero affected rows in D1 dialect - [`5c3c629`](https://github.com/better-auth/better-auth/commit/5c3c629d073f2dee460bf20c8efe99c5a8eb0859) fix: throw descriptive error for unsupported D1 transactions ### 📊 Changes **8 files changed** (+340 additions, -266 deletions) <details> <summary>View changed files</summary> 📝 `docs/content/docs/concepts/database.mdx` (+35 -113) 📝 `docs/content/docs/integrations/hono.mdx` (+1 -135) 📝 `packages/core/package.json` (+7 -0) 📝 `packages/core/src/types/init-options.ts` (+2 -0) 📝 `packages/kysely-adapter/package.json` (+1 -0) ➕ `packages/kysely-adapter/src/d1-sqlite-dialect.ts` (+243 -0) 📝 `packages/kysely-adapter/src/dialect.ts` (+12 -0) 📝 `pnpm-lock.yaml` (+39 -18) </details> ### 📄 Description <img width="400" alt="auth ts-17" src="https://github.com/user-attachments/assets/6afd3ad5-5dee-42b9-ba2b-2f86ba2d8e17" /> <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Adds built-in support for Cloudflare D1Database so BetterAuth runs natively on Cloudflare Workers with a Kysely dialect and auto-detection. Removes the need for custom adapters and resolves Worker types build issues. - **New Features** - Added D1SqliteDialect for Kysely (queries, transactions, introspection). - Auto-detects D1 via batch/exec/prepare in getKyselyDatabaseType and createKyselyAdapter; BetterAuthOptions.database accepts D1Database. - **Dependencies** - Added @cloudflare/workers-types: optional peerDependency in core and devDependency in kysely-adapter. <sup>Written for commit 313bbcae5ba5d6d79fe2a2f01a57c592685be2cb. Summary will update on new commits.</sup> <!-- End of auto-generated description by cubic. --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-03-13 13:33:43 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#7371