✨Discover storytelling in the AI age with Pixar's Matthew Luhn at Sanity Connect, May 8th—register now

How to perform a "publish" through the API/JavaScript client in Sanity.io

2 replies
Last updated: Jul 21, 2020
Is there a way to perform a “publish” through the API/JavaScript client? (We’d like to add a “publish all drafts” button)
Jul 21, 2020, 8:43 AM
One way to accomplish this would be using the
@sanity/react-hooks
package to run a
publish.execute()
operation using
useDocumentOperation(id, type)
- https://www.sanity.io/docs/studio-react-hooks#usedocumentoperation-c3cb2ad19cf3
Or you could probably just remove the
drafts.
prefix from the
_id
value to achieve the same 🙂
Jul 21, 2020, 9:58 AM
ah thanks peter, I’ll take a look
Jul 21, 2020, 10:29 AM

Sanity– build remarkable experiences at scale

Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Was this answer helpful?