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.
How the banner works
Section titled “How the banner works”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.tsxloads~/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 failsnext buildinstead, and one that throws only at runtime is caught byglobal-error.tsx. - Admin page —
src/app/(vexcms)/admin/[[...path]]/page.tsxloads~/vex.config.serverafter 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.tsloads~/vex.configthe 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.tsxandglobal-error.tsxshow 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.
What the banner shows
Section titled “What the banner shows”| 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.
Config
Section titled “Config”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 oneviewId. - A field’s
dependsOnnames a field that does not exist. - A
select()withschema.validator: "literal"has no options, or avariant()has no variants or two members that store the same kind of value. admin.livePreview.expiredSessionsis not"allow"or"deny".schema.autoMigrateis 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.
Access
Section titled “Access”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
authCollectionsinvex.config.tsdisagree with the collections the registered auth adapter builds from your auth options. Update thebetterAuthCollections(...)call (or your adapter’s equivalent) so both read the same schema. - The roles field named by
access.userRolesFieldis writable from the client. Declare it withinput: falsein your Better AuthadditionalFields.
See Authentication.
Components
Section titled “Components”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.
Storage
Section titled “Storage”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.
Unexpected
Section titled “Unexpected”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.