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.
Basic Usage
Using withSecrets
Adding Secrets to Your Configuration
Accessing Secrets in Generated Code
Once configured, these secrets are available as environment variables in your sandbox:
Common Use Cases
Database Connections
API Keys and External Services
Application Configuration
Environment Variables Setup
Create a .env file in your project root to store your secrets:
Security Best Practices
Never commit secrets or API keys to version control. Always use environment variables and ensure your .env file is in your .gitignore.
1. Use Environment Variables
Always use process.env to access secrets:
2. Add .env to .gitignore
Ensure your .env file is not committed to version control:
3. Validate Required Secrets
Validate that all required secrets are present before initializing VibeKit:
4. Use Different Environments
Use different environment files for different stages:
Complete Example
Here’s a complete example showing how to set up secrets for a full-stack application:
Troubleshooting
Common Issues
- Missing Environment Variable: Make sure all required secrets are set in your environment
- Secrets Not Available in Sandbox: Ensure secrets are properly configured in the
secrets object
- Type Errors: Use the non-null assertion operator
! or provide default values for optional secrets
Testing Your Configuration
You can test your configuration by initializing VibeKit: