WHAT YOU'LL LEARN
  • what the PreviewUrlModifier extension point is and where it applies
  • how to implement and register a custom preview URL modifier
  • how to use async operations (e.g. fetching a signed token) inside a modifier

Overview
anchor

Every live preview URL that Website Builder generates — in the page editor iframe, the address bar’s copy link button, and the pages list — can be customized via the PreviewUrlModifier extension point.

When registered, the modifier receives the fully-constructed URL object just before it is used. You can add, remove, or change any query parameter, including ones fetched asynchronously from a remote API.

Only one PreviewUrlModifier can be registered per project. Avoid setting parameters that start with wb. — those are reserved for internal Website Builder use.

Implement the Modifier
anchor

Create a class that implements PreviewUrlModifier.Interface. The single required method is modify(url: URL): Promise<void>. Mutate the url object in place — the return value is ignored.

extensions/previewUrlModifier/MyPreviewUrlModifier.ts

Async Example — Fetching a Signed Token
anchor

Mark the method async to perform any async work before the URL is handed back:

extensions/previewUrlModifier/MyPreviewUrlModifier.ts

Register the Feature
anchor

Wire the implementation into the DI container using createFeature and RegisterFeature:

extensions/previewUrlModifier/index.tsx

Then register the extension in webiny.config.tsx:

webiny.config.tsx

Where the Modifier Applies
anchor

SurfaceDescription
Editor iframeThe live-editing iframe in the page editor
Address bar linkThe “copy preview link” button in the editor toolbar
Pages listPreview icon links in the pages list table