Skip to main content
The 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 variables
  • convex env get - Print a variable’s value
  • convex env list - List all environment variables
  • convex env remove - Unset an environment variable

Set command

Set environment variables on your deployment.

Usage

Arguments

string
Name of the environment variable to set.Optional when using --from-file.
string
Value to set. If omitted, you’ll be prompted to enter it interactively.

Options

string
Read environment variables from a .env file.Without --force, fails if any existing variable has a different value.
boolean
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

string
required
Name of the environment variable to retrieve.

Examples

List command

List all environment variables on your deployment.

Usage

Examples

List all environment variables:
List variables on production:

Remove command

Unset an environment variable from your deployment.

Usage

Aliases

  • convex env rm
  • convex env unset

Arguments

string
required
Name of the environment variable to remove.

Examples

Remove a variable:
Remove from production:

Deployment selection

All convex 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
By default, commands target your dev deployment.

Environment variable format

When using --from-file, the file should follow the .env format:

Best practices

  1. Never commit secrets - Don’t commit .env files with secrets to version control
  2. Use different values per environment - Production and dev should have separate API keys
  3. Set in CI/CD - Use convex env set in deployment pipelines to configure production
  4. 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
Values are shown in the Convex dashboard but can be marked as sensitive to hide them from unauthorized team members.