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.
Parameters
Section titled “Parameters”config?
Section titled “config?”The raw client configuration supplied by the caller.
Returns
Section titled “Returns”The resolved VexClientConfig with all defaults applied.
Examples
Section titled “Examples”// Basic config with user-defined collections onlydefineConfig({ collections: [ defineCollection({ slug: "posts", fields: { title: text() } }), ],});// Config with auth collections built from a client-safe schema moduleimport { betterAuthCollections } from "@vexcms/better-auth/client";
import { authSchema } from "./auth/schema";
defineConfig({ authCollections: betterAuthCollections(authSchema), collections: [posts, authors],});Throws
Section titled “Throws”When an upload() field references a media
collection slug not present in mediaCollections, or a media collection
slug collides with a regular collection slug.
Throws
Section titled “Throws”When config.access references an unknown
resource, field, or index.
Throws
Section titled “Throws”Error when schema.autoMigrate is true — automatic migration is not
implemented, and enabling it would silently migrate nothing.
- VexClientConfigInput for the user-facing input type
- VexClientConfig for the resolved return type
- mergeAuthCollections for auth collection merge logic
- defineServerConfig for the server layer built on top of this result