Joint session with Vercel: How to build intelligent storefronts (May 15th) →

How to set up staging and production environments in Sanity Studio?

13 repliesLast updated: Dec 2, 2025

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?
AI Update

Absolutely! Setting up staging and production environments for your Sanity Studio is definitely possible, and it's a smart approach when you're making schema and UI changes. Here's how to do it:

The Basic Approach: Multiple Datasets

The key is to use separate datasets for staging and production. Datasets are completely isolated collections of content within your Sanity project - think of them as separate databases. Your Free plan includes 2 datasets, which is perfect for this setup.

Setting Up Your Environments

1. Create a staging dataset

If you don't already have one, create a staging dataset using the Sanity CLI:

sanity dataset create staging

2. Configure environment variables

Since you're deploying to Vercel, you'll want to use environment variables to control which dataset each deployment uses. The key variable is SANITY_STUDIO_API_DATASET.

In your Studio project, you can create environment-specific files:

For example, in .env.development:

SANITY_STUDIO_API_DATASET="staging"

3. Set up Vercel deployments

The recommended approach is to deploy separate Studio instances to Vercel:

This way, you can test schema and UI changes in your staging Studio without affecting production.

Important note: If you're using Sanity's hosted Studio (xxx.sanity.studio), you can only host one version there. For staging, you'll need to host on Vercel or another platform. Many teams host production on Sanity's hosting and staging on Vercel, or both on Vercel.

Configure CORS Origins

Don't forget to add your Vercel deployment URLs to your CORS origins in the Sanity management dashboard (manage.sanity.io):

Make sure to check "Allow credentials" if you're using authentication tokens.

Alternative: Workspaces Feature

If you only need to switch between datasets but don't need different UI/schema versions, you could use Workspaces to configure multiple isolated Studio configurations within a single deployment. Each workspace can connect to a different dataset and have its own tools and plugins. However, this won't help with testing breaking schema changes since all workspaces share the same codebase - both datasets would use the same Studio code version.

For your use case where you're actively changing the schema and UI, separate deployments (as described above) are the better approach.

Deploying Changes

When you're ready to deploy Studio changes:

This setup gives you a safe environment to test changes before your client sees them in production!

Show original thread
13 replies

Was this answer helpful?

Sanity – Build the way you think, not the way your CMS thinks

Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.

Related contributions