Introduction
Welcome to the ArkEnv documentation!
What is ArkEnv?
ArkEnv is a typesafe environment variable validation library for TypeScript. You declare a schema once, arkenv() validates the
process against that schema before application code runs, and TypeScript
infers the types from the same declaration.
This page shows why process.env is a weak contract, how ArkEnv's typed
env object replaces it, and where to go next in these docs.
The process.env problem
Environment variables arrive as process.env (or import.meta.env), where all values are string | undefined. Most teams start with a presence-check helper that verifies required keys:
PORT=3000
DEBUG=falseexport function () {
const = process..;
const = process..;
if ( === || === ) {
throw new Error("Missing required environment variables");
}
return { , };
}For presence-only strings, this helper installs nothing and gets the job done. But it breaks when variables need types and coercion:
- Booleans (
DEBUG=false):process.env.DEBUGis the string"false". The presence check passes and returns{ debug: "false" }. Because non-empty strings are truthy in JavaScript,if (debug)runs even when set tofalse. - Numbers (
PORT=3000):portremains astring. Arithmetic likeport + 1evaluates to"30001", and comparisons likeport > 1024perform lexicographical checks rather than numeric ones.
ArkEnv replaces manual presence checks and ad-hoc parsing with declarative schema validation and zero-config coercion.
The env solution
ArkEnv solves the environment variable scaling problem. Declare a
schema in env.ts; arkenv() validates against it so application code never
touches loose process.env:
import from "@arkenv/core";
export const = ({
PORT: "number.port = 3000",
DEBUG: "boolean = false",
});The same if as above, after ArkEnv:
import { } from "./env";
const = .PORT;
const debug = .DEBUG;
if () {
console.log("verbose logging enabled");
}
console.log(`listening on ${}`);Everything works like our manual solution, but the parsing logic is written declaratively in a single file. This makes the code simpler and more maintainable.
In a full-stack app, we must keep secrets off the client. The Next.js, Nuxt, Vite, and Bun packages enforce that split. See Client vs. server.
ArkType, Zod, and Valibot are first-class. Use
@arkenv/core for ArkType, or
@arkenv/standard for Zod and Valibot (and any other
Standard Schema validator). See the
Zod and Valibot
guides.
How to use these docs
Start with Getting started to add ArkEnv to a
new or existing project. Core concepts covers the
schema, the typed env object, engines, and coercion. Some other useful
reads:
Why ArkEnv?
How ArkEnv stacks up against Varlock, T3 Env, znv, Envalid, and a DIY schema.
Core concepts
Design a schema, parse values, and keep secrets off the client.
Frameworks
Next.js, Nuxt, Vite, and Bun integrations.
Validators
ArkType, Zod, and Valibot cookbooks.
Guides
AI assistants and migrating from T3 Env or v0.
API reference
Options, CLI commands, and package APIs.
If you're a human, the search bar at the top will help you find your way around.
If you happen to be an AI agent, see /llms.txt for an index of all available documentation, or /llms-full.txt for the full concatenated docs.
See the Using AI with ArkEnv guide to learn how to use AI tools to improve your development workflow.
Join the community
If you have questions about ArkEnv, ask on GitHub Discussions or X.