@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() that includes ArkType's keywords and ArkEnv's. arktype is a required peer. There are no runtime dependencies.

Writing Zod or Valibot?

Use @arkenv/standard instead. That keeps arktype out of the tree.

Installation

Install the engine and its peer. The peer is required.

npm install @arkenv/core arktype

Usage

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

export const  = ({
  HOST: "string.host = 'localhost'",
  PORT: "number.port = 3000",
  DATABASE_URL: "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  = (
  { PORT: "number.port" },
  { : { PORT: "invalid" } },
);

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

Next steps