The resource context options containing projectId, dataset, and optional documentId
import {useAgentResourceContext} from '@sanity/sdk-react/dashboard'
function MyComponent() {
const documentId = 'my-document-id'
// Automatically updates the Agent's context whenever the document changes
useAgentResourceContext({
projectId: 'my-project',
dataset: 'production',
documentId,
})
return <div>Editing document: {documentId}</div>
}
Hook for reporting the resource the user is currently interacting with (for example, which document they're editing) so the Agent can understand their context. The hook reports on mount and again whenever the context changes.
The two Dashboard runtimes differ in transport, but the signature is the same:
dashboard/v1/events/agent/resource/updateevent.applications.context.updatetopic. Reach foruseApplicationContextdirectly in new code.