---
title: "Deprecating nuxt-safe-runtime-config"
description: "Nuxt 4.7 checks runtimeConfig schemas itself, so nuxt-safe-runtime-config is deprecated. Here are the two ways off the module, each with a codemod."
canonical_url: "https://nuxt-safe-runtime-config.onmax.me/blog/deprecating-nuxt-safe-runtime-config"
---
# Deprecating nuxt-safe-runtime-config

> Nuxt 4.7 checks runtimeConfig schemas itself, so nuxt-safe-runtime-config is deprecated. Here are the two ways off the module, each with a codemod.

I am deprecating `nuxt-safe-runtime-config`. For a good reason, though. With [nuxt/nuxt#36905](https://github.com/nuxt/nuxt/pull/36905), Nuxt 4.7 now does most of its job.

I built `nuxt-safe-runtime-config` to validate `runtimeConfig` with Standard Schema using Zod, Valibot, or ArkType. In Nuxt 4.7, you can pass a schema straight into `runtimeConfig`. Nuxt converts `NUXT_*` environment strings to the types your schema asks for, types `useRuntimeConfig()` from it, and refuses to start with `NUXT_E8014` when a value is missing or has the wrong type.

Keeping a separate module around for something Nuxt already does doesn't make much sense anymore. I am moving `nuxt-safe-runtime-config` into maintenance mode. It will only get security fixes and fixes for severe bugs, with no new features. `0.5.1` is the last release, and on Nuxt 4.7 and later it prints a deprecation warning. The repository and the [migration guide](https://nuxt-safe-runtime-config.onmax.me/) stay online.

There are two ways off the module, and both have a codemod.

## Move to Nuxt 4.7 runtime config

This is the default path. You drop the module, add no new dependency for Zod or ArkType, and keep your schema.

Upgrade to Nuxt 4.7 or later first, plus Zod 4.2+ or ArkType 2.1.28+ if you use them. Nuxt expects a Standard JSON Schema, so older versions like Zod 3 won't work.

Preview the changes first, then apply them:

```bash
npx nuxt-safe-runtime-config@latest migrate --dry-run
npx nuxt-safe-runtime-config@latest migrate
```

Here is a small Zod example from the [migration guide](https://nuxt-safe-runtime-config.onmax.me/). Before:

```ts [nuxt.config.ts]
export default defineNuxtConfig({
  modules: ['nuxt-safe-runtime-config'],
  runtimeConfig: {
    databaseUrl: '',
    public: { apiBase: 'https://api.example.com' },
  },
  safeRuntimeConfig: { $schema: './runtime-config.schema' },
})
```

```ts [runtime-config.schema.ts]
import { z } from 'zod'

export default z.object({
  databaseUrl: z.string(),
  public: z.object({ apiBase: z.string() }),
})
```

After running the codemod:

```ts [nuxt.config.ts]
export default defineNuxtConfig({
  modules: [],
  runtimeConfig: {
    public: { apiBase: 'https://api.example.com' },
  },
})
```

```ts [layers/runtime-config/nuxt.config.ts]
import runtimeConfigSchema from '../../runtime-config.schema.ts'

export default defineNuxtConfig({
  runtimeConfig: runtimeConfigSchema,
})
```

The schema file doesn't change. `runtimeConfig` holds either a schema or plain values, so the schema moves to a layer and `apiBase` stays in `nuxt.config.ts` as its default. `databaseUrl` stays required, so production sets `NUXT_DATABASE_URL` and Nuxt refuses to start without it.

Here is what the codemod does:

- Moves `$schema` into `runtimeConfig` and keeps your schema as written, so checks like `.url()` stay in your code.
- Removes `''` placeholders, because Nuxt would take `''` as the default and the field would stop being required.
- Keeps plain values in `nuxt.config.ts` as defaults and puts the schema in a layer when there are any.
- Wraps Valibot schemas in `toStandardJsonSchema()` and adds `@valibot/to-json-schema`.
- Renames `useSafeRuntimeConfig` to `useRuntimeConfig` (calls inside a Vue `<template>` go in the report instead), removes the `nuxt-safe-runtime-config/eslint` import and the `prefer-safe-runtime-config` rule, and removes the module from `package.json` and `modules`.
- Prints a report of anything you need to check by hand.

There is one big limitation, though. Nuxt only checks types, required values, enums, and unions. It doesn't run URL formats, min/max checks, patterns, `.refine()`, or transforms. If you pass `NUXT_PUBLIC_API_BASE=not-a-url`, the server still starts. The report lists the skipped checks it finds, with their file and line, so you can validate the ones that matter where your code reads the value. Treat it as a starting point: it can miss some, such as a `.refine()` inside `z.lazy()`, so go through the checks your app relies on yourself.

The codemod also stops before editing anything if your app uses something Nuxt doesn't support. That includes transforms, async checks, `envSchema`, and Nitro-only apps using `nuxt-safe-runtime-config/nitro`.

## Switch to ViteHub Env

The other option is [ViteHub Env](https://nuxt-safe-runtime-config.onmax.me/guide/migrate-to-vitehub-env). Instead of checking Nuxt's runtime config, it replaces it.

Run the codemod with `--dry-run` first to see the diff and report, then apply it:

```bash
npx @vite-hub/codemods nuxt-safe-runtime-config --dry-run
npx @vite-hub/codemods nuxt-safe-runtime-config
```

ViteHub Env reads `.env.example` as the schema, so an `envSchema` app can usually keep its file. Not every file works unchanged, though: ViteHub Env rejects sensitive enum values, including enums inside an array, so run the codemod on a branch, install, and start the migrated app before you merge or deploy it. Secrets become `SecretEnv` values that print `<redacted>` until you call `.unseal()`. You get the same API in Nuxt, Vite, and Nitro apps, using `useServerEnv(event)` on the server and `usePublicEnv()` in app code. There is also `vitehub env check`, which lists the declared server variables and whether each is set, without printing values. It doesn't check public ones.

It comes with a few costs, though. ViteHub Env needs Nuxt 5 and Node.js 24.15, and it adds `vite-hub` to your dependencies. Nitro-only apps need Nitro 3 with Vite and have to migrate by hand, because the codemod doesn't cover them. Public values are also fixed at build time. `nuxt-safe-runtime-config` applied `NUXT_PUBLIC_*` overrides when the server started, so here you have to set public variables before the build. Server values are still read when the server runs.

## Which one?

Go with Nuxt 4.7 runtime config unless you need `.env.example` as the schema (and your file works with ViteHub Env), secret handling, or Nitro. Deleting a module and letting Nuxt do the job is the simpler move for most apps.

You can read the full steps and limitations in the [migration guide](https://nuxt-safe-runtime-config.onmax.me/), the [ViteHub Env migration page](https://nuxt-safe-runtime-config.onmax.me/guide/migrate-to-vitehub-env), and [nuxt/nuxt#36905](https://github.com/nuxt/nuxt/pull/36905).


## Sitemap

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