How to clone/retrieve schema from deployed Sanity Studio?

5 replies
Last updated: Aug 24, 2020
Hi! I have a question: If I have a project that is deployed to *.sanity.studio and I remove the development files from my local machine, is there a way of “cloning” the project (including schemas etc…) from the deployment server? Or should I make sure to track the changes with git or similar (probably a good idea anyway… :))?
AI Update

Unfortunately, you cannot retrieve your source code, schemas, or configuration files from a deployed *.sanity.studio instance. When you run sanity deploy, it compiles your Studio into a static bundle (HTML, CSS, and JavaScript) that gets hosted on Sanity's infrastructure. This is a built production artifact, not your original source code.

Think of it like this: the deployed Studio is similar to a compiled application - you can use it, but you can't "decompile" it back into your original schema definitions, custom components, or configuration files.

What You Should Do

Yes, you absolutely should use Git or another version control system to track your Sanity Studio project! This is considered a best practice for several reasons:

  1. Source code preservation: Your schema definitions, custom components, and configuration are valuable code that needs to be versioned
  2. Team collaboration: Multiple developers can work on the Studio simultaneously
  3. Rollback capability: If something breaks, you can revert to a previous working state
  4. Deployment automation: You can set up CI/CD pipelines to automatically deploy when you push changes

What IS Available from Sanity

While you can't retrieve your Studio source code, you can access:

  • Your content data: All documents in your dataset are always accessible via the Sanity CLI using GROQ queries or through the API
  • Your deployed schema: When you run sanity deploy, it also deploys your schema definitions to Sanity's platform (used by features like Agent Actions and Canvas), but this is for platform features, not for retrieving your source code

Recovery Options

If you've lost your local files but have a deployed Studio:

  1. Check if you have any backups on other machines or cloud storage
  2. Look for any previous deployments to other services (Vercel, Netlify) that might have the source
  3. If you're working with a team, check if anyone else has the repository
  4. As a last resort, you'd need to manually recreate your schema by examining your deployed Studio's behavior and document structure in your dataset

Bottom line: Always use version control for your Sanity Studio project. The deployed *.sanity.studio is just the compiled output, not a backup of your source code.

Show original thread
5 replies
Hi!You should definitely track changes with git
😉
you can wrangle out the schemas from the compiled app bundle, but it's definitively better to put it into git. You can even deploy it from GitHub: https://maxschmitt.me/posts/deploy-sanity-github-actions/
you can wrangle out the schemas from the compiled app bundle, but it's definitively better to put it into git. You can even deploy it from GitHub: https://maxschmitt.me/posts/deploy-sanity-github-actions/
Hi!You should definitely track changes with git
😉
Thanks! Will definitely do that 🙂. Luckily not actually in the situation outlined above!

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.

Was this answer helpful?