Skip to content

sanitizeConfigForClient

sanitizeConfigForClient(config): object

Defined in: packages/core/src/config/sanitizeConfig.ts:134

Strips all non-serializable values from a VexConfig for safe passage across RSC / JSON serialization boundaries (e.g. server layout → client component).

Uses stripNonSerializable to recursively walk the entire config tree, replacing functions, React components, class instances, and symbols with null. Adding a new non-serializable property anywhere in the config is handled automatically — no manual additions needed here.

The access config is always omitted from the client version — it is never needed client-side and contains permission functions that cannot be serialized.

VexConfig

The fully resolved server-side VexCMS config.

A deeply sanitized copy safe to pass to client components.

admin: object

Resolved admin panel configuration — always fully populated after defaults are applied.

sidebar: object

Navigation sidebar configuration — always present after defaults are applied.

collapsible: "none" | "offcanvas" | "icon"

How the sidebar in the admin panel collapses

side: "left" | "right"

Which side of the viewport the admin sidebar is anchored to.

optional auth?: object

Auth adapter registered with this config. Auth collections are merged with user-defined collections — protected collections and locked fields are preserved during merge.

readonly collections: object[]

Auth collections to register alongside user-defined collections.

These are merged into VexConfig.collections automatically by defineConfig(). Each collection uses standard Vex field builders (text(), relationship(), etc.) and may carry admin.readOnly defaults on system fields.

readonly name: string

Provider identifier for debugging and telemetry.

readonly userCollection: string

The slug of the collection that stores user documents.

Used by the admin panel to resolve user references and by auth-aware components to look up the current user collection.

basePath: string

URL prefix for all admin panel routes — always set after defaults are applied.

collections: object[]

All registered content collections — always an array after defaults are applied.

globals: object[]

Resolved global configs. Always present; defaults to [].

mediaCollections: object[]

Media collections — processed by storage adapters and stored separately from user-defined collections. These appear in the admin panel under a dedicated “Media” section. Each collection is tagged with meta.storageAdapterName indicating which adapter owns it.

schema: object

Resolved schema generation configuration — always fully populated after defaults are applied.

outputPath: string

Path where vex.schema.ts is written. Always set after defaults are applied.

optional storage?: object

Storage adapters registered with this config. Processed media collections from all adapters are available via mediaCollections.

adapters: object[]

Storage adapters configured for the project.

types: object

outputPath: string

Path where vex.types.ts is written. Always set after defaults are applied.

// In a Next.js server component (e.g. AdminLayout):
import vexConfig from "~/convex/vex.config";
import { sanitizeConfigForClient } from "@vexcms/core";
const clientConfig = sanitizeConfigForClient(vexConfig);
return <AdminShell config={clientConfig} />;
  • ClientVexConfig for the sanitized type
  • stripNonSerializable for the recursive sanitizer