Installation

Install ArkEnv with the CLI or by hand in a new or existing project.

Edit on GitHub

Prerequisites

ArkEnv is designed to drop into a new or existing TypeScript app. ArkEnv provides an interactive CLI that detects your stack, writes a schema, and wires framework config.

npx arkenv init
pnpm dlx arkenv init
yarn dlx arkenv init
bunx arkenv init

Omit a project name to mutate the current directory. Pass a name to create a new folder (optionally from --example):

npx arkenv init my-app --example with-vite-react -H vercel
pnpm dlx arkenv init my-app --example with-vite-react -H vercel
yarn dlx arkenv init my-app --example with-vite-react -H vercel
bunx arkenv init my-app --example with-vite-react -H vercel

For agent sessions, use --agent (implies --yes --quiet --json):

npx arkenv init --agent
pnpm dlx arkenv init --agent
yarn dlx arkenv init --agent
bunx arkenv init --agent

Install the runtime validation engine as a dependency, and the arkenv CLI as a devDependency:

npm install @arkenv/core
npm install -D arkenv
pnpm add @arkenv/core
pnpm add -D arkenv
yarn add @arkenv/core
yarn add --dev arkenv
bun install @arkenv/core
bun install --dev arkenv

If you are using Standard Schema (Zod or Valibot):

npm install @arkenv/standard
npm install -D arkenv
pnpm add @arkenv/standard
pnpm add -D arkenv
yarn add @arkenv/standard
yarn add --dev arkenv
bun install @arkenv/standard
bun install --dev arkenv

Why install locally?

  • Deterministic versioning: Locks the exact CLI version in package-lock.json or pnpm-lock.yaml, ensuring absolute consistency across team members and CI pipelines.
  • Zero latency & offline execution: Executions run instantly from node_modules/.bin/arkenv without querying npm, working completely offline.
  • CI/CD reliability: Pipelines execute the version frozen in the lockfile instead of dynamically resolving @latest.

Once installed locally, running npx arkenv <command> (or pnpm arkenv, bun arkenv) inside your project automatically executes your locked local binary from node_modules/.bin.

Wire into package.json scripts

Add arkenv check to your project scripts to validate environment variables before builds:

package.json
{
  "scripts": {
    "build": "arkenv check && next build",
    "env:check": "arkenv check"
  }
}

Flags, output files, and refusal codes live in init reference.

Add to an existing repository

When the CLI finds a package.json, it adopts the repo incrementally.

Run the interactive CLI

npx arkenv init
pnpm dlx arkenv init
yarn dlx arkenv init
bunx arkenv init

The CLI refuses a dirty git working tree. Commit or stash (git stash -u) first, or pass --force if you accept overwriting generated files.

The CLI never reads your actual .env files. Suggested schema key names come from .env.example if you have one, otherwise from process.env / import.meta.env usage in source.

Answer the wizard

The CLI asks about framework, layout, validator, and hosting preset. If compilerOptions.strict is off in tsconfig.json, the wizard offers to enable it (recommended).

Review generated files

After the CLI, a Next.js app (for example) looks like this:

env.ts
.env.example
.env
page.tsx
next.config.ts

If the project has a src/ directory, the schema lands at src/env.ts instead.

Import env in your app

If you don't have a .env file yet, copy the example and fill in values:

Terminal
cp .env.example .env

Import env instead of process.env (or import.meta.env):

./app/page.tsx
import {  } from "../env";

.(.);

Manual installation

Prefer a hands-on setup? Install the validation engine yourself, then add a framework package from the framework guides.

Validation engine

@arkenv/core is the ArkType-powered engine. arktype is a required peer.

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

If you aren't using ArkType, install @arkenv/standard:

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

TypeScript module resolution

@arkenv/standard subpath exports (/valibot, /zod-mini) and the framework plugin subpaths require modern TypeScript module resolution. Set compilerOptions.moduleResolution to "bundler", "node16", or "nodenext". Legacy "node" resolution is not supported.

Next steps