Sanity Studio v4.20.0: New schema validate command, improvements to scheduled drafts, and multiple fixes

✨ Highlights

Deprecating React 18

React 19 was released December 5, 2024, and the Sanity Studio has supported it since the early days, while still preserving compatibility with React 18. Now, as we approach the one year mark of the React 19 release, its time to leave React 18 behind so that the Studio can start adopting React 19-only features for more efficient data fetching and rendering patterns. As of this release, React 18 is officially marked as deprecated and in the coming weeks we will release a new major version (v5) which drops support for React v18 entirely.

To prepare for this change we recommend that all existing Studios are upgraded to the latest React 19.x. For plugin developers, we recommend that you test and verify that your plugin is tested compatible with React 19, and you can also start preparing for the Sanity v5 release where React 19.2 is the new baseline. Also make sure to mark it as compatible with v5 by including Sanity v5 in the allowed peerDependency range, e.g.: "sanity": "^3.0.0 || ^4.0.0 || ^5.0.0-0" (note the trailing -0 to make it compatible with prereleases of v5).

Sanity schema validate

This update adds a new flag to the schema validate command. sanity schema validate --debug-metafile-path <path> outputs a file with information about the size of the serialized schema. The file follows ESBuild's metafile format and can be analyzed through https://esbuild.github.io/analyze/.

This visualization can help identify large parts of a schema that rely too heavily on inlined types or fields, rather than named, reusable, types.

Deleting scheduled drafts allows for copying contents back to draft

Deleting scheduled drafts now gives you the option to copy the content of the scheduled version to a draft version of the document.

New to scheduled drafts? Check out the user guide.

Allow createGlobalStyle to work with auto updating studios

Fixes an issue where createGlobalStyle from styled-components doesn't work if the Studio is deployed with autoUpdates: true. Usually this issue would manifest itself in some UI text using Times New Roman instead of Inter, and missing browser scrollbar styling.

If you're affected by this issue you'll need to run a new sanity deploy after updating to sanity@latest, you might as well use our styled-components fork while at it and give your studio a nice performance boost.
If you're already using @sanity/styled-components instead of styled-components then you're not affected by this issue.

Additional improvements

Makes Unpublish the primary action for Published documents.

The delete confirmation dialog now includes information about the versions of the document that will be deleted by it, providing extra clarity for users. This action will only be available if a published version of the document exists.

🐛 Notable bugfixes

Fixes an issue where Presentation Tool would construct an invalid URL on refresh if the URL in the address bar was absolute.

Fixes a regression in v4.19 where schema errors were not formatted properly and difficult to understand.

Fixes an error in where focusing on image inputs inside dialogs would unexpectedly close it.

Fixes a bug where nested validation rules could prohibit selecting an asset from the Media Library.

Fixes a bug in where disabling comments, through __internal_comments: undefined in portable text was not taking effect in portable text inline comments.

Fixes several issues with the datetime input.

Fixes inconsistent second and milliseconds in the time input initial value.

Restore support for time step in the time input.

Fixes an issue in where in some cases the releases tool could crash when doing changes in the time input.

Use the tool title for document.title if present, instead of defaulting to tool name

Fixes an issue that prevent React 19 studios from being able to use the @sanity/css-in-js drop-in replacement for styled-components. While @sanity/styled-components also works, @sanity/css-in-js uses React 19 features to be even faster.

Fixes an issue in where delete operation wouldn't work if you had version documents.

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.