Skip to content

betterAuthAdapter

betterAuthAdapter(props?): VexAuthAdapter

Defined in: packages/better-auth/src/adapter.ts:96

Creates a Vex auth adapter from a Better Auth configuration.

Introspects Better Auth’s full merged schema (base fields + plugin fields

  • additionalFields) via getAuthTables() and converts each table into a standard Vex CollectionConfig using Vex field builders.

Mappings from Better Auth DBFieldAttribute to Vex fields:

  • type → Vex field type (string→text, boolean→checkbox, number→number, date/timestamp→date, json→text fallback, array→select)
  • required → field required
  • defaultValue → field defaultValue
  • unique/index → field index (index name: by_<field>_unique or by_<field>)
  • referencesrelationship field
  • System fields get admin.readOnly: true and meta.locked: true
  • Sensitive fields get admin.hidden: true

BetterAuthAdapterOptions

— Adapter options; pass your Better Auth config object wrapped in { config: authOptions }. Optional — when omitted, uses default Better Auth tables with no plugins or additional fields.

VexAuthAdapter

A VexAuthAdapter ready for defineConfig({ auth: … }).

import { betterAuthAdapter } from "@vexcms/better-auth";
import { authOptions } from "~/auth/server";
export default defineConfig({
auth: betterAuthAdapter({ config: authOptions }),
collections: [posts],
});