Sanity TypeGen
Enhancements to Portable Text Editor and TypeGen support for Astro
v3.69.0
✨ Highlights
Markdown behaviors for the Portable Text Editor
The Portable Text Editor (PTE) now ships with markdown keyboard shortcuts for headings, block quotes and lists.
This change extends the core behaviors of the PTE with default markdown behaviors for a more intuitive writing experience. This allows you to:
- Use
#
characters to create headings. - Use
>
to create a blockquote. - Use
Backspace
at the beginning of a block to clear its style. - Use
-
,*
,_
or1.
to initiate a list.
This is part of the effort that brings features from the new standalone Portable Text Editor back into the Studio.
TypeGen: add support for astro
You can now generate types from queries in .astro
files. Learn more in the TypeGen docs.
🐛 Notable bugfixes
- Fixes schema extraction with nested union references.
- Header when creating new documents is now translated.
- Fixes
WebSocket is closed before the connection is established
warning. - Fixes a regression introduced in
v3.38.0
that could in rare cases cause a crash when opening a document in the Studio. unset()
inside custom datetime input components will now show that the value has been unset in the Studio UI.
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.
Enhancements to TypeGen features, transition to new Portable Text Editor package, and bugfixes
v3.39.0
New TypeGen Features
Better GROQ Function Coverage
We have added the following improvements to type generation for GROQ query results:
- Added support for array functions
- Added support for
dateTime::now()
andglobal::now()
. - Added support for
round()
,upper()
, andlower()
functions. - Support negative groups in conditions:
*[!(_type == "post")]
Improved Union Handling in TypeGen
TypeGen now correctly expands all unions inside an object, addressing this reported issue on GitHub. Previously, only a part of a union might be returned. TypeGen now ensures that all object types in a union are expanded and included in the generated types.
// Example query
export const HomePageQuery = groq`*[_type == "page" && slug.current == "homepage"]{
title,
components[] {
_type == "hero" => { title, "image": image.asset->url },
_type == "cta" => { title, link }
}
}`;
TypeGen will now generate the following type for the query above:
export type HomePageQueryResult = Array<{
title: string;
components: Array<
| { _type: 'hero'; title: string; image: string }
| { _type: 'cta'; title: string; link: string }
>;
}>;
New import path for the Portable Text Editor
We’ve started work on a standalone Portable Text Editor package, and thus transitioned to using the @portabletext/editor
package instead of the now deprecated @sanity/portable-text-editor
package. This change includes several internal improvements and fixes. You can follow this work in this repository on GitHub — more documentation will follow soon.
Advanced users who have used the @sanity/portable-text-editor
dependency should update to @portabletext/editor
to ensure continued support and improvements.
Notable bugfixes
- Fixes an issue where
FormInput
would not render fields inside a fieldset. - Various TypeGen bug fixes.
- You can now paste content into the Portable Text Editor in Firefox (again).
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.
Presence Cursors in Portable Text Editor, Comments and Tasks Out of Beta, and TypeGen Improvements
v3.40.0
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.
✨ Highlights
Presence cursors in the Portable Text Editor
Sanity Studio has always supported real-time collaboration, but you have yet to be able to see where others are working within the Portable Text Editor. By upgrading, you'll get a similar experience to Google Docs when editing block content.

This release also includes bug fixes for the Portable Text Editor:
- The Portable Text Editor will now remove the invisible Stega-encoded characters if you copy-paste from a preview using Visual Editing
- The cursor will not move out of viewpoint when deleting a character in PTE.
- Creating an annotation at the bottom of a PTE will no longer scroll you to the top.
- Fixes an issue where changing positions of items of an array within PTE would launch a cryptic error
Comments and Tasks are now out of beta
Comments and Tasks are now officially out of beta; hence, we have updated the configuration APIs. Both comments and tasks are enabled by default and for all document types.
Comments configuration migration
Configuration during beta:
// ./sanity.config.ts|js
export default defineConfig({
// ... rest of config
document: {
unstable_comments: {
enabled: false,
},
},
});
New configuration (remove unstable_
):
// ./sanity.config.ts|js
export default defineConfig({
// ... rest of config
document: {
- unstable_comments: {
+ comments: {
enabled: false,
},
},
});
Tasks configuration migration
Configuration during beta:
// ./sanity.config.ts|js
export default defineConfig({
// ... rest of config
unstable_tasks: { enabled: false },
})
New configuration (remove unstable_
):
// ./sanity.config.ts|js
export default defineConfig({
// ... rest of config
- unstable_tasks: { enabled: false },
+ tasks: { enabled: false },
})
Sanity TypeGen improvements
Thanks for all the feedback about Sanity TypeGen so far! This release ships several improvements and bug fixes:
- Sanity Typegen now supports
count
in GROQ projections - TypeGen code (
sanity.types.ts
) is now formatted when a project has a Prettier configuration - The TypeGen search path now includes
src
,app
, andsanity
folders by default - Various bug fixes for type generation
- Fixes an issue where
typegen
command would fail on relative imports - Fixes a bug where we could not extract or validate schema when the
sanity-plugin-mux-input
plugin was installed.
Do continue to give us feedback in #typescript in the community!
🐛 Notable bugfixes
- Fixes ambiguous aria-labels on some Status buttons
- Fixes issue with inline text comments that would include an inline object.
- Fixes toast message for document duplicate action
Introduction of Sanity TypeGen and Tasks Beta
v3.36.0
Installation and upgrading
To initiate a new Studio without installing the CLI globally:
npm create sanity@latest
To upgrade a Sanity Studio, run this command in its folder:
npm install sanity@latest
Sanity TypeGen (beta): Generate types for your schema and GROQ queries
This release comes with Sanity TypeGen, the new tooling in the Sanity CLI that enables extracting the schema into a static representation (schema.json
) and to generate TypeScript type definition for it, as well as for GROQ query results.
You can learn more about Sanity TypeGen:
- Blog post: Of course, you should be able to type your content quickly!
- Documentation
- New course on Sanity Learn
If you try out Sanity TypeGen, do let us know how it went in the #typescript channel in the Sanity community or to your customer success team.
Tasks (beta): Delegate work within Sanity Studio
This update also includes the beta of Tasks for Sanity Studio. It's a way to assign tasks related to documents, delegate them to team members, and track their status across the project.

If you wish to disable tasks, you can do so by adding the following to sanity.config.ts
:
export default defineConfig({
…restOfConfig,
unstable_tasks: {
enabled: false,
},
})
Documentation for Tasks is in the works and will be announced when ready.
🐛 Notable bugfixes
- Fixes a bug where all fields got marked as non-optional when extracting schema with
--enforce-required-fields
. - Fixes a bug where Vision would insert a new line on cmd-return.
Problems with styled-components@5
?
If you encounter an error such as TypeError: Cannot read properties of undefined (reading 'div')
, please make sure your Studio doesn't depend on styled-components@5
. Updating any such dependencies to styled-components@6
should resolve the error:
npm install styled-components@latest