#Give me an exact workflow to push from dev to prod deployment
13 messages · Page 1 of 1 (latest)
Hi @oak plover. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
Here's an exact workflow to push from a development deployment to a production deployment in Convex:
-
Develop and test your changes locally using your individual dev deployment. Run
npx convex devto start your local development environment Typical team development workflow (https://docs.convex.dev/production#typical-team-development-workflow). -
When your changes are ready, commit them to your Git repository and create a pull request or commit to a shared branch Typical team development workflow (https://docs.convex.dev/production#typical-team-development-workflow).
-
If you're using a hosting provider like Vercel or Netlify, set up automatic deployments to trigger when changes are merged to your main branch Hosting and Deployment (https://docs.convex.dev/production/hosting).
-
If you're deploying manually, follow these steps:
a. Checkout the branch you want to deploy (usually main)
b. Run the following command:npx convex deploy --cmd 'npm run build'This command will deploy your backend code to your production deployment and build your frontend Custom Hosting (https://docs.convex.dev/production/hosting/custom#build-and-deploy-to-convex-and-github-pages).
-
Confirm that you want to push your current backend code to your production deployment when prompted Custom Hosting (https://docs.convex.dev/production/hosting/custom#build-and-deploy-to-convex-and-github-pages).
-
If you're using a hosting provider, the frontend will be automatically deployed. If you're using custom hosting, you'll need to deploy the built frontend code to your hosting provider Custom Hosting (https://docs.convex.dev/production/hosting/custom#how-it-works).
By following this workflow, you ensure that your production deployment has your newest functions and your app is configured to connect to it Using Convex with Vercel (https://docs.convex.dev/production/hosting/vercel#how-it-works).
Remember, you should only deploy to your production deployment after thoroughly testing your changes on your local development deployment Project Configuration (https://docs.convex.dev/production/project-configuration).
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
@oak plover Kapa.ai is still learning and improving, please let me know how I did by reacting below.
@bitter crane And how do I work with preview deployments
Let me check the knowledge base for you again. One moment! :books:
Certainly! I'd be happy to explain how to work with preview deployments in Convex. Preview deployments are a great way to test both frontend and backend changes before pushing them to production. Here's how you can work with them:
-
First, ensure you have a Convex Pro plan, as preview deployments are a Pro feature Preview Deployments (https://docs.convex.dev/production/hosting/preview-deployments).
-
Set up the
CONVEX_DEPLOY_KEYenvironment variable:- Go to your Convex Dashboard (https://dashboard.convex.dev/) and navigate to your project's Settings page.
- Click "Generate Preview Deploy Key" to create a Preview deploy key.
- Copy this key and add it to your hosting provider's environment variables for preview deployments Using Convex with Vercel (https://docs.convex.dev/production/hosting/vercel#preview-deployments).
-
(Optional) Set up default environment variables for your preview deployments in your Convex project Using Convex with Vercel (https://docs.convex.dev/production/hosting/vercel#preview-deployments).
-
(Optional) If you need to set up initial data for your preview deployments, you can create a function to do this and add it to your deploy command:
npx convex deploy --cmd 'npm run build' --preview-run 'functionName'Replace 'functionName' with the name of your setup function Using Convex with Netlify (https://docs.convex.dev/production/hosting/netlify#deploy-previews).
-
When you push changes to a feature branch or create a pull request, your hosting provider (like Vercel or Netlify) will create a preview deployment. Convex will automatically create a corresponding backend preview deployment Using Convex with Vercel (https://docs.convex.dev/production/hosting/vercel#how-it-works-1).
-
You can now test your changes using the preview URL provided by your hosting provider. This preview will use a fresh Convex backend deployment, separate from your production and development deployments Using Convex with Netlify (https://docs.convex.dev/production/hosting/netlify#how-it-works-1).
-
Preview deployments are automatically cleaned up after 14 days, or when a new preview deployment with the same name is created. You can also manually delete them from the Convex dashboard Preview Deployments Limits (https://docs.convex.dev/production/hosting/preview-deployments#limits).
Remember that preview deployments are currently a beta feature. If you encounter any issues or have feedback, you can reach out to the Convex team on their Discord community Preview Deployments Limits (https://docs.convex.dev/production/hosting/preview-deployments#limits).
By using preview deployments, you can effectively test your changes in an isolated environment before merging them into your main branch and deploying to production.
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
@oak plover Kapa.ai is still learning and improving, please let me know how I did by reacting below.
@bitter crane So preview deployments is a Vercal only feature?
Let me check the knowledge base for you again. One moment! :books:
No, preview deployments are not a Vercel-only feature in Convex. Let me clarify this for you:
-
Convex preview deployments are a feature available on the Convex Pro plan, and they can be used with various hosting providers, not just Vercel Preview Deployments (https://docs.convex.dev/production/hosting/preview-deployments).
-
Convex supports preview deployments with both Vercel and Netlify:
- For Vercel, they're called "Preview Deployments" Using Convex with Vercel (https://docs.convex.dev/production/hosting/vercel#preview-deployments)
- For Netlify, they're referred to as "Deploy Previews" Using Convex with Netlify (https://docs.convex.dev/production/hosting/netlify#deploy-previews)
-
The Convex CLI (
npx convex deploy) is designed to work with various environments. It can infer the Git branch name for Vercel, Netlify, GitHub, and GitLab environments CLI Deploy (https://docs.convex.dev/cli#deploy-convex-functions-to-a-preview-deployment). -
You can even use preview deployments with custom hosting solutions by specifying the preview deployment name manually using the
--preview-createoption CLI Deploy (https://docs.convex.dev/cli#deploy-convex-functions-to-a-preview-deployment).