NUXT_B5031
A runtime config schema cannot be converted to JSON Schema.
B5031
Nuxt reads the type and default value of a runtime config schema from its Standard JSON Schema when the configuration is loaded. The schema itself is not included in your server bundle.
This error is reported when a schema does not implement Standard JSON Schema, or when the schema library cannot convert it (for example a schema that uses transforms). A schema for the whole of runtimeConfig must also describe a single object rather than a union.
Resolution
Use a schema library that implements Standard JSON Schema, such as Zod or ArkType. Wrap a Valibot schema in toStandardJsonSchema():
nuxt.config.ts
import * as v from 'valibot'
import { toStandardJsonSchema } from '@valibot/to-json-schema'
export default defineNuxtConfig({
runtimeConfig: {
apiSecret: toStandardJsonSchema(v.string()),
},
})Remove transforms from runtime config schemas, and convert the value where you read it instead:
nuxt.config.ts
import { z } from 'zod'
export default defineNuxtConfig({
runtimeConfig: {
allowedHosts: z.string().transform(value => value.split(',')), // [!code --]
allowedHosts: z.array(z.string()).default([]), // [!code ++]
},
})