---
title: "Configuration"
description: "Every safeRuntimeConfig option with its type and default, the useSafeRuntimeConfig() signature, and the package entry points."
canonical_url: "https://nuxt-safe-runtime-config.onmax.me/reference/configuration"
---
# Configuration

> Every safeRuntimeConfig option with its type and default, the useSafeRuntimeConfig() signature, and the package entry points.

## Options

Options go under `safeRuntimeConfig` in `nuxt.config.ts`. Set `$schema` or `envSchema`, not both. With neither, the module does nothing. The schema is checked while you build and when the server starts; [Validation](https://nuxt-safe-runtime-config.onmax.me/guide/validation) explains what each check sees.

```ts [nuxt.config.ts]
export default defineNuxtConfig({
  modules: ['nuxt-safe-runtime-config'],
  safeRuntimeConfig: {
    $schema: runtimeConfigSchema,
  },
})
```

<table>
<thead>
  <tr>
    <th>
      Option
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Default
    </th>
    
    <th>
      What it does
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        $schema
      </code>
    </td>
    
    <td>
      <code>
        StandardSchemaV1 | string
      </code>
    </td>
    
    <td>
      
    </td>
    
    <td>
      A <a href="https://standardschema.dev/" rel="nofollow">
        Standard Schema
      </a>
      
      , or a path from the project root to a module that default-exports one. Use a path for <a href="https://nuxt-safe-runtime-config.onmax.me/guide/environment-overrides#transform-values-with-a-schema-module">
        transforms and refinements
      </a>
      
      .
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        envSchema
      </code>
    </td>
    
    <td>
      <code>
        string | { file: string, paths?: Record<string, string> }
      </code>
    </td>
    
    <td>
      
    </td>
    
    <td>
      Experimental. An annotated <a href="https://nuxt-safe-runtime-config.onmax.me/guide/env-schema">
        <code>
          .env.example
        </code>
      </a>
      
      , with optional <a href="https://nuxt-safe-runtime-config.onmax.me/guide/env-schema#nested-config">
        nested paths
      </a>
      
      . Checked only when the server starts.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        requireAtBuild
      </code>
    </td>
    
    <td>
      <code>
        boolean
      </code>
    </td>
    
    <td>
      <code>
        false
      </code>
    </td>
    
    <td>
      Fail the build on an <code>
        undefined
      </code>
      
       or <code>
        ''
      </code>
      
       value too, not only on a wrong one. For CI that builds with every production value. See <a href="https://nuxt-safe-runtime-config.onmax.me/guide/validation#require-every-value-at-build">
        Validation
      </a>
      
      .
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        validateAtBuild
      </code>
    </td>
    
    <td>
      <code>
        boolean
      </code>
    </td>
    
    <td>
      
    </td>
    
    <td>
      Deprecated. See <a href="https://nuxt-safe-runtime-config.onmax.me/guide/validation#upgrade-from-validateatbuild-and-validateatruntime">
        the upgrade table
      </a>
      
      .
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        validateAtRuntime
      </code>
    </td>
    
    <td>
      <code>
        boolean
      </code>
    </td>
    
    <td>
      
    </td>
    
    <td>
      Deprecated. The server start check always runs; <code>
        false
      </code>
      
       still turns it off for now.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        onError
      </code>
    </td>
    
    <td>
      <code>
        'throw' | 'warn' | 'ignore'
      </code>
    </td>
    
    <td>
      <code>
        'throw'
      </code>
    </td>
    
    <td>
      What a failed check does. See <a href="https://nuxt-safe-runtime-config.onmax.me/guide/validation#when-a-check-fails">
        When a check fails
      </a>
      
      .
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        jsonSchemaTarget
      </code>
    </td>
    
    <td>
      <code>
        'draft-2020-12' | 'draft-07' | 'openapi-3.0'
      </code>
    </td>
    
    <td>
      <code>
        'draft-2020-12'
      </code>
    </td>
    
    <td>
      The JSON Schema draft requested from your schema library for runtime checks, coercion and types. Change it only if your library can't produce the default.
    </td>
  </tr>
</tbody>
</table>

When a library has no JSON Schema output of its own, the module converts it with [@standard-community/standard-json](https://github.com/standard-community/standard-json). The converters for Valibot and Zod ship with the module, so you don't install them.

On Nuxt 5, `validateAtRuntime: false` or `onError: 'warn' | 'ignore'` keeps your `$schema` under the module's control instead of registering it for Nuxt's mandatory native checks. See [Nuxt 5 validation settings](https://nuxt-safe-runtime-config.onmax.me/guide/nuxt-5#preserve-validation-settings).

## `useSafeRuntimeConfig()`

```ts
function useSafeRuntimeConfig(event?: { context: object }): SafeRuntimeConfig
```

Auto-imported in the app and in `server/`. For explicit imports, use `#imports` in app code and `#safe-runtime-config/server` in server code. Without an event it returns the current runtime config. With an H3 event it returns that request's config, the checked version of `useRuntimeConfig(event)`. The return type comes from `.nuxt/types/safe-runtime-config.d.ts`, described in [Types](https://nuxt-safe-runtime-config.onmax.me/guide/type-safety).

## Entry points

<table>
<thead>
  <tr>
    <th>
      Import
    </th>
    
    <th>
      What it is
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        nuxt-safe-runtime-config
      </code>
    </td>
    
    <td>
      The Nuxt module
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        nuxt-safe-runtime-config/nitro
      </code>
    </td>
    
    <td>
      The <a href="https://nuxt-safe-runtime-config.onmax.me/guide/nitro">
        Nitro module
      </a>
      
      , for Nitro apps without Nuxt
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        nuxt-safe-runtime-config/eslint
      </code>
    </td>
    
    <td>
      The <a href="https://nuxt-safe-runtime-config.onmax.me/guide/eslint">
        ESLint plugin
      </a>
      
       and its <code>
        configs.recommended
      </code>
    </td>
  </tr>
</tbody>
</table>


## Sitemap

See the full [sitemap](https://nuxt-safe-runtime-config.onmax.me/sitemap.md) for all pages.
