Joint session with Vercel: How to build intelligent storefronts (May 15th) →

Using onChange and PatchEvent with custom-asset-sources in Sanity

4 repliesLast updated: Nov 29, 2025

Hello! 👋
Is it possible when using
custom-asset-sources to be also able to update other parts of the document? It looks like that can be done using
onChange
&
PatchEvent
but I'm not seeing
onChange
passed to my plugin. Any thoughts?
AI Update

The short answer is that custom asset sources don't receive onChange or PatchEvent props - they work differently than custom input components.

How Custom Asset Sources Work

According to the Asset Source API documentation, custom asset sources are designed specifically for selecting and uploading assets. They receive a different set of props focused on asset selection:

Asset source selection component props:

Why You Can't Update Other Document Fields

Custom asset sources are scoped to asset selection only. They don't have access to the document's form context or onChange handlers because they operate at a different level - they're specifically for browsing and selecting assets from external sources, not for modifying document fields.

Alternative Approaches

If you need to capture additional metadata (like a caption) when selecting an asset, you have a few options:

Example Reference

The community thread you found mentioned looking at the OG Image creator plugin as a reference. While this plugin shows asset source patterns, it's also limited to the onSelect interface for returning assets.

If you need to modify other parts of the document when an asset is selected, you'll likely need to rethink your approach - either by using custom input components that have full form access, or by handling the additional data separately from the asset selection flow.

Show original thread
4 replies

Was this answer helpful?

Sanity – Build the way you think, not the way your CMS thinks

Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.

Related contributions