TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/get-convex/convex-backend/llms.txt
Use this file to discover all available pages before exploring further.
convex env command allows you to manage environment variables on your Convex deployment. Environment variables are accessible in your Convex functions via process.env.
Subcommands
convex env set- Set environment variablesconvex env get- Print a variable’s valueconvex env list- List all environment variablesconvex env remove- Unset an environment variable
Set command
Set environment variables on your deployment.Usage
Arguments
Name of the environment variable to set.Optional when using
--from-file.Value to set. If omitted, you’ll be prompted to enter it interactively.
Options
Read environment variables from a
.env file.Without --force, fails if any existing variable has a different value.When setting multiple variables, overwrite existing environment variable values instead of failing on mismatch.
Examples
Set a single variable
Set a variable with a value:Set interactively
Set a variable and be prompted for the value:Set from file
Set multiple variables from a.env file:
Force overwrite
Overwrite existing values when importing from file:Set from stdin
Read value from stdin:Set on production
Set a variable on your production deployment:Get command
Print an environment variable’s value.Usage
Arguments
Name of the environment variable to retrieve.
Examples
List command
List all environment variables on your deployment.Usage
Examples
List all environment variables:Remove command
Unset an environment variable from your deployment.Usage
Aliases
convex env rmconvex env unset
Arguments
Name of the environment variable to remove.
Examples
Remove a variable:Deployment selection
Allconvex env subcommands support deployment selection:
--prod- Target production deployment--preview-name <name>- Target a preview deployment--url <url>- Target a specific deployment URL--admin-key <key>- Admin key for authentication
Environment variable format
When using--from-file, the file should follow the .env format:
Best practices
- Never commit secrets - Don’t commit
.envfiles with secrets to version control - Use different values per environment - Production and dev should have separate API keys
- Set in CI/CD - Use
convex env setin deployment pipelines to configure production - Validate on startup - Check for required environment variables in your backend initialization code
Security
Environment variables are:- Encrypted at rest
- Only accessible to your Convex functions
- Not exposed in client-side code
- Transmitted securely over HTTPS