✨Discover storytelling in the AI age with Pixar's Matthew Luhn at Sanity Connect, May 8th—register now

Understanding the difference between a locally run and deployed Sanity installation in React.

3 replies
Last updated: Mar 9, 2021
Hiya.  I'm currently on my first Sanity project, and still trying to wrap my head around it. 🙂  One thing that I don't fully understand yet is the difference between a deployed Sanity installation and a locally run installation when using it with React. In
user G
’s tutorial on YouTube she added "http://localhost:3000/ " to the Sanity API whitelist. But other than using the
@sanity/cli
NPM package and the Sanity project ID, I can't think of what it is that decides if a locally run or a deployed Sanity installation is to be used. How is this logic handled? Is this documented someplace where I can read about it?
Mar 8, 2021, 8:26 AM
I am also new to Sanity, working on my first project. I will try to answer this question for you, but there may be other people more experienced than I am who can answer.
When running your local studio and making changes to your schema/etc, the only thing that is local to your machine is the code for the studio. The dataset being used is the one hosted by
sanity.io , and the studio is making requests to sanity.io for whichever dataset you have configured.
One you have finished making changes to your schema, you commit those changes and deploy them to your hosted studio on
sanity.io . If you use the studio code in your project, hosted somewhere else, it will still be making requests to the dataset on sanity.io .
Mar 8, 2021, 3:32 PM
Ah, I think I understand now. My React site is getting the data from Sanity's servers no matter if Sanity Studio is running on my computer or not. It's Sanity Studio that I'm running locally, and it's the schemas that I'm deploying to Sanity's servers, not the data in the database. Furthermore, I can have data in the Sanity database that aren't defined in the schemas in Sanity Studio (I've seen the error message in Sanity Studio at one time), just as I can have data fields defined in Sanity Studio (i.e. the schemas) that has no data in the database. Sanity Studio and the schemas is just a way to access, organize and edit the data in the database.
Is this just about right?
Mar 9, 2021, 8:40 AM
user M
I believe that is right, yes!
Mar 9, 2021, 3:38 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?