👋 Next.js Conf 2024: Come build, party, run, and connect with us! See all events

How to set up staging and production environments in Sanity Studio using Vercel.

13 replies
Last updated: Sep 28, 2022
Hey all 👋 I took over an existing project that uses Studio and deployments with Vercel.I would like to have a staging and a production environment on Studio since I’m changing stuff in the schema and in the ui.
Is that possible? If so, what do I need to do?
Sep 28, 2022, 4:21 PM
Is the Studio deployed to Vercel as well? If so create a separate branch for the staging environment and update the env variable specifying the dataset (
SANITY_STUDIO_API_DATASET
) to whatever your staging dataset is called.
I’ve never used it but you can also try this:
https://www.sanity.io/docs/spaces
Sep 28, 2022, 4:24 PM
I don’t think this has a custom deployment. I believe it’s using the default url that studio creates fora. project (if that makes sense)
Sep 28, 2022, 4:26 PM
Like
xxx.sanity.studio/production/dashboard
Sep 28, 2022, 4:27 PM
You can only host 1 version of the Studio with Sanity, but as
user J
mentioned, you can use the spaces feature to switch between datasets.
Sep 28, 2022, 5:17 PM
I see, so no UI changes, got it
Sep 28, 2022, 5:19 PM
Since I have your attention ( 😄 ), is it common to deploy new Sanity Studio changes via the terminal with
sanity deploy
?
Sep 28, 2022, 5:19 PM
It is! People will also sometimes use Github actions to deploy new versions of the Studio, but I'm a bit ignorant when it comes to that process.
Sep 28, 2022, 5:22 PM
BTW, if you're looking to have different deployments of the Studio with different schemas and the like, you'll want to use another option for hosting. Or host the production Studio with Sanity and the development Studio with Vercel, etc.
Sep 28, 2022, 5:23 PM
Hmm, hmm, that’s what I was looking it.Kinda scared of breaking changes so definitely will be looking into that
Sep 28, 2022, 5:25 PM
Thank you!
Sep 28, 2022, 5:25 PM
How does that affect the
sanity deploy
part, tho? 🤔
Sep 28, 2022, 5:25 PM
sanity deploy
would then only update the production Studio in the example I gave. If you're hosting w/Vercel or Netlify, you'd need to commit your changes to a repo to deploy.
That said, if you're just running the studio locally, any changes you make will not effect the deployed Studio until you run
sanity deploy
. You can get away with just experimenting locally most of the time!
Sep 28, 2022, 5:28 PM
I’ve been trying out Studio locally but would like to have a staging environment for the client to try out the changes, hence my questions
Sep 28, 2022, 5:31 PM

Sanity– build remarkable experiences at scale

Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Was this answer helpful?