Package Exports
- @carere/gel-better-auth
Readme
About The Project
Why Gel Better Auth?
Gel (formerly EdgeDB) is a wonderful database that is a joy to work with. Better Auth is the best authentication framework for TypeScript. Obviously, they both work great together, so I decided to create this adapter to make it even better :)
Features
- 🚀 Schema Generation: Work out of the box with any Better Auth plugins.
- 🔒 Cascading Delete: Cascading delete is supported for all models.
- ⚡ Indexes Support: Works out of the box, see examples for more details.
- 🛠 Constraints: Unique flag are supported as native Gel's constraints.
- 🎯 Scalar Types: Literals are represented as Scalar Type in the schema !!
- 🔥 Link instead of Id: relations like
userIdare represented as computed property !!
Enjoy the power of Better Auth and Gel together!
Getting Started
Get up and running in just a few minutes.
Prerequisites
- Bun (recommended) or Node.js runtime
- Gel/EdgeDB instance (prefer local)
- Better Auth configured in your project
Installation
Install the package and peer dependencies
# Using Bun (recommended) bun add @carere/gel-better-auth better-auth gel # Using npm npm install @carere/gel-better-auth better-auth gel # Using pnpm pnpm add @carere/gel-better-auth better-auth gel
Set up your Gel connection
# Initialize Gel project (if not already done) gel project initGenerate the Gel schema
bunx @better-auth/cli generate
Run the watcher for automatic migrations (in dev mode)
gel watch -m
Usage
Here's how to use the adapter with your Better Auth setup:
Basic Setup
// auth.ts
import { betterAuth } from "better-auth";
import { gelAdapter } from "@carere/gel-better-auth";
import createClient from "gel";
// Create your Gel client
const gelClient = createClient();
// Configure Better Auth with Gel adapter
export const auth = betterAuth({
database: gelAdapter(gelClient, {
// Optional: Specify module name (defaults to "default")
moduleName: "auth",
// Optional: Define indexes for better performance
indexes: {
user: [
"email", // Single field index
"createdAt", // Another single field index
["name", "email"] // Composite index
],
session: [
"token",
["userId", "expiresAt"] // Composite index
]
}
}),
// ... rest of your Better Auth config
});🚀 Roadmap
- Performance benchmarking and optimization
See the open issues for a full list of proposed features (and known issues).
Contributing
Contributions are more than welcome. If you have a suggestion that would make this project better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement".
Don't forget to give the project a star!
Top contributors:
License
Distributed under the MIT License. See LICENSE for more information.
Contact
Kevin Abatan - abatan.k@gmail.com
Project Link: https://github.com/carere/gel-better-auth
Acknowledgments
- Better Auth - The best authentication framework for TypeScript
- Gel - The best Type-Safe & Full-Featured Database