Learn how to configure secrets and environment variables in VibeKit
VibeKit allows you to securely pass environment variables to your sandbox environment through the secrets configuration. This guide explains how to configure and manage these secrets.
Configuration Overview
Secrets in VibeKit are environment variables that get passed to the sandbox where your code executes. They are configured through the optional secrets object when initializing the VibeKit class.
export type SecretsConfig = { /** Environment variables to be passed to the sandbox */ [key: string]: string;};
import { VibeKit, VibeKitConfig } from "@vibe-kit/sdk";const config: VibeKitConfig = { agent: { type: "codex", model: { apiKey: process.env.OPENAI_API_KEY!, }, }, environment: { e2b: { apiKey: process.env.E2B_API_KEY!, }, }, secrets: { // These environment variables will be available in your sandbox DATABASE_URL: process.env.DATABASE_URL!, REDIS_URL: process.env.REDIS_URL!, STRIPE_SECRET_KEY: process.env.STRIPE_SECRET_KEY!, API_BASE_URL: process.env.API_BASE_URL!, },};const vibeKit = new VibeKit(config);
Accessing Secrets in Generated Code
Once configured, these secrets are available as environment variables in your sandbox:
// In your generated code running in the sandboxconst databaseUrl = process.env.DATABASE_URL;const stripeKey = process.env.STRIPE_SECRET_KEY;// Use them in your applicationconst db = new Database(databaseUrl);const stripe = new Stripe(stripeKey);