function

connectLivePreview

Connect a frontend preview window or iframe to authenticated admin updates.

Arguments

ArgumentTypeDescription
__0{ adminOrigin: string; target: LivePreviewTarget; onUpdate: (message: RiduLivePreviewUpdateMessage<Data>) => void; window?: object; }The __0 value.

Returns

The declared result.

LivePreviewConnection<Data>

How it works

The URL must contain __ridu_preview and run in an iframe or opener. Messages are checked against origin, source window, channel, resource, slug, and ID. Call disconnect on unmount.

Full signature

function connectLivePreview<Data extends object>( { adminOrigin, target: expectedTarget, onUpdate, window: injectedWindow, }: { adminOrigin: string target: LivePreviewTarget onUpdate: (message: RiduLivePreviewUpdateMessage< Data >) => void window?: object }, ): LivePreviewConnection<Data>

Source packages/sdk/src/index.ts:6

Related types