#copy envs from dev to prod deployment
4 messages · Page 1 of 1 (latest)
Let me check the knowledge base for you. One moment! :books:
Yes, there is a way to copy keys from the development instance to the production instance. However, it's important to note that environment variables are separate for each instance. You can set defaults for preview deploys and you can manually copy from prod to dev on your own. This allows you to work with different API keys and other environment variables.
There's also a CLI command to get and set environment variables. If you want to set default environment variables for a project that get synced to new preview deployments and new dev deployments, you can do so. This means that when new team members join and get a dev instance, they'll automatically have that environment variable without having to copy it from somewhere else.
Here's an example of how you can configure your client to use environment variables:
import React from "react";
import ReactDOM from "react-dom/client";
import App from "./App";
import "./index.css";
import { ClerkProvider, useAuth } from "@clerk/clerk-react";
import { ConvexProviderWithClerk } from "convex/react-clerk";
import { ConvexReactClient } from "convex/react";
const convex = new ConvexReactClient(import.meta.env.VITE_CONVEX_URL as string);
ReactDOM.createRoot(document.getElementById("root")!).render(
<React.StrictMode>
<ClerkProvider publishableKey={import.meta.env.VITE_CLERK_PUBLISHABLE_KEY}>
<ConvexProviderWithClerk client={convex} useAuth={useAuth}>
<App />
</ConvexProviderWithClerk>
</ClerkProvider>
</React.StrictMode>,
);
You can use the .env.local or .env file to configure your client when running locally. For production configuration, set the environment variable in your production environment depending on your hosting platform.
For more information, you can refer to the following sources:
- Discord Support Thread: Trouble understanding team workflow using Convex (https://discord.com/channels/1019350475847499849/1214799939364716574)
- Configuring a React client (https://docs.convex.dev/auth/clerk#configuring-a-react-client)
- Configuring dev and prod instances (https://docs.convex.dev/auth/clerk#configuring-dev-and-prod-instances)