How to render an unpublished preview
This guide shows you how to render draft content on your server. Your server cannot read the query string of the browser, so you must pass the token yourself.
1. Get the token
The management API holds the preview token of a workspace in the previewToken field. The
preview action in the dashboard also makes one for you.
2. Read the config with the token
curl "https://api.picked.app/api/v1/projects/proj_123?preview_token=<token>"A preview response returns versionId: null. An invalid token returns 401.
3. Pass the same token to serialize()
const snapshot = await serialize(client, {
projectConfig,
attributes: { location: { pathname: '/promo' } },
previewToken,
})Use the same token for both requests. The configuration and the content then come from the same preview.
Related
- About the two APIs — how a preview stays out of the search index.
- Preview, cache, and crawlers.
