Configuration & API

API reference and configuration options for @arkenv/nuxt.

Register ArkEnv in your Nuxt config

The idiomatic way to configure ArkEnv in Nuxt is by adding the module to your nuxt.config.ts and configuring it under the arkenv config key.

nuxt.config.ts
export default defineNuxtConfig({
	modules: ["@arkenv/nuxt/module"],
	arkenv: {
		/* config options here */
	}
});

By default, ArkEnv looks for your schema in env.ts or src/env.ts for the flat layout, or in the env/ or src/env/ directory for the strict layout.


Configuration options

The arkenv configuration block accepts the following options:

Prop

Type

Specify the path to the schema definition file.

When omitted, ArkEnv auto-discovers the schema, searching for "src/env.ts" or "env.ts" in the project root.

Type

string | undefined

Specify the configuration layout.

When omitted, the layout is auto-detected from the schema structure: it is "strict" when env/client.ts and env/server.ts are present (with optional env/internal/shared.ts), and falls back to "flat" (a single env.ts) otherwise.

  • "flat": A single env.ts schema file.
  • "strict": A split schema layout (env/client.ts, env/server.ts, and optionally env/internal/shared.ts).

Type

"flat" | "strict" | "simple" | undefined

Enable or disable build-time environment variable validation during build/dev startup.

Type

boolean | undefined

Default

true


Validation behavior

When validate: true (default), @arkenv/nuxt evaluates your schema during the Nuxt module setup phase (at both dev startup and build time). If any required environment variables are missing or fail validation constraints, the process will output a descriptive ArkEnvError and immediately abort the build.

This prevents misconfigured applications from ever being deployed to staging or production.

Disabling validation

If you need to skip build-time validation (for example, in a CI environment where build-time secrets are not provided, or when using custom runtime injection), you can set validate: false:

nuxt.config.ts
export default defineNuxtConfig({
	modules: ["@arkenv/nuxt/module"],
	arkenv: {
		validate: false
	}
});

Runtime API

createEnv(schema, options)

A factory function to validate and return your environment config. It automatically connects to Nuxt's dynamic useRuntimeConfig() payload.

Usage (Flat Layout)

env.ts
import  from '@arkenv/nuxt';

export const  = ({
	: "string",
	: "string",
}, {
	: ["NUXT_PUBLIC_API_URL"]
});