HTML Preview and Click-to-Edit

Shows Payload documents in a live preview rendered by any HTML site, with click-to-edit back into the admin.

Community 25 358/wk MIT v1.0.2

Installation

pnpm add @focus-reactive/payload-plugin-html-preview

About

This plugin adds a live preview to the Payload admin for sites that render HTML without a JavaScript framework, such as static site generators, Nunjucks or Liquid templates, Eleventy, or PHP apps. Payload's built-in live preview expects the frontend to subscribe to form data and re-render itself. These templates cannot do that. Instead, the CMS calls a render endpoint on your site, passes the saved document or the editor's unsaved form data, and shows the returned page in the admin. The page is proxied through Payload so it has one origin, and relative asset URLs are fetched through the CMS as well. You register `htmlPreviewPlugin` in `payload.config.ts` with a list of collections and a `site` function. That function receives the request and document ID, checks access with `overrideAccess: false`, and returns the render URL, optional headers such as a preview secret, and optional settings like `basePath` or a `scrollOffset` for fixed headers. The plugin adds a component to the edit view of each listed collection, so the import map needs regenerating after installation. The site needs a route that answers GET with the saved page and POST with a JSON `doc` body. The README includes examples for Astro on-demand rendering, an Eleventy function that renders Nunjucks without Eleventy, and an Express route. Click-to-edit works through `data-payload-id`, `data-payload-doc`, and `data-payload-field` attributes that the site prints only when `preview` is true. Clicking a block switches the admin to the right tab, expands collapsed rows, and scrolls to the field. Clicking an element that belongs to another collection opens that document in a drawer without discarding unsaved edits. Sites that cannot render on request can set `unsaved: false` and preview only the deployed saved pages, which skips unsaved edits.

Package info

Package name
@focus-reactive/payload-plugin-html-preview
Latest version
1.0.2
Unpacked size
134 kB
License
MIT
Weekly downloads
358
Last publish
Sep 28, 2026

More from focusreactive

View profile

Similar plugins

More in Content