@arkenv/core

ArkType-powered environment validation for TypeScript projects.

Edit on GitHub

@arkenv/core is the ArkType validation engine. It exports arkenv() and a type() function which includes all of ArkType's keywords and additional ones. arktype is a required peer. There are no runtime dependencies.

  • 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.

Installation

npm install @arkenv/core arktype
pnpm add @arkenv/core arktype
yarn add @arkenv/core arktype
bun install @arkenv/core arktype

Usage

./env.ts
import  from "@arkenv/core";

export const  = ({
  : "string.host = 'localhost'",
  : "number.port = 3000",
  : "string",
});

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 and return a typed env object
typefunctionArkType type with keywords
ArkEnvErrorclassThrown on validation failure
ArkEnvConfigtypeOptions object
EnvSchematypeDeclarative schema map
InfertypeInfer output from a schema
SafeArkEnvResulttypeResult shape returned by @arkenv/core/safe

Subpaths

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

ImportRole
@arkenv/coreThrow-path arkenv() and type()
@arkenv/core/issuesformatIssues, getSchemaKeys, and EnvIssue / EnvIssueCode / EnvIssueMeta
@arkenv/core/safearkenv — result object instead of a throw (default + named export)
./env.ts
import  from "@arkenv/core/safe";

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

if (!.) {
  .(.);
}

Next steps