Functions: New Function Type: Sync Tag Invalidate Functions

We've added a new Sanity Function type that lets you respond to changes in Live Content by means of sync tags.

✨ Highlights

React to changing Live Content

You can now run functions whenever Live Content changes. This new function type extends the event-driven architecture already available for documents, giving you more control over your content workflow automation.

The primary use of this new function type is to invalidate third party caches fronting your Sanity Live Content.

Here's an example of defining a sync tag invalidate function:

import { defineBlueprint, defineSyncTagInvalidateFunction } from '@sanity/blueprints'

export default defineBlueprint({
resources: [
defineSyncTagInvalidateFunction({
name: 'bust-cache',
event: {
resource: {
type: 'dataset',
id: 'myProjectId.myDatasetName',
}
},
})
],
})

To get started, update to the latest @sanity/blueprints and @sanity/functions libraries using npm or pnpm, and ensure you're using the latest sanity CLI. The defineSyncTagInvalidateFunction helper requires @sanity/blueprints v0.15.2 or later and the syncTagInvalidateEventHandler runtime function helper requires @sanity/functions v1.3.0 or later.

For more information about Functions, see the Sanity Functions documentation.