#Whats the preferred way of determining if you are running convex in dev mode or production?
3 messages · Page 1 of 1 (latest)
Hi @icy stream. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
The preferred way to determine if you are running Convex in development or production mode is to use environment variables. Here's how you can approach this:
-
Set up environment variables:
- For your development deployment, set an environment variable (e.g.,
CONVEX_ENV) to "development" in the Convex dashboard. - For your production deployment, set the same environment variable to "production" in the Convex dashboard.
- For your development deployment, set an environment variable (e.g.,
-
Access the environment variable in your Convex functions:
You can then useprocess.env.CONVEX_ENVin your Convex functions to determine the current environment.
This approach is recommended by Convex, as mentioned in the Convex & Clerk documentation:
export default {
providers: [
{
domain: process.env.CLERK_JWT_ISSUER_DOMAIN,
applicationID: "convex",
},
],
};
While this example is specific to Clerk authentication, the same principle applies for determining the environment in general.
It's important to note that Convex does not currently provide a built-in system variable to distinguish between development and production environments. Setting and using your own environment variables is the recommended approach.