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 VexCollectionConfigusing 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→ fieldrequireddefaultValue→ fielddefaultValueunique/index→ fieldindex(index name:by_<field>_uniqueorby_<field>)references→relationshipfield- System fields get
admin.readOnly: trueandmeta.locked: true - Sensitive fields get
admin.hidden: true
Parameters
Section titled “Parameters”props?
Section titled “props?”— 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.
Returns
Section titled “Returns”A VexAuthAdapter ready for defineConfig({ auth: … }).
Example
Section titled “Example”import { betterAuthAdapter } from "@vexcms/better-auth";import { authOptions } from "~/auth/server";
export default defineConfig({ auth: betterAuthAdapter({ config: authOptions }), collections: [posts],});