Framework Integration
vars works with any framework — wrap your scripts and go.
How it works
Wrap your dev and build scripts with vars run:
{
"scripts": {
"dev": "vars run --env dev -- next dev",
"build": "vars run --env prod -- next build"
}
}vars run decrypts your config, validates schemas, and injects variables into process.env before your framework starts. No plugins, no adapters.
Server vs Client
Server-side (API routes, SSR, Node.js): process.env works directly. Import vars from #vars for type safety.
Client-side (browser bundles): Frameworks don't pass process.env to the browser. Two options:
-
Static generation — bake values into the generated file at build time:
VARS_KEY=$KEY vars gen config.vars --platform static --env dev -
Framework bridge — use your framework's native env passthrough (details in each framework guide below)
Choose your framework
Next.js
Client vars work out of the box via NEXT_PUBLIC_*
Vite / React
Needs static gen or vite.config.ts define bridge for client
SvelteKit
Server routes work, client needs bridge
Astro
Server islands work, client islands need static gen
Remix
Server-only — no client concerns
Express / Hono / Fastify
Pure server, just works
Cloudflare Workers
Use --platform cloudflare for env bindings