Frameworks
Validate environment variables in Next.js, Nuxt, Vite, TanStack Start, and Bun with ArkEnv.
ArkEnv works in any JavaScript or TypeScript project. When you build full-stack applications, client bundles must never receive server secrets. The framework packages below enforce that boundary during development and production builds.
Choose your framework to get started:
Next.js
@arkenv/nextjs, withArkEnv, and build-time validation.
Nuxt
@arkenv/nuxt module, runtime config, and NUXT_PUBLIC_ keys.
Vite
@arkenv/vite-plugin transform mode and VITE_ keys.
TanStack Start
@arkenv/vite-plugin / @arkenv/rsbuild-plugin with tanstackStart() and createServerFn.
Bun fullstack dev server
@arkenv/bun-plugin for Bun bundler and fullstack apps.
Vanilla
Use ArkEnv in a plain Node.js or Bun project.
How hosts enforce the boundary
Frameworks use compile-time AST transforms or host runtime adapters:
| Framework | Integration strategy | Client bundle output | SSR and server validation | Public env without rebuild (Docker) |
|---|---|---|---|---|
| Next.js | Host adapter + codegen (@arkenv/nextjs) | Generated runtime proxy | Process boot (process.env) | Requires rebuild for NEXT_PUBLIC_* |
| Nuxt | Nitro plugin (@arkenv/nuxt) | Dynamic runtimeConfig hydration | Nitro server boot gate | Yes (via Nitro runtimeConfig) |
| Vite | AST build transform (@arkenv/vite-plugin) | Inlined public literals + throwing stubs | Full @arkenv/core at server boot | Requires rebuild for VITE_* |
| TanStack Start | AST build transform (@arkenv/vite-plugin / @arkenv/rsbuild-plugin) | Inlined public literals + throwing stubs | Full @arkenv/core at server boot | Requires rebuild for VITE_* / PUBLIC_* |
| Bun | Bundler AST transform (@arkenv/bun-plugin) | Inlined public literals + throwing stubs | Full @arkenv/core at server boot | Requires rebuild for BUN_PUBLIC_* |
Vite, TanStack Start, and Bun evaluate two module graphs in full-stack and
SSR apps.
Application code imports @arkenv/core (or @arkenv/standard); the
plugin rewrites the client graph so public keys inline and server
secrets become throwing stubs. Next.js and Nuxt use host adapters
(@arkenv/nextjs, @arkenv/nuxt) with dedicated entrypoints and
codegen or runtimeConfig hydration.
ArkEnv keeps the validation engine (@arkenv/core /
@arkenv/standard) as an optional peer of each host adapter. You
install the engine you use; the adapter does not bundle either runtime.
That keeps host packages lean and lets you pair any adapter with ArkType
or a Standard Schema validator.
Loading .env files
ArkEnv does not read .env files. Something else must load them before
arkenv() runs.
Next.js, Nuxt, Vite, and Bun already load .env* files. On plain Node
(20.6+), use the built-in --env-file flag:
node --env-file=.env dist/index.jsFor TypeScript in development, pass the same flag to your usual runner:
tsx --env-file=.env src/index.tsFor NestJS applications, @nestjs/cli 11+ supports
nest start --env-file .env — follow the
Use with NestJS guide.
After values are in process.env (or a custom record), arkenv()
validates them.