Getting Started

Configuration

All options for safeRuntimeConfig in your nuxt.config.ts.

All options for safeRuntimeConfig in your nuxt.config.ts.

Options Reference

OptionTypeDefaultDescription
$schemaStandardSchemaV1-Your validation schema (required)
validateAtBuildbooleantrueValidate during dev/build
validateAtRuntimebooleanfalseValidate when server starts
onError'throw' | 'warn' | 'ignore''throw'Validation error behavior
jsonSchemaTargetstring'draft-2020-12'JSON Schema version for runtime

Example Configuration

nuxt.config.ts
export default defineNuxtConfig({
  safeRuntimeConfig: {
    $schema: runtimeConfigSchema,

    // Validation timing
    validateAtBuild: true, // default
    validateAtRuntime: false, // opt-in

    // Error handling
    onError: 'throw', // 'throw' | 'warn' | 'ignore'

    // JSON Schema
    jsonSchemaTarget: 'draft-2020-12',
  },
})

Error Behaviors

'throw' (default)

Stops the build or throws an error at runtime. Recommended for catching issues early.

'warn'

Logs a warning but continues. Useful during migration or when some values are expected to be missing in development.

'ignore'

Silently continues. Use sparingly.

JSON Schema Target

The jsonSchemaTarget option controls which JSON Schema draft to use for runtime validation. Options:

  • 'draft-2020-12' (default) - latest, best compatibility
  • 'draft-2019-09' - if your tools require it
  • 'draft-07' - legacy support

Runtime validation uses @cfworker/json-schema, a lightweight (~8KB) validator that works on all runtimes including edge.

When a schema library does not expose native JSON Schema output, the module falls back to @standard-community/standard-json. Valibot and Zod converter dependencies are bundled with the module package, so application projects do not need extra installs for those libraries.

Copyright © 2026