David Alonso
David Alonso4w ago

Env variables being pushed automatically

Is something like this possible: when running npx convex dev , variables in the following files inside the convex folder get pushed to the following deployments: env.local -> development env.staging -> preview env.prod / .env -> prod This would be super neat! Not sure what the easiest way currently is when migrating a file-system snapshot to a different project
4 Replies
Convex Bot
Convex Bot4w ago
Thanks for posting in <#1088161997662724167>. Reminder: If you have a Convex Pro account, use the Convex Dashboard to file support tickets. - Provide context: What are you trying to achieve, what is the end-user interaction, what are you seeing? (full error message, command output, etc.) - Use search.convex.dev to search Docs, Stack, and Discord all at once. - Additionally, you can post your questions in the Convex Community's <#1228095053885476985> channel to receive a response from AI. - Avoid tagging staff unless specifically instructed. Thank you!
jamwt
jamwt3w ago
hey there! I asked our fancy new AI bot in the docs, here's the answer: Yes, you can set environment variables for your Convex project using the command line. The Convex CLI provides commands to manage environment variables. Here's how you can do it: 1. To set an environment variable:
npx convex env set <name> <value>

npx convex env set <name> <value>

2. To list all environment variables:
npx convex env list

npx convex env list

3. To get the value of a specific environment variable:
npx convex env get <name>

npx convex env get <name>

4. To remove an environment variable:
npx convex env remove <name>

npx convex env remove <name>

These commands will modify the environment variables for your development deployment by default. If you want to set environment variables for your production deployment, you can use the --prod flag:
npx convex env --prod set <name> <value>
npx convex env --prod set <name> <value>
It's important to note that environment variables are set per-deployment, so you can have different values for the same key in your development and production environments. For more detailed information on managing environment variables in Convex, you can refer to the Production > Environment Variables documentation.
Environment Variables | Convex Developer Hub
Store and access environment variables in Convex
jamwt
jamwt3w ago
obviously this isn't exactly what you're asking for -- I think it's an interesting feature request to have a kind of macro that does this automatically from a specific .env file given a flag, say. but for now, just letting you know it's scriptable since you can parse that file and use the cli in this way, in a pinch
David Alonso
David AlonsoOP3w ago
Thank you!!

Did you find this page helpful?