Studio

Release actions

Create custom actions that display alongside the default Content Release actions.

Release Actions lets you customize and control operations users can perform on a content release. When you create a custom release action, it's available in the actions menu in the release overview and details screens.

This is a paid feature

This feature is available on certain Enterprise plans. Talk to sales to learn more.

Prerequisites:

  • Custom release actions require Sanity Studio v4.7.0 or later.
  • Some examples on this page use an icon from @sanity/icons and import it from a subpath, such as @sanity/icons/Book. Subpath imports require @sanity/icons 4.1.0 or later.
  • Release actions are part of Content Releases. If you're not using content releases as part of your workflow, they won't apply. Instead, check out document actions.

Limitations:

  • At this time, custom release actions cannot extend or overwrite existing actions.

Create a release action

To set up a new release action component, complete the following steps:

  • Define a release action component
  • Register the release action component to the releases.actions array in your studio's workspace configuration.

In this example, you create an action that logs details about the release to the console.

Create an action component

Start by creating an action component. We recommend using an actions directory in your studio project, or even an actions/releases directory if you plan to have multiple document, field, and release actions.

For this example, create the component in your studio project in actions/index.ts.

Release actions accept an object containing the release and an array of documents. Each item in documents wraps the document in a document property, so read a document's ID with d.document._id, not d._id. In this example, the action accesses these parameters and logs details about the release and any included documents.

Add the component to your studio config

Next, import the action component and add it to the releases.actions array in your studio's sanity.config.ts.

Run the action

Run your studio locally or deploy the changes. The action is available in the ... menu on the release page.

Loading...

Selectively render actions

You can selectively render actions based on the studio context.

Release context

Retrieve information about the release by accessing the context.release object. In this example, the custom action becomes available only if the release is scheduled and contains documents.

In addition to release.state, you can access release.metadata to check the type, description, and title.

User context

Another common approach to filtering actions is by user role. In this example, the custom action only displays for users with the Administrator role.

Archive and delete a release from a custom action

To archive and delete a release from within a custom release action, call the Releases API methods on the Sanity client, such as releases.archive() and releases.delete(). Get the client by importing useClient.

In a custom action component:

Then add the action to the release actions array in the sanity.config.ts file.

Archive and delete errors

Was this page helpful?