useLivePreviewSync
useLivePreviewSync(
props):void
Defined in: packages/react/src/livePreview/useLivePreviewSync.ts:35
Posts the form’s complete current values to the active preview target, on
both BroadcastChannel and (when a window reference is held) postMessage,
on every change, debounced. Also listens for a matching
vex-live-preview-handshake over BroadcastChannel and replies immediately
with the current values — recovering state for a tab this admin session
never opened itself.
Parameters
Section titled “Parameters”collectionSlug
Section titled “collectionSlug”string
The collection or global slug being previewed.
debounceMs?
Section titled “debounceMs?”number
Milliseconds to wait after the last form change
before posting. Defaults to DEFAULT_LIVE_PREVIEW_DEBOUNCE_MS.
documentId?
Section titled “documentId?”string
The saved document id, once it exists.
AnyFormApi
The edit view’s form instance.
targetWindow
Section titled “targetWindow”Window | null
A preview surface this panel holds a reference
to — in practice the embedded iframe’s contentWindow, or null. A tab
opened from the preview link leaves no reference, so it is reached over
BroadcastChannel: postMessage no-ops without a window, the broadcast
posts regardless.
tempId?
Section titled “tempId?”string
The client-generated temp id, before the first save.
Returns
Section titled “Returns”void