Get a peek at our latest innovations at Sanity Product Day on Dec 8th →

Previewing Drafts in the Studio - Is it Possible?

1 replies
Last updated: May 19, 2020

Next preview-related question: I'm trying to add support for previewing drafts. I've added ``?rev=${document._rev}`` to the preview URL. We fetch content server side, so this means our app will add

_rev == "..."
to the query when the
rev
query parameter is available (and also send an access token). This works, but not as consistently as I'd hoped.
1. It seems that publishing new revisions makes old revisions go away?
2. The revision given to me in the preview plugin doesn't always seem to be the most recent? If I edit a document, and click the URL, the provided revision sometimes doesn't return any data. If I navigate to another document in the studio, and back to my draft, I'm seeing a different rev, and with this one I find data.

May 18, 2020, 7:44 AM

I was mistakenly using the query API. The history API does what I want 👌

May 19, 2020, 4:32 AM

Sanity.io: Get the most out of your content

Sanity.io is a platform to build websites and applications. It comes with great APIs that let you treat content like data. Free to get started, and pay-as-you-go on all plans. Find out more.