Is it possible to connect @sanity/client to local studio when developing?
The short answer is: no, you cannot connect @sanity/client directly to your local Studio instance. The Sanity client always connects to the hosted Content Lake (your project's cloud-hosted datasets), not to the Studio application itself.
However, you have several good options for testing schema changes safely before deploying to production:
Use a separate dataset for development
The recommended approach is to create a staging or development dataset within your project. You can work with this dataset locally while testing schema changes:
import {createClient} from '@sanity/client'
const client = createClient({
projectId: 'your-project-id',
dataset: 'development', // or 'staging' instead of 'production'
apiVersion: '2024-01-01',
useCdn: false
})You can create additional datasets through the Sanity Manage interface or CLI. As mentioned in the projects documentation, projects support multiple datasets for different development stages - production, development, and staging datasets allow you to test features and migrations while maintaining content integrity.
Copy data between datasets
If you want to test with realistic data, you can copy content from your production dataset to your development dataset using the sanity dataset copy command:
sanity dataset copy production developmentThis creates a snapshot of your production content in the development dataset, letting you experiment safely.
Why the Studio isn't a "server"
It's important to understand that Sanity Studio is just a React application - it's a frontend interface that also connects to the Content Lake via the client. The Studio doesn't host your content locally; it's always reading from and writing to your cloud-hosted datasets. This architecture means your content is always in the Content Lake, whether you're accessing it through Studio, your website, or any other client.
This multi-dataset approach is actually quite powerful - you can run your local Studio pointed at a development dataset, test your schema changes there, and once you're confident, deploy the schema and switch your production Studio and clients to use it.
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.