Sanity Studio v3.73.0: Live Content API now implemented in Presentation + Improvements and bugfixes

✨ Highlights

Presentation tool is now using Sanity Live Content API

The Presentation tool is now using Sanity Live Content API to drive Live Mode in integrations like @sanity/react-loader, @sanity/svelte-loader, @nuxtjs/sanity and @sanity/core-loader.

The new setup allows query refetching to only happen when actually needed, as opposed to every two seconds.

Why was fetching happening every two seconds before?

This aggressive polling was in place to capture changes that couldn’t be reliably predicted client-side using Content Source Maps/CSM. The goal was to ensure that such changes were detected and that eventual consistency was maintained in the live preview.

count(*[_type == "person" && isPublished])

For the client to know when this query count will change it would need to monitor every person document and if isPublished is true. This doesn't scale.

*[slug.current == "discounted"]

If any document is given the slug discounted, the query needs to refetch. The client would need to monitor every single document mutation in the dataset and check if a new document now has the slug, as well as check if any fields on the current matching document has changed, or if the matching document got deleted and there's a fallback match, or none at all.

The gist of it is the client can't predict everything, and if it tries, it winds up using a lot of memory and perform work, just in case anything has changed.

While this over-fetching never counted towards your Sanity API hit quota, the intention has always been to move over to a better architecture.

Enter the new Sanity Live API; it's built to solve "when should a query refetch?" and it allows Presentation to rely on the backend for telling it when it needs to refetch, thus using far less memory, less network resources, and less work on the main thread.

🐛 Notable bugfixes

Internal document types will no longer appear in validation results in the CLI

Fixes an issue where write tokens were not being set in .env file after initializing a remote template

Fixes an issue where splitting a Portable Text block right before an inline object might cause the editor to crash

Fixes an issue where using Shift+Enter to insert a line break (\n) in the Portable Text input would not work as expected in Safari

Install or upgrade Sanity Studio

To initiate a new Sanity Studio project or upgrade an existing one, please refer to our comprehensive guide on Installing and Upgrading Sanity Studio.

If you are updating from a version earlier than 3.37.0, you should also check out this article to ensure your dependencies are up to date.