0.1.5 • Published 9 months ago

@nerdfolio/remult-better-auth v0.1.5

Weekly downloads
-
License
ISC
Repository
github
Last release
9 months ago

remult-better-auth

Adapter to use better-auth with remult ORM

Installation

pnpm i @nerdfolio/remult-better-auth

Generate Schema

This package comes with a single-command CLI to generate the relevant better-auth schema as remult entities: User, Account, Session, Verification. After the installation, run:

pnpm @nerdfolio/remult-better-auth generate [output-file]

If output-file is not provided, the default value is ./auth-schema.ts.

Here is a generated schema example

Usage

Follow the Remult setup to define the api for your particular web framework. For example, in SolidStart, it would be something like

// src/api.ts

export const api = remultApi({
	entities: [...],
	getUser,
	...
})

Then use the getRemult() method of that api to obtain the remult object and pass that to @nerdfolio/remult-better-auth. You'll need to import the entity schema generated above.

import { betterAuth } from "better-auth"
import { api } from "~/api"
import {User, Account, Session, Verification} from "./src/auth-schema"


return betterAuth({
	database: remultAdapter(api.getRemult(), { authEntities: {User, Account, Session, Verification}}),
	...anyOtherBetterAuthOptions
})

The alternative to using api.getRemult() is instantiating your own new Remult(...) instance and setup appropriate data providers so that the adapter can map better-auth requests to the appropriate entity repositories. You'll probably choose this for the scripting scenario outside of web frameworks.

0.1.5

9 months ago

0.1.4

9 months ago

0.1.1

10 months ago

0.1.0

10 months ago