[PR #4236] [CLOSED] feat: AdapterRouter (experimental) #30870

Closed
opened 2026-04-17 21:52:30 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/4236
Author: @zpg6
Created: 8/26/2025
Status: Closed

Base: canaryHead: feat/adapter-router


📝 Commits (10+)

  • adc2670 feat: AdapterRouter (experimental)
  • d221bcf docs: cleanup Adapter Router README
  • f7c329b docs: improved organization example
  • ecc3360 docs: clarify cross-adapter
  • 22a8a4a docs: emphasize how this relates to design of Adapter
  • 6f8d9f7 fix: clarify plugin support
  • 6b1dd80 feat: provide access to fallbackAdapter in routing callbacks
  • a9cee4f fix: properly export adapter router
  • 568a440 feat: return whether considered a core model
  • 81687cf fix: improve callback data type

📊 Changes

5 files changed (+1571 additions, -6 deletions)

View changed files

📝 packages/better-auth/build.config.ts (+1 -0)
📝 packages/better-auth/package.json (+19 -6)
packages/better-auth/src/adapters/adapter-router/README.md (+287 -0)
packages/better-auth/src/adapters/adapter-router/index.ts (+311 -0)
packages/better-auth/src/adapters/adapter-router/test/adapter-router.test.ts (+953 -0)

📄 Description

Route different Better Auth models to different database adapters while maintaining a unified interface. Perfect for things like multi-tenancy, gradual migrations, performance tiers, and microservices data ownership.

READ MORE:
https://github.com/zpg6/better-auth/tree/feat/adapter-router/packages/better-auth/src/adapters/adapter-router#readme


Summary by cubic

Adds an experimental AdapterRouter that routes Better Auth models to different database adapters while keeping a single, unified interface. Enables multi-tenancy, gradual migrations, performance tiers, and microservices-style data ownership.

  • New Features
    • adapterRouter with a required fallbackAdapter and ordered route callbacks; routes receive { modelName, operation, data } and can be async.
    • Full Adapter API passthrough (create/find/update/delete/count); relationships work transparently across adapters; createSchema uses the fallback adapter.
    • Debug logging for routing decisions and strong TypeScript types for config and callbacks.
    • README with examples (priority routing, load balancing, compliance) and comprehensive tests covering priority, async routing, CRUD, and failures.

🔄 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/4236 **Author:** [@zpg6](https://github.com/zpg6) **Created:** 8/26/2025 **Status:** ❌ Closed **Base:** `canary` ← **Head:** `feat/adapter-router` --- ### 📝 Commits (10+) - [`adc2670`](https://github.com/better-auth/better-auth/commit/adc267019e5bbb1d60caa750539f997d66d648d1) feat: AdapterRouter (experimental) - [`d221bcf`](https://github.com/better-auth/better-auth/commit/d221bcfdf93579b7aef9060291544dbb709afc94) docs: cleanup Adapter Router README - [`f7c329b`](https://github.com/better-auth/better-auth/commit/f7c329b6a8cf9759a5ad1837ae586c202c5be1c5) docs: improved organization example - [`ecc3360`](https://github.com/better-auth/better-auth/commit/ecc3360cb850dd9abb0e352ef1218cab58595048) docs: clarify cross-adapter - [`22a8a4a`](https://github.com/better-auth/better-auth/commit/22a8a4a8a3d83db7e2e97c5adda31f1c8b11e3bf) docs: emphasize how this relates to design of Adapter - [`6f8d9f7`](https://github.com/better-auth/better-auth/commit/6f8d9f7bc93eaa4b88046973c3b747e57e45c5eb) fix: clarify plugin support - [`6b1dd80`](https://github.com/better-auth/better-auth/commit/6b1dd8008d5158658139551608abd24bd0b5f08b) feat: provide access to `fallbackAdapter` in routing callbacks - [`a9cee4f`](https://github.com/better-auth/better-auth/commit/a9cee4fd8b82d67919b0bd29caff7389898c6c4f) fix: properly export adapter router - [`568a440`](https://github.com/better-auth/better-auth/commit/568a4401a458273e8880b4e89c78bcbbb8706a99) feat: return whether considered a core model - [`81687cf`](https://github.com/better-auth/better-auth/commit/81687cfa71efbd8876fb7d07098525b3161f8459) fix: improve callback data type ### 📊 Changes **5 files changed** (+1571 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/build.config.ts` (+1 -0) 📝 `packages/better-auth/package.json` (+19 -6) ➕ `packages/better-auth/src/adapters/adapter-router/README.md` (+287 -0) ➕ `packages/better-auth/src/adapters/adapter-router/index.ts` (+311 -0) ➕ `packages/better-auth/src/adapters/adapter-router/test/adapter-router.test.ts` (+953 -0) </details> ### 📄 Description Route different Better Auth models to different database adapters while maintaining a unified interface. Perfect for things like multi-tenancy, gradual migrations, performance tiers, and microservices data ownership. READ MORE: https://github.com/zpg6/better-auth/tree/feat/adapter-router/packages/better-auth/src/adapters/adapter-router#readme <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Adds an experimental AdapterRouter that routes Better Auth models to different database adapters while keeping a single, unified interface. Enables multi-tenancy, gradual migrations, performance tiers, and microservices-style data ownership. - **New Features** - adapterRouter with a required fallbackAdapter and ordered route callbacks; routes receive { modelName, operation, data } and can be async. - Full Adapter API passthrough (create/find/update/delete/count); relationships work transparently across adapters; createSchema uses the fallback adapter. - Debug logging for routing decisions and strong TypeScript types for config and callbacks. - README with examples (priority routing, load balancing, compliance) and comprehensive tests covering priority, async routing, CRUD, and failures. <!-- 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-04-17 21:52:30 -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#30870