JSPM

@carere/gel-better-auth

1.1.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 3
  • Score
    100M100P100Q29607F
  • License MIT

Adapter for Better Auth and Gel/EdgeDB

Package Exports

  • @carere/gel-better-auth

Readme


Gel + Better Auth

Gel Better Auth

Gel adapter for Better Auth
Report Bug · Request Feature

Quality Assurance

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 userId are 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

Installation

  1. 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
  2. Set up your Gel connection

    # Initialize Gel project (if not already done)
    gel project init
  3. Generate the Gel schema

    bunx @better-auth/cli generate
  4. 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:

contrib.rocks image

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