Vercel
One VARS_KEY, runtime decrypt on Vercel Functions and Edge.
Setup
vars gen config.vars --platform serverlessCiphertexts for every env are embedded in the generated module. getVars(env) decrypts at runtime using Web Crypto and memoizes per-invocation isolate.
Usage
// app/api/health/route.ts
import { getVars } from '#vars'
export async function GET() {
const vars = await getVars(process.env)
return Response.json({
app: vars.APP_NAME,
db: vars.DATABASE_URL.unwrap(),
})
}Works identically for Edge Functions, Serverless Functions, Middleware, and Server Components.
Secrets
In the Vercel dashboard:
- Project → Settings → Environment Variables
- Add
VARS_KEY(Sensitive) with the output ofvars key export. - Add
VARS_ENV(plaintext) with the env name — e.g.prodfor Production,devfor Preview/Development.
That's it. Only two entries per environment, no per-secret configuration.
Local dev
{
"scripts": {
"dev": "vars run --env dev -- next dev"
}
}vars run exports VARS_KEY + VARS_ENV into process.env for your dev server.