Feature Request: Extract Internal DB Abstraction Layer into Standalone Package (e.g. @better-db) #2939

Closed
opened 2026-03-13 10:28:32 -05:00 by GiteaMirror · 3 comments
Owner

Originally created by @heiwen on GitHub (Mar 1, 2026).

Summary

We're building Hebo Gateway, an embeddable, self-hostable AI gateway for LLM applications: https://github.com/8monkey-ai/hebo-gateway/

It acts as a unified layer in front of model providers (OpenAI, Anthropic, Bedrock, Groq, etc.) and provides OpenAI-compatible interfaces. Some of them are stateful (e.g. Responses / Conversation API) and require an underlying DB layer for storage.

Since Hebo Gateway is designed to be embedded into other products and SaaS (in the same way as better-auth), we aim to: stay ORM-agnostic, avoid forcing a database / ORM-layer choice and keep bundle size minimal. This means to allow consumers to bring their own DB stack

In fact, in many cases Hebo Gateway is designed to work together with better-auth, as we don't plan to provide our own API Key authentication mechanism, but allow consumers to bring their own, with better-auth being a preferred choice.

Similar to how better-fetch and better-call are already separate libraries, it would be great if this could be extracted out into something like better-db / better-orm.

This would follow a similar pattern to how Standard Schema provides an abstraction across schema libraries like zod, valibot, typebox.

Alternatives

There is currently no widely adopted, minimal, ORM-agnostic database abstraction layer for TypeScript.

Projects like:

  • @superfunctions/db
  • unadapter

attempt to provide a unified interface across Prisma, Drizzle, Kysely, etc., but:

  • They introduce additional bundle size
  • They duplicate logic already implemented inside Better Auth
  • They are not yet widely adopted

Better Auth’s internal DB abstraction is:

  • Minimal
  • Cleanly designed
  • Adapter-based
  • Production-proven
  • ORM-agnostic

It is exactly the kind of “lowest common denominator” interface that many libraries need.

Originally created by @heiwen on GitHub (Mar 1, 2026). ## Summary We're building **Hebo Gateway**, an embeddable, self-hostable AI gateway for LLM applications: https://github.com/8monkey-ai/hebo-gateway/ It acts as a unified layer in front of model providers (OpenAI, Anthropic, Bedrock, Groq, etc.) and provides OpenAI-compatible interfaces. Some of them are stateful (e.g. Responses / Conversation API) and require an underlying DB layer for storage. Since Hebo Gateway is designed to be embedded into other products and SaaS (in the same way as `better-auth`), we aim to: stay ORM-agnostic, avoid forcing a database / ORM-layer choice and keep bundle size minimal. This means to allow consumers to bring their own DB stack In fact, in many cases Hebo Gateway is designed to work together with `better-auth`, as we don't plan to provide our own API Key authentication mechanism, but allow consumers to bring their own, with `better-auth` being a preferred choice. Similar to how `better-fetch` and `better-call` are already separate libraries, it would be great if this could be extracted out into something like `better-db` / `better-orm`. This would follow a similar pattern to how [`Standard Schema`](https://standardschema.dev/) provides an abstraction across schema libraries like `zod`, `valibot`, `typebox`. ## Alternatives There is currently no widely adopted, minimal, ORM-agnostic database abstraction layer for TypeScript. Projects like: - `@superfunctions/db` - `unadapter` attempt to provide a unified interface across Prisma, Drizzle, Kysely, etc., but: - They introduce additional bundle size - They duplicate logic already implemented inside Better Auth - They are not yet widely adopted Better Auth’s internal DB abstraction is: - Minimal - Cleanly designed - Adapter-based - Production-proven - ORM-agnostic It is exactly the kind of “lowest common denominator” interface that many libraries need.
GiteaMirror added the enhancement label 2026-03-13 10:28:32 -05:00
Author
Owner

@himself65 commented on GitHub (Mar 1, 2026):

We have @better-auth/*-adapter right now. And we will polish it as much as possible

@himself65 commented on GitHub (Mar 1, 2026): We have @better-auth/*-adapter right now. And we will polish it as much as possible
Author
Owner

@heiwen commented on GitHub (Mar 1, 2026):

Oh wow, that's quite timely!

I think for what I'm looking for there is one more step missing: @better-auth/*-adapter currently depends on @better-auth/core/db/adapter which itself pulls in @better-auth/core/db/ with all the better-auth specific table definitions.

I'd love to be able to use @better-auth/core/db/adapter as a standalone package, and define my own table structure.

@heiwen commented on GitHub (Mar 1, 2026): Oh wow, that's quite timely! I think for what I'm looking for there is one more step missing: `@better-auth/*-adapter` currently depends on `@better-auth/core/db/adapter` which itself pulls in `@better-auth/core/db/` with all the better-auth specific table definitions. I'd love to be able to use `@better-auth/core/db/adapter` as a standalone package, and define my own table structure.
Author
Owner

@heiwen commented on GitHub (Mar 3, 2026):

@himself65 would you consider extracting @better-auth/core/db/adapter into a stand-alone library without any other better-auth dependencies?

@heiwen commented on GitHub (Mar 3, 2026): @himself65 would you consider extracting `@better-auth/core/db/adapter` into a stand-alone library without any other better-auth dependencies?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#2939