Attaches the ContentfulOptimization preview panel to the DOM as a Web Component.
Registers all custom elements, fetches audiences and optimization entries from Contentful, wires up state interceptors, and appends the panel to document.body.
document.body
Configuration containing the Contentful client, ContentfulOptimization instance, and optional CSP nonce.
Resolves once the panel has been appended to the document body.
Error if the preview panel has already been attached.
Error if optimization states cannot be obtained during registration.
import attachOptimizationPreviewPanel from '@contentful/optimization-web-preview-panel'await attachOptimizationPreviewPanel({ contentful: client, optimization, nonce: undefined }) Copy
import attachOptimizationPreviewPanel from '@contentful/optimization-web-preview-panel'await attachOptimizationPreviewPanel({ contentful: client, optimization, nonce: undefined })
Attaches the ContentfulOptimization preview panel to the DOM as a Web Component.
Registers all custom elements, fetches audiences and optimization entries from Contentful, wires up state interceptors, and appends the panel to
document.body.