schema
Schema shapes accepted by arkenv() in core and standard modes.
arkenv() accepts a schema that maps environment variable names to
validators. Core uses the ArkType DSL (and compiled type() values).
Standard mode accepts a map of Standard Schema validators.
Declarative map
Pass a map of ArkType strings (or nested objects). This is an
EnvSchema: each value is validated against ArkEnv's ArkType scope
before parsing.
import from "@arkenv/core";
export const = ({
: "'development' | 'production' | 'test' = 'development'",
: "string.host = 'localhost'",
: "number.port = 3000",
: "string",
});Compiled type()
Build the schema once with type() when you reuse it across runtimes or
packages.
import , { } from "@arkenv/core";
export const = ({
: "number.port = 3000",
: "string",
});
export const = ();See Reusing schemas.
Standard Schema maps
With @arkenv/standard, every value must be
a Standard Schema validator (Zod, Valibot, and others). ArkType DSL
strings fail.
import from "@arkenv/standard";
import * as from "zod";
export const = ({
: .().(0).(65535),
: .(),
});Inferring types
Infer<T> works for declarative maps, compiled ArkType types, and
Standard Schema values.
import , { type } from "@arkenv/core";
const = {
: "string",
: "number.port = 3000",
} as ;
export const = ();
export type = <typeof >;Client and server schemas
Framework packages enforce public prefixes on a flat schema:
- Flat: one schema; public prefixes decide client exposure
- Optional recipe: two modules with
extendswhen names must stay off the client type graph
Details:
Client vs. server,
@arkenv/nextjs,
@arkenv/nuxt.