Deploying Convex in a Turborepo
I've been following along the guide to deploy Convex to Vercel. Owing to the fact that my repository is a turborepo, I'm finding the deployment instructions a bit confusing. I used Better T-Stack to create my repository. This means that the Convex directory is structured as such:
Now, the guide asks the user to do:
npx convex deploy --cmd 'npm run build'
which I'm not sure how to manage here. Do I build these two things separately? Ideally I'd like to resolve being able to run a single build instruction (ideally the typical one in a vercel deployment). I've got the entire repo here for anyone to play around with here: https://github.com/ajay-bhargava/todo
Any guidance is appreciated. I'll keep plugging away at this and report back my findings / progress if i make any.4 Replies
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!
Some related questions I have are:
- In addition to the
PRODUCTION_DEPLOY_KEY
do I need the DEPLOY_URL
?
- Is this something that goes into my web application as an environment variable?
- Why don't I need a deploy key for dev
?
If I'm understanding this:
Basically the CONVEX_DEPLOY_KEY is just an automatic way to set the CONVEX_URL (which I can just grab from the dashboard, right?) and then run convex deploy
?
Further reading ... ok, so the PRODUCTION_DEPLOY_KEY
is just so that I don't have to authenticate to write the convex functions?Here's a reference implementation: https://github.com/get-convex/turbo-expo-nextjs-clerk-convex-monorepo
The deploy key does contain deployment info so you don't have to set the convex url, but it also serves as an admin key for the deployment, allowing functions to be uploaded from a codebase to the deployment, which happens at build time.
It runs the command you provide (eg.,
npm run build
) after Convex functions successfully deploy, and injects framework prefixed variables to the client like NEXT_PUBLIC_CONVEX_URL
.Thanks! The build command:
Was critical. Of note it is important to replace the
with
in my specific case.