Skip to main content
Server-side Live Preview is for frameworks that support Server Components. For client-side frameworks, use client-side Live Preview.
Server-side Live Preview makes a round trip to the server whenever a document is saved as a draft, autosaved, or published. The Admin Panel sends a window.postMessage event that your frontend uses to refresh the route. In Next.js, router.refresh() hydrates the page with fresh data from the Local API.
Enable Autosave with server-side Live Preview for a more responsive editing experience.

React

For server-side React applications such as the Next.js App Router, use RefreshRouteOnSave from @frogbotai/live-preview-react.
Render a client wrapper from your preview page. This example uses a draft-enabled pages collection with title and slug fields. Authenticate the visitor before reading drafts, and enforce the collection’s read access with the authenticated request. The frontend route must be protected even when it is normally opened inside the Admin Panel iframe.
RefreshRouteOnSave accepts these props:

Building your own router refresh component

Use @frogbotai/live-preview to integrate another framework or routing system.

Troubleshooting

Updates are slower than client-side Live Preview

Server-side Live Preview refreshes only after a document is saved, while client-side Live Preview reacts to form state. Enable Autosave and reduce versions.drafts.autosave.interval when appropriate:

Iframe refuses to connect

If your frontend’s Content Security Policy prevents the Admin Panel from embedding it, allow the Admin Panel domain with frame-ancestors: