@arkenv/standard

ArkType-free environment validation via Standard Schema.

Edit on GitHub

@arkenv/standard is the ArkType-free validation engine. First-class support is Zod and Valibot. It consumes Standard Schema validators. Libraries that only implement the validate hook may still need a toJsonSchema helper or a dedicated subpath (for example @arkenv/standard/valibot). The root import has no runtime dependencies or peers.

Already on ArkType?

Use @arkenv/core instead. ArkType strings belong on that engine, not wrapped through this one.

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

Installation

Install the engine next to Zod or Valibot. It does not pull in arktype.

npm 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

The main entry is the throw-path runtime. Issue helpers and the non-throwing parser live on subpaths so the default import stays small.

ExportKindRole
arkenvfunction (default + named)Validate a Standard Schema field map
ArkEnvErrorclassThrown on validation failure
SafeArkEnvResulttypeResult shape returned by @arkenv/standard/safe
StandardEnvConfigtypeExtends core options with toJsonSchema

Subpaths

Issue formatting and the non-throwing parser are separate entries.

ImportRole
@arkenv/standardRoot engine (throw path). Dependency-free. Zod works zero-config.
@arkenv/standard/issuesformatIssues, getSchemaKeys, and EnvIssue / EnvIssueCode / EnvIssueMeta
@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  = (
  { : ..() },
  { : { PORT: "invalid" } },
);

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

export const  = ({
  PORT: .optional(.number(), 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