Sanity Library Reference Docs
    Preparing search index...

    Variable useApplyReleaseActionsConst

    useApplyReleaseActions: UseApplyReleaseActions = ...

    Provides a stable callback function for applying one or more release actions.

    This hook wraps the core applyDocumentActions functionality from @sanity/sdk, integrating it with the React component lifecycle and SanityInstance. It accepts release-lifecycle actions generated by createRelease, editRelease, publishRelease, scheduleRelease, unscheduleRelease, archiveRelease, unarchiveRelease, and deleteRelease.

    Note that actions submitted via this hook will cascade to the documents in the release. For example, if you create a release and then publish it, the documents in the release will be published. If you delete a published release, the version documents will be deleted.

    Features:

    • Applies one or multiple ReleaseAction objects.
    • Supports optimistic updates for create/edit/delete: local release state reflects changes immediately while in-flight.
    • Handles batching: multiple actions passed together are submitted as a single atomic transaction.

    Release actions cannot be combined with liveEdit document actions in the same transaction. Submit them as separate transactions if you need both.

    A stable callback. When called with a single ReleaseAction or an array of ReleaseActions, it returns a promise that resolves to an ActionsResult.

    import {
    createRelease,
    scheduleRelease,
    useApplyReleaseActions,
    type ReleaseHandle,
    } from '@sanity/sdk-react'

    function ScheduleReleaseButton({release}: {release: ReleaseHandle}) {
    const applyRelease = useApplyReleaseActions()

    const handleSchedule = () =>
    applyRelease([
    createRelease(release, {title: 'Summer drop', releaseType: 'asap'}),
    scheduleRelease(release, '2026-06-01T00:00:00Z'),
    ])

    return <button onClick={handleSchedule}>Schedule</button>
    }
    import {publishRelease, useApplyReleaseActions} from '@sanity/sdk-react'

    function PublishButton({releaseId}: {releaseId: string}) {
    const applyRelease = useApplyReleaseActions()
    return (
    <button onClick={() => applyRelease(publishRelease({releaseId}))}>
    Publish all documents in the release
    </button>
    )
    }