Usage Examples
Netlify
Set a single bootstrap variable (ENVVAULT_TOKEN) on Netlify, and let envv run fetch everything else at build time. The same token also works in Netlify Functions for runtime SDK reads.
Build Command
# netlify.toml
[build]
command = "envv run -e production -- npm run build"
publish = "dist"
[build.environment]
NODE_VERSION = "20"In the Netlify dashboard, set ENVVAULT_TOKEN and (optionally) ENVVAULT_PROJECT as build-time environment variables.
Generate .env at Build
# netlify.toml
[build]
command = "envv generate --type=env -e production > .env.production && npm run build"
publish = "dist"Use this when your framework reads .env.production directly (Vite, Next.js, SvelteKit).
Netlify Functions Runtime
// netlify/functions/checkout.ts
import { EnvVault } from '@envvault/sdk'
const ev = new EnvVault({ environment: 'production' })
export default async (req) => {
const stripeKey = await ev.secrets.get('STRIPE_SECRET_KEY')
// ...
}The function inherits ENVVAULT_TOKEN from the project's environment variables.
Deploy Previews
Pick a preview environment based on the Netlify deploy context:
# netlify.toml
[context.production]
command = "envv run -e production -- npm run build"
[context.deploy-preview]
command = "envv run -e preview -- npm run build"
[context.branch-deploy]
command = "envv run -e staging -- npm run build"