env

The validated env object returned by arkenv().

Edit on GitHub

arkenv() returns a typed object of validated (and coerced) values. Import that object as env and read properties from it in application code.

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

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

.; // string
.; // number

Default source

Without a config object, ArkEnv reads process.env. Override with options.env when the host injects variables another way.

Your framework or process manager must populate the source before arkenv() runs. See Loading .env files.

Return shape

Default arkenv() returns a validated object and throws ArkEnvError on failure. For a result object, import arkenv from @arkenv/core/safe or @arkenv/standard/safe.

CallReturn type
arkenv()Validated object; throws ArkEnvError on failure
arkenv from /safe{ success: true, data } or { success: false, issues }

Core and @arkenv/standard return a plain object. Next.js and Nuxt wrap that object in a Proxy.

Framework proxies

Next.js and Nuxt Proxies throw if client code reads a server-only key, or if code reads a key missing from the schema.

Vite and Bun plugins rewrite the client graph so only public keys are inlined. The app still imports env from your schema module.

See Client vs. server and Error reporting.

Typing helpers

Export Infer when you need the schema's output type without reading typeof env.

./env.ts
import , { type  } from "@arkenv/core";

const  = { : "string" } as ;
export const  = ();
export type  = <typeof >;

Do not augment ambient env types

Do not augment ImportMetaEnv (Vite) or NodeJS.ProcessEnv (Bun) for schema keys — those helpers were dropped in v1. Reading process.env or import.meta.env skips ArkEnv. Import { env } from your schema module.

Next steps