Can I import a project into Vercel from a feature branch?

I am currently working on migrating a project from just a single app repo to a monorepo with Turborepo. I was able to update the settings in Vercel to at least build the Next.js application in my PR with the new monorepo structure. However, I can’t get it to build my Sanity studio because that isn’t imported into Vercel.

My project structure looks like apps/web and apps/studio where web is just a copy of what I had at the root level when it wasn’t a monorepo and studio is my Sanity CMS studio. Is there a way to bring this into Vercel so that it too can be built in my PR?

In a monorepo you’ll set up individual Vercel projects for each app within the monorepo, so it sounds like you just need to make one for Sanity Studio now

Here’s how to set it up:

  1. Go to your Vercel dashboard and click “Add New…” > “Project”
  2. Import your repository (the same one you’re using for your Next.js app)
  3. In the configuration screen, under “Framework Preset”, select “Sanity”
  4. In the “Root Directory” field, enter apps/studio
  5. Configure other settings as needed and click “Deploy”

This will create a separate Vercel project for your Sanity Studio, which will have its own deployment URL, but it will deploy from the same repository as your Next.js app.

Does that work even when the apps/studio is on a feature branch and not the default branch? When importing the project it’s just showing the default branch content and I can’t edit the directory to be something else.

Also there’s a “Sanity” and “Sanity (v3)”. I’m guessing the v3 one should be selected?

So I tried what you mentioned above and it gives me on initial deploy

However, it looks like it is working for the branch :sweat_smile:, although will probably fail due to ENV vars.

I ended up getting this to work. However, I have a line like this const projectId = process.env.SANITY_STUDIO_PROJECT_ID ?? ""; in my sanity config and for some reason it was defaulting to "" even though I have that env var in that project’s settings in Vercel. After I hardcoded it in the code everything deployed just fine.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.