Better Auth integration
@hedystia/better-auth connects Better Auth's adapter API to Hedystia DB. It also generates Hedystia DB schemas and migrations from Better Auth model definitions.
npm install @hedystia/better-auth @hedystia/db better-authConfigure Better Auth with an initialized database:
import { betterAuth } from "better-auth";
import { hedystiaAdapter } from "@hedystia/better-auth";
import { db } from "./database";
export const auth = betterAuth({
database: hedystiaAdapter(db, {
outputDir: "./hedystia-db",
}),
});Create and initialize db using the database setup guide, and apply the generated schemas and migrations for the configured authentication models before serving requests. Use the migration guide to review and apply changes.
Pagination and errors
Adapter findMany calls honor limit: 0, which returns no rows. Limits and offsets must be non-negative safe integers. Negative values, fractions, infinity, NaN and values above JavaScript's safe integer range are rejected before SQL execution. A positive limit with an offset selects the requested page; supply a stable sortBy when paging through a list.
Database query errors propagate to Better Auth instead of being converted into an empty result. Applications should handle an unavailable database as a failure, rather than treating an outage as proof that an account or session does not exist.
Generated output
outputDir defaults to ./hedystia-db. Optional schemasDir and migrationsDir override the individual generated directories. Review generated migrations before applying them to production. Storage drivers differ in transactions and concurrency guarantees; use the guarantees of your selected driver rather than assuming all backends behave identically.
