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

Connecting to an existing Sanity dataset in VSCode and deploying a hosted version of Sanity Studio.

23 replies
Last updated: Mar 9, 2023
Hi just re 'setup' question. I have a website, using sanity to store some images and data. I connect to sanity through vscode. I connect to sanity dataset production for example. My site and data are all finished.
Now the problem. I have backups of my visual studio project. Though my pc has completely died. Motherboard issues so I am starting my new build i was planning. When I reinstall Vs code and use my backup vscode files......how do I connect to my existing sanity dataset in vscode without wiping that dataset? I think its called 'production' or 'projecttest'.
Nov 4, 2022, 9:08 AM
Hey
user C
! You can just add your project ID and dataset name to your configuration in
sanity.json
. This won't wipe any data, it'll just connect your Studio to that project and dataset and allow you to work with existing data.
Nov 4, 2022, 4:34 PM
Thanks. Where do I find the project id?
Nov 4, 2022, 4:39 PM
Can I find that by logging in via browser?
Nov 4, 2022, 4:39 PM
I have the dataset name
Nov 4, 2022, 4:39 PM
You can find it in sanity.io/manage when you select the project. It'll be right below the name of the project.
Nov 4, 2022, 4:40 PM
Awesome thanks!
Nov 4, 2022, 4:40 PM
One more quick question. How my current setup works with sanity, I have to run sanity from vscode sanity start to get to my actual data and make any edits. Is it possible to go to sanity.io/manage and actually have access to the data?
For example I have a contact form but I have to run vscode and sanity start to login through the cmd line to read contact form messages.
Nov 4, 2022, 4:42 PM
You can run
sanity deploy
to deploy a hosted version of your Studio. That way, you don't need to run
sanity start
each time.
Nov 4, 2022, 4:43 PM
Ohhhhh
Nov 4, 2022, 4:43 PM
Wow. I've been doing the long way round for ages now. I guess ill have to do that when my new pc is up and running with my website backup and connected to sanity.
Nov 4, 2022, 4:44 PM
Thanks for the info
Nov 4, 2022, 4:44 PM
For sure! Happy to help!
Nov 4, 2022, 4:44 PM
Hi I have another question regarding sanity studio after it is deployed. Is there some way to set up an automatic email notification when I receive a message to my contact box? Or would that be some custom coding involved? Thanks
Jan 5, 2023, 2:12 PM
That would have to be something custom. Folks will usually use a webhook to send the data to an email service.
Jan 5, 2023, 5:23 PM
Hi one more question about this, I'm recreating my project in v3 doing a fresh sanity install because I had some issues converting from v2 to v3. If I connect my new v3 project to this same v2 made dataset will the data still be safe and not get wiped?
Thanks for any info :)
Mar 7, 2023, 11:34 AM
user M
Mar 8, 2023, 12:10 PM
The data won’t get wiped, but if you connect that dataset to a new Studio, it’ll receive any edits you make 🙂
Mar 8, 2023, 4:37 PM
Oh okay thats cool. So I can just redo my project fresh (install latest sanity) copy my code over with bare minimal changes ...then connect to the existing dataset from sanity v2 and everything should work fine then?
Mar 8, 2023, 4:42 PM
Exactly! I’ve actually found the upgrade process is easier if you just bootstrap a new V3 project, cop over your schemas, then add the old Studio’s project id.
Mar 8, 2023, 4:44 PM
Excellent. Thanks for the confirmation. Yeah I ran into a few different more complex issues running through editing the existing project. So hopefully this works out better.
Cheers
Mar 8, 2023, 4:46 PM
Happy to help!
Mar 8, 2023, 4:46 PM
user M
did something change in @sanity/client with this? 🤔. Hopefully I'm not top far from getting my v2 stuff over on v3. A few roadblocks though. Not sure on this.
Mar 9, 2023, 2:32 PM
Yes, V5 of the client (which was recently released) introduced some breaking changes.
Mar 9, 2023, 3:45 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?