@arkenv/standard

ArkType-free environment validation via Standard Schema.

Edit on GitHub

@arkenv/standard is the Standard Schema validation engine. It validates environment variables with any Standard Schema validator (Zod, Valibot, and others). The root import has no runtime dependencies or peers.

  • If you use ArkType, use @arkenv/core. It also supports Zod and Valibot. You do not need to install both engines.
  • If you don't use ArkType, use @arkenv/standard. This will keep your tree free of the arktype dependency.

TypeScript must use moduleResolution: "bundler" | "node16" | "nodenext".

Installation

npm install @arkenv/standard
pnpm add @arkenv/standard
yarn add @arkenv/standard
bun install @arkenv/standard

Usage

./env.ts
import  from "@arkenv/standard";
import * as  from "zod";

export const  = ({
  : .().(0).(65535).(3000),
  : .(),
  : .(["development", "production", "test"]).("development"),
});

Compared to @arkenv/core

Both engines share arkenv() options, errors, and framework plugins. They differ in schema style and peers.

@arkenv/core@arkenv/standard
ValidatorArkType DSL + type()Standard Schema map only
Keywords (string.host, number.port)YesNo
Peer arktypeRequiredNone
OptionsArkEnvConfigStandardEnvConfig (ArkEnvConfig plus toJsonSchema)
CoercionBuilt-in for ArkType shapesStandard JSON Schema on the value, or @arkenv/standard/valibot / /zod-mini / toJsonSchema

Exports

These are the public names from @arkenv/standard.

ExportKindRole
arkenvfunction (default + named)Validate a Standard Schema field map
ArkEnvErrorclassThrown on validation failure
formatIssuesfunctionFormat issues
getSchemaKeysfunctionList schema keys
Config / issue typestypesStandardEnvConfig extends core options with toJsonSchema

Subpaths

ImportRole
@arkenv/standardRoot engine (throw path). Dependency-free. Zod works zero-config.
@arkenv/standard/safearkenv — result object instead of a throw (default + named export)
@arkenv/standard/valibotSame arkenv, pre-configured for Valibot. valibot + @valibot/to-json-schema are required.
@arkenv/standard/zod-miniSame arkenv, pre-configured for Zod Mini. zod is required.
./env.ts
import  from "@arkenv/standard/safe";
import * as  from "zod";

const  = (
  { : ..() },
  { : { : "invalid" } },
);

if (!.) {
  .(.);
}
./env.ts
import {  } from "@arkenv/standard/valibot";
import * as  from "valibot";

export const  = ({
  : .(.(), 3000),
});

Framework /standard subpaths

Next.js, Nuxt, Vite, and Bun ship /standard (and related) entries that pair with this package. See each package reference for import paths.

Next steps