# Configuration

> 

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

## Options Reference

<table>
<thead>
  <tr>
    <th>
      Option
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Default
    </th>
    
    <th>
      Description
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        $schema
      </code>
    </td>
    
    <td>
      <code>
        StandardSchemaV1
      </code>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      Your validation schema (required)
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        validateAtBuild
      </code>
    </td>
    
    <td>
      <code>
        boolean
      </code>
    </td>
    
    <td>
      <code>
        true
      </code>
    </td>
    
    <td>
      Validate during dev/build
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        validateAtRuntime
      </code>
    </td>
    
    <td>
      <code>
        boolean
      </code>
    </td>
    
    <td>
      <code>
        false
      </code>
    </td>
    
    <td>
      Validate when server starts
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        onBuildError
      </code>
    </td>
    
    <td>
      <code>
        'throw' | 'warn' | 'ignore'
      </code>
    </td>
    
    <td>
      <code>
        'throw'
      </code>
    </td>
    
    <td>
      Build validation error behavior
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        onRuntimeError
      </code>
    </td>
    
    <td>
      <code>
        'throw' | 'warn' | 'ignore'
      </code>
    </td>
    
    <td>
      <code>
        'throw'
      </code>
    </td>
    
    <td>
      Runtime validation error behavior
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        logSuccess
      </code>
    </td>
    
    <td>
      <code>
        boolean
      </code>
    </td>
    
    <td>
      <code>
        true
      </code>
    </td>
    
    <td>
      Log successful validation
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        logFallback
      </code>
    </td>
    
    <td>
      <code>
        boolean
      </code>
    </td>
    
    <td>
      <code>
        true
      </code>
    </td>
    
    <td>
      Log JSON Schema fallback warnings
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        jsonSchemaTarget
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <code>
        'draft-2020-12'
      </code>
    </td>
    
    <td>
      JSON Schema version for runtime
    </td>
  </tr>
</tbody>
</table>

## Example Configuration

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

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

    // Error handling
    onBuildError: 'throw',    // stop build on error
    onRuntimeError: 'warn',   // log warning, don't crash

    // Logging
    logSuccess: true,
    logFallback: true,

    // 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](https://github.com/cfworker/cfworker/tree/main/packages/json-schema), a lightweight (~8KB) validator that works on all runtimes including edge.
