Skip to content

defineConfig

defineConfig(config?): VexClientConfig

Defined in: packages/core/src/config/config.ts:77

Resolves a raw client config input into a fully-populated VexClientConfig.

Applies defaults for any omitted properties — an absent collections array is replaced with an empty array so downstream consumers can always iterate without null-checking. Pure: same input always produces a deep-equal (not reference-equal) output, so evaluating this module twice in one bundle graph (server + browser) is safe.

authCollections — built by the project’s auth package’s client-safe builder (e.g. betterAuthCollections() from @vexcms/better-auth/client), or omitted entirely for a project with no auth — are merged with user-defined collections via mergeAuthCollections, then internalCollections are appended. Protected auth collections cannot be overridden, and locked fields are preserved.

Also validates config.access against the resolved resources (collections, media collections, globals) — auth collections are already merged in by the time this runs, so access rules may target them.

VexClientConfigInput

The raw client configuration supplied by the caller.

VexClientConfig

The resolved VexClientConfig with all defaults applied.

// Basic config with user-defined collections only
defineConfig({
collections: [
defineCollection({ slug: "posts", fields: { title: text() } }),
],
});
// Config with auth collections built from a client-safe schema module
import { betterAuthCollections } from "@vexcms/better-auth/client";
import { authSchema } from "./auth/schema";
defineConfig({
authCollections: betterAuthCollections(authSchema),
collections: [posts, authors],
});

When an upload() field references a media collection slug not present in mediaCollections, or a media collection slug collides with a regular collection slug.

When config.access references an unknown resource, field, or index.

Error when schema.autoMigrate is true — automatic migration is not implemented, and enabling it would silently migrate nothing.