Environment Variables
Store secrets and configuration for your projects securely.
Adding environment variables
Open your project in the editor, click the gear icon in the toolbar, and go to "Environment Variables". Add key-value pairs. Values are encrypted at rest and masked in the UI.
How they work
Environment variables are injected into your execution environment. For server-side languages (Python, Go, etc.), they are set as OS environment variables in the Docker container. For WebContainer projects, they are set in the Node.js process.
# Python
import os
api_key = os.environ.get('API_KEY')
# JavaScript
const apiKey = process.env.API_KEY
# Go
apiKey := os.Getenv("API_KEY")Security
Environment variables are encrypted in the database. They are never included in shared or forked projects. If someone forks your project, they get the code but not your secrets.
Variables are only injected at execution time. They do not appear in the editor, file tree, or project downloads.
Limits
Maximum 20 environment variables per project. Keys must be uppercase letters, numbers, and underscores. Values are limited to 4KB each.