varsvars

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:

  1. Static generation — bake values into the generated file at build time:

    VARS_KEY=$KEY vars gen config.vars --platform static --env dev
  2. Framework bridge — use your framework's native env passthrough (details in each framework guide below)

Choose your framework