@arkenv/vite-plugin

Exports and transform options for the Vite plugin.

Edit on GitHub

API reference for @arkenv/vite-plugin. Setup recipes: Vite guide.

Installation

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

Or if you use Zod, Valibot, or another Standard Schema validator:

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

Exports

ExportRole
defaultarkenvPlugin plugin factory
named arkenvPluginPlugin factory
named arkenvVitePluginHost-explicit named alias
./standardStandard Schema plugin entry

Transform options

Pass transform options only. A schema argument is rejected.

OptionDefaultMeaning
schemaPathauto (env.ts)Schema module to transform
clientPrefixVite envPrefix (VITE_)Keys exposed to the client
Plus(none)All ArkEnvConfig fields except safe
logger / logLevel(none)Logging

Call arkenvPlugin() with no args, or an options object that includes transform fields (schemaPath, clientPrefix, logging). Do not pass a schema map or compiled type() to the plugin.

Startup validation

When the plugin is registered, it resolves env.ts and validates it during Vite config resolution. Missing or invalid environment variables therefore abort the dev server or production build before Vite is ready. The plugin revalidates the schema when a relevant .env file or schema module changes during HMR.

Without the plugin, validation is import-driven and runs when a module imports env.ts. Startup fail-fast is the documented behavior of the existing plugin contract; there is no default-off lazy-validation flag.

Next steps