Skip to main content

Command Palette

Search for a command to run...

Convex Environment Variables Reference

Published
1 min read
Convex Environment Variables Reference
T

Just a guy who loves to write code and watch anime.

Environment Variables

System variables (always available in Convex functions)

process.env.CONVEX_CLOUD_URL; // https://your-deployment.convex.cloud
process.env.CONVEX_SITE_URL; // https://your-deployment.convex.site
  • CONVEX_CLOUD_URL — for Convex clients (queries, mutations, subscriptions)

  • CONVEX_SITE_URL — for HTTP actions

Setting custom env variables

# Dev
npx convex env set MY_API_KEY some-secret-value

# Production
npx convex env set MY_API_KEY prod-secret-value --prod

Or set them in the Convex dashboard under Deployment Settings.

Accessing in Convex functions

const apiKey = process.env.MY_API_KEY; // string or undefined

Client-side env variables (Vite)

Convex URLs are not automatically available in your React code. Set them in your .env file.

# .env
VITE_CONVEX_URL=https://your-deployment.convex.cloud

If you need the .site URL on the client you can derive it:

const CONVEX_SITE_URL = import.meta.env.VITE_CONVEX_URL.replace(
  ".cloud",
  ".site",
);

Or add a separate env variable:

# .env
VITE_CONVEX_SITE_URL=https://your-deployment.convex.site