Connecting to an existing Sanity dataset in VSCode and deploying a hosted version of Sanity Studio.
Good news - you won't wipe your dataset! Your Sanity content lives in the cloud, not in your local VS Code files. Your backup project files just contain the connection configuration to access that data, so you're safe to restore them on your new machine.
Here's what you need to do:
Restore Your Project
Install Node.js and npm on your new machine (if not already installed)
Restore your VS Code project files from your backup to your new machine
Install dependencies - Navigate to your project folder and run:
npm installCheck your configuration - Your project should have a
sanity.cli.js(orsanity.cli.ts) file in the root that contains your project ID and dataset name:export default defineCliConfig({ api: { projectId: 'your-project-id', dataset: 'production' // or 'projecttest' } })Authenticate - Run this command to log in to your Sanity account:
npx sanity loginThis will open a browser window for authentication and store your credentials locally.
Start your Studio (if you're running Sanity Studio locally):
npm run dev
That's it! Your project will connect to your existing dataset without any issues. The sanity login command just authenticates your machine - it doesn't affect your content at all.
If Configuration Files Are Missing
If your backup doesn't include the sanity.cli.js file, you can recreate it manually. You'll need:
- Your Project ID (find it in manage.sanity.io)
- Your dataset name (likely "production" or "projecttest" as you mentioned)
Just create the configuration file with those values, and you'll be connected to your existing data.
Your content is completely safe in Sanity's cloud - these configuration files are just the "key" to access it, not the data itself!
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.