Skip to content

Config errors

VexCMS checks your config while vex.config.ts and vex.config.server.ts load. When a check fails, the admin panel shows a banner explaining it instead of a crashed page. The banner links here, to the section for its category.

defineConfig, defineServerConfig, defineCollection, defineAccess and the field builders throw while their module evaluates, before React renders anything. A static import config from "~/vex.config" would take the route down with no error boundary able to catch it. The scaffolded app loads both configs through loadVexConfigModule from @vexcms/core instead:

import { loadVexConfigModule } from "@vexcms/core"
import { VexConfigErrorBanner } from "@vexcms/react"
const clientConfig = await loadVexConfigModule({ load: () => import("~/vex.config") })
if (clientConfig.status === "invalid") {
return <VexConfigErrorBanner error={clientConfig.error} />
}
// clientConfig.config is the resolved config
  • Root layout — in development, src/app/layout.tsx loads ~/vex.config. If it fails, the whole app renders the banner, because the client providers cannot mount without a config. The check is stripped from production builds: importing the config there would ship every client component it reaches, the rich-text editor included, to every public page. A config that always throws fails next build instead, and one that throws only at runtime is caught by global-error.tsx.
  • Admin page — src/app/(vexcms)/admin/[[...path]]/page.tsx loads ~/vex.config.server after the sign-in gate, so a server-only failure shows the banner inside the admin panel, and only to people allowed into it.
  • Proxy — src/proxy.ts loads ~/vex.config the same way. In production a middleware module that throws while loading fails every request, including /admin, before any page renders; loading it inside the handler keeps requests reaching the banner.
  • Error files — admin/error.tsx and global-error.tsx show the banner for a config error that is thrown somewhere else, such as in the browser only.

The banner is rendered on the server, so it is in the first HTML response.

Environment Shows
Development (NODE_ENV=development) The error class, its full message, and a link to this page
Production The category, a link to this page, and the framework digest when there is one

In production the message is never sent to the browser, because it can contain slugs and config values. loadVexConfigModule logs the full error with console.error on the server, so look in your server logs for it. To change what is shown, pass includeDetail to loadVexConfigModule.

VexConfigError — a collection, field, global or defineConfig option is invalid. Common causes:

  • A saved list view (admin.view/admin.views) names a field, column or index the collection does not have, or two views share one viewId.
  • A field’s dependsOn names a field that does not exist.
  • A select() with schema.validator: "literal" has no options, or a variant() has no variants or two members that store the same kind of value.
  • admin.livePreview.expiredSessions is not "allow" or "deny".
  • schema.autoMigrate is set. It is not implemented yet; remove it.

The message names the collection, view or field that failed. Fix the option it names.

Some field builders still throw a plain Error (for example number() with min greater than max); those show under Unexpected.

VexAccessConfigError — the access rules reference a collection, field or index that does not exist, often after a rename. Update the rule, or the resource it points at. See Access control.

VexAuthConfigError — thrown by defineServerConfig when:

  • The authCollections in vex.config.ts disagree with the collections the registered auth adapter builds from your auth options. Update the betterAuthCollections(...) call (or your adapter’s equivalent) so both read the same schema.
  • The roles field named by access.userRolesField is writable from the client. Declare it with input: false in your Better Auth additionalFields.

See Authentication.

VexComponentConfigError — an admin.components override or contribution is invalid, usually two entries with the same id in one slot. To replace a built-in, hide it with { id, hidden: true } and add yours under a new id. See Admin customization.

VexStorageConfigError — a media collection names a storage adapter that is not registered in defineServerConfig({ server: { storage: { adapters } } }), an upload() field points at a media collection that does not exist, or a media collection’s slug collides with a regular collection’s. Register the adapter, or fix the slug. See Custom storage adapter.

Something other than a VexCMS config check threw while the config module was loading: a typo, an import that resolves to undefined, or an environment variable read at module load. In development the banner shows the error; in production, check the server logs.