@luke @ThatGuyJamal @arthur I'm working
@luke @CodingWithJamal @arthur I'm working on releasing the Monorepo (React Native + web) template today, check it out and lmk if you have feedback: https://github.com/get-convex/turbo-expo-nextjs-clerk-convex-monorepo
10 Replies
Hi @ian . QQ: What does the vercel deployment script look like for this template. Following web guide, when it's in the same folder, you run
npx convex deploy --cmd 'npm run build'
With the separate folder structure here, what would be the equivalent comment to support both preview and production builds.Try going through this https://vercel.com/docs/monorepos/turborepo
But swap
turbo run build
for npx convex deploy --cmd 'turbo run build'
Deploying Turborepo to Vercel
Learn about Turborepo, a build system for monorepos that allows you to have faster incremental builds, content-aware hashing, and Remote Caching.
If that works I can link to that documentation instead of duplicating steps into the repo’s readme
That's probably not going to work, since for vercel, you are running this command in the project root. So say in the repo example, if you run npx convex deploy, you would be in the apps/web directory, but the actual convex project is in packages/backend, unless with npx convex deploy, you have a way to specify the directory
For example in the below:

Looking at it, I am guessing you could just do
turbo run build
then in the packages/backend have a build script that is just npx convex deploy
and apps/web have its own next build
command. Turbo run build will trigger both build commands. What do you think?
And with turbo, you can specify deps, so you can make one build depend on another, or even with the pipeline deps:
This will mean since web is dependent on backend, it's build won't trigger till packages/backend build script is done, which in this case would be npx convex deploy
The syntax above mean first run any build commands of its dependencies, and since web is dependent on packages/backend, it will enforce the orderThat works, but for preview deploys you won't be deploying the preview UI pointing at the preview backend. it's ugly, but what about something like (from the root):
?
Ok. That could work. The vercel command does need to be run from apps/web. Can you explain what you mean the preview ui won’t be deployed in the earlier scenario?
Check out the convex preview deploy docs- the deploy sets an env variable about where to find the backend for the —cmd command. When the frontend deploys it needs to know where the backend is. So you can run the build inside —cmd or you’d need to hardcode the url in the vercel env, which would only point at one url, probably prod is best.
If you’re fine with previews not deploying a preview backend and pointing at prod that’s fine but then you can’t preview frontend and backend changes at once
Ok. It's probably easier to leave as our current setup of having convex and nextjs in one project, and having expo project import from there. We are using turbo repo and it works. Just would have liked to move the convex folder out of the nextjs project.