#How do I know if I'm in DEV in convex?
3 messages · Page 1 of 1 (latest)
Hi @latent stump. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
There's no built-in environment variable in Convex that reliably indicates whether you're in a dev vs. production deployment. Notably, NODE_ENV is not a reliable indicator — it is currently set to "production" everywhere in Convex (both dev and prod deployments). [NODE_ENV thread]
Recommended approach: Create your own environment variable
The recommended strategy is to define your own custom environment variable (e.g., CONVEX_ENV) and set it differently per deployment via the Convex dashboard. [NODE_ENV thread]
Steps:
-
Go to your development deployment settings on the Convex dashboard and add:
- Name:
CONVEX_ENV - Value:
development
- Name:
-
Go to your production deployment settings and add:
- Name:
CONVEX_ENV - Value:
production
- Name:
-
Access it in your Convex functions using
process.env:
const isDev = process.env.CONVEX_ENV === "development";
You can also set environment variables from the CLI: [Environment Variables]
npx convex env set CONVEX_ENV 'development'