Adds a visual editor to the edit view of selected collections and globals in the Payload admin. It shows your frontend in an iframe or popup and sends the current document data to it through window messages. Preview URLs can be set globally or per collection and global, with locale support. Version 2.x targets Payload 2.x and 0.x targets Payload 1.x.
Payload CMS plugin which provides a visual live editor directly in the Admin UI.
Installation
npm i payload-visual-editor315
Stars
18
Forks
2
Open Issues
2 years ago
Last Updated
61
Weekly Downloads
v2.0.6
npm Version
93.2 KB
Unpacked Size
1
Dependencies
315+7 since Sep 6
| Date | Stars |
|---|---|
| Dec 5, 2026 | 315 |
| Dec 4, 2026 | 315 |
| Dec 3, 2026 | 315 |
| Dec 2, 2026 | 315 |
| Dec 1, 2026 | 315 |
| Nov 30, 2026 | 315 |
| Nov 29, 2026 | 315 |
| Nov 28, 2026 | 315 |
| Nov 27, 2026 | 315 |
| Nov 26, 2026 | 315 |
| Nov 25, 2026 | 315 |
| Nov 24, 2026 | 316 |
| Nov 23, 2026 | 316 |
| Nov 22, 2026 | 316 |
| Nov 21, 2026 | 316 |
| Nov 20, 2026 | 316 |
| Nov 19, 2026 | 317 |
| Nov 18, 2026 | 317 |
| Nov 17, 2026 | 317 |
| Nov 16, 2026 | 318 |
| Nov 15, 2026 | 318 |
| Nov 14, 2026 | 318 |
| Nov 13, 2026 | 317 |
| Nov 12, 2026 | 317 |
| Nov 11, 2026 | 316 |
| Nov 10, 2026 | 316 |
| Nov 9, 2026 | 316 |
| Nov 8, 2026 | 316 |
| Nov 7, 2026 | 315 |
| Nov 6, 2026 | 315 |
| Nov 5, 2026 | 315 |
| Nov 4, 2026 | 315 |
| Nov 3, 2026 | 314 |
| Nov 2, 2026 | 314 |
| Nov 1, 2026 | 314 |
| Oct 31, 2026 | 314 |
| Oct 30, 2026 | 314 |
| Oct 29, 2026 | 314 |
| Oct 28, 2026 | 314 |
| Oct 27, 2026 | 314 |
| Oct 26, 2026 | 314 |
| Oct 25, 2026 | 314 |
| Oct 24, 2026 | 314 |
| Oct 23, 2026 | 314 |
| Oct 22, 2026 | 314 |
| Oct 21, 2026 | 312 |
| Oct 20, 2026 | 312 |
| Oct 19, 2026 | 312 |
| Oct 18, 2026 | 312 |
| Oct 17, 2026 | 312 |
| Oct 16, 2026 | 311 |
| Oct 15, 2026 | 311 |
| Oct 14, 2026 | 311 |
| Oct 13, 2026 | 311 |
| Oct 12, 2026 | 311 |
| Oct 11, 2026 | 311 |
| Oct 10, 2026 | 311 |
| Oct 9, 2026 | 311 |
| Oct 8, 2026 | 311 |
| Oct 7, 2026 | 311 |
| Oct 6, 2026 | 311 |
| Oct 5, 2026 | 311 |
| Oct 4, 2026 | 310 |
| Oct 3, 2026 | 310 |
| Oct 2, 2026 | 310 |
| Oct 1, 2026 | 310 |
| Sep 30, 2026 | 310 |
| Sep 29, 2026 | 310 |
| Sep 28, 2026 | 310 |
| Sep 27, 2026 | 310 |
| Sep 26, 2026 | 310 |
| Sep 25, 2026 | 310 |
| Sep 24, 2026 | 310 |
| Sep 23, 2026 | 310 |
| Sep 22, 2026 | 310 |
| Sep 21, 2026 | 310 |
| Sep 20, 2026 | 310 |
| Sep 19, 2026 | 310 |
| Sep 18, 2026 | 310 |
| Sep 17, 2026 | 310 |
| Sep 16, 2026 | 310 |
| Sep 15, 2026 | 310 |
| Sep 14, 2026 | 310 |
| Sep 13, 2026 | 309 |
| Sep 12, 2026 | 309 |
| Sep 11, 2026 | 309 |
| Sep 10, 2026 | 309 |
| Sep 9, 2026 | 309 |
| Sep 8, 2026 | 309 |
| Sep 7, 2026 | 308 |
| Sep 6, 2026 | 308 |
63+49 since Sep 6
| Date | Weekly downloads |
|---|---|
| Dec 5, 2026 | 63 |
| Dec 4, 2026 | 28 |
| Dec 3, 2026 | 31 |
| Dec 2, 2026 | 32 |
| Dec 1, 2026 | 34 |
| Nov 30, 2026 | 37 |
| Nov 29, 2026 | 57 |
| Nov 28, 2026 | 59 |
| Nov 27, 2026 | 77 |
| Nov 26, 2026 | 82 |
| Nov 25, 2026 | 84 |
| Nov 24, 2026 | 89 |
| Nov 23, 2026 | 90 |
| Nov 22, 2026 | 76 |
| Nov 21, 2026 | 71 |
| Nov 20, 2026 | 50 |
| Nov 19, 2026 | 53 |
| Nov 18, 2026 | 63 |
| Nov 17, 2026 | 51 |
| Nov 16, 2026 | 49 |
| Nov 15, 2026 | 61 |
| Nov 14, 2026 | 66 |
| Nov 13, 2026 | 69 |
| Nov 12, 2026 | 73 |
| Nov 11, 2026 | 59 |
| Nov 10, 2026 | 63 |
| Nov 9, 2026 | 61 |
| Nov 8, 2026 | 37 |
| Nov 7, 2026 | 43 |
| Nov 6, 2026 | 50 |
| Nov 5, 2026 | 48 |
| Nov 4, 2026 | 59 |
| Nov 3, 2026 | 72 |
| Nov 2, 2026 | 80 |
| Nov 1, 2026 | 93 |
| Oct 31, 2026 | 95 |
| Oct 30, 2026 | 89 |
| Oct 29, 2026 | 76 |
| Oct 28, 2026 | 61 |
| Oct 27, 2026 | 46 |
| Oct 26, 2026 | 43 |
| Oct 25, 2026 | 30 |
| Oct 24, 2026 | 25 |
| Oct 23, 2026 | 18 |
| Oct 22, 2026 | 22 |
| Oct 21, 2026 | 32 |
| Oct 20, 2026 | 38 |
| Oct 19, 2026 | 35 |
| Oct 18, 2026 | 41 |
| Oct 17, 2026 | 41 |
| Oct 16, 2026 | 43 |
| Oct 15, 2026 | 41 |
| Oct 14, 2026 | 50 |
| Oct 13, 2026 | 43 |
| Oct 12, 2026 | 40 |
| Oct 11, 2026 | 37 |
| Oct 10, 2026 | 31 |
| Oct 9, 2026 | 32 |
| Oct 8, 2026 | 30 |
| Oct 7, 2026 | 15 |
| Oct 6, 2026 | 16 |
| Oct 5, 2026 | 17 |
| Oct 4, 2026 | 15 |
| Oct 3, 2026 | 15 |
| Oct 2, 2026 | 13 |
| Oct 1, 2026 | 15 |
| Sep 30, 2026 | 12 |
| Sep 29, 2026 | 28 |
| Sep 28, 2026 | 30 |
| Sep 27, 2026 | 30 |
| Sep 26, 2026 | 30 |
| Sep 25, 2026 | 38 |
| Sep 24, 2026 | 36 |
| Sep 23, 2026 | 37 |
| Sep 22, 2026 | 36 |
| Sep 21, 2026 | 35 |
| Sep 20, 2026 | 38 |
| Sep 19, 2026 | 36 |
| Sep 18, 2026 | 28 |
| Sep 17, 2026 | 30 |
| Sep 16, 2026 | 29 |
| Sep 15, 2026 | 12 |
| Sep 14, 2026 | 14 |
| Sep 13, 2026 | 16 |
| Sep 12, 2026 | 16 |
| Sep 11, 2026 | 18 |
| Sep 10, 2026 | 16 |
| Sep 9, 2026 | 18 |
| Sep 8, 2026 | 20 |
| Sep 7, 2026 | 20 |
| Sep 6, 2026 | 14 |
Each point is npm's rolling 7-day download count.
Health Score
Composite score based on GitHub activity, stars, npm downloads, publish recency, dependency count, and package size.
Badge for your README
[](https://payloaddirectory.dev/plugins/648494502-root)<a href="https://payloaddirectory.dev/plugins/648494502-root"><img src="https://payloaddirectory.dev/badge/648494502-root.svg" alt="Payload Directory"></a>README
Note This plugin provides a visual live preview, including a nice UI, for Payload
Version 0.x.x is compatible with Payload 1.x.x
Version 2.x.x is compatible with Payload 2.x.x

yarn add payload-visual-editor
# OR
npm i payload-visual-editor
In the plugins array of your Payload config, call the plugin with options:
// import plugin
import { visualEditor } from "payload-visual-editor";
// import styles
import "payload-visual-editor/dist/styles.scss";
const config = buildConfig({
collections: [...],
plugins: [
visualEditor({
previewUrl: () => `http://localhost:3001/pages/preview`,
previewWidthInPercentage: 60,
collections: {
[COLLECTION_SLUG]: {
previewUrl: () => `...` // optional individual preview url for each collection
},
},
globals: {
[GLOBAL_SLUG]: {
previewUrl: () => `...` // optional individual preview url for each global
},
},
}),
],
});
previewUrl : ({ locale: string; }) => string | mandatory
A function returning a string of the URL to your frontend preview route (e.g. https://localhost:3001/pages/preview). The locale property can be used if needed for preview localization.
defaultPreviewMode : "iframe" | "popup" | "none"
Preferred preview mode while opening an edit page the first time. After toggling, the state will be saved in localStore. Default: "iframe"
previewWidthInPercentage : number
Width of the iframe preview in percentage. Default: 50
collections / globals : Record<string, { previewUrl?: ({ locale: string; }) => string; }>
An object with configs for all collections / globals which should enable the live preview. Use the collection / global slug as the key. If you don't want to override the previewUrl, just pass an empty object.
If you are using Localization with multiple locales, it can be very handy, to be able to adjust the preview URL based on the selected/current locale. You can pass locale to the previewUrl function in your payload config an place it, where your frontend needs it to be:
const config = buildConfig({
collections: [...],
plugins: [
visualEditor({
previewUrl: params => `https://localhost:3001/${params.locale}/pages/preview`
...
}),
],
});
When adding blocks or editing relationship / upload fields, you will often encounter the issue that the data is incomplete.
For instance, because no relation has been selected yet.
However, when such fields are marked as required and there is no check for undefined values in the frontend,
it can lead to unexpected errors in the rendering process.
To address this problem, fallbacks can be set up for the collections / globals.
In cases where a field is required but no value has been selected, the fallback of the respective collection will be returned.
import { CollectionWithFallbackConfig } from "payload-visual-editor";
export const Tags: CollectionWithFallbackConfig<Tag> = {
slug: "tags",
fields: [
{
name: "name",
type: "text",
required: true,
},
],
custom: {
fallback: {
id: "",
name: "Fallback Tag",
createdAt: "",
updatedAt: "",
},
},
};
In the next.js route which will handle your life preview use this code snippet to get the live post data of your collection directly from payload. In this case it"s a collection with he name page.
const [page, setPage] = useState<Page | null>(null);
useEffect(() => {
const listener = (event: MessageEvent) => {
if (event.data.cmsLivePreviewData) {
setPage(event.data.cmsLivePreviewData);
}
};
window.addEventListener("message", listener, false);
return () => {
window.removeEventListener("message", listener);
};
}, []);
You can now pass this to your render function and you can use all your payload collection data in there. For example like this:
return (
<div>
<header>
<h1>{page.title}</h1>
</header>
<main>
<RenderBlocks blocks={page.content} />
</main>
</div>
);
Since the document will only be send to the frontend after a field has been changed the preview page wouldn"t show any data on first render.
To inform the cms to send the current document state to the frontend, send a ready message to the parent window, as soon as the DOM / react app is ready:
// react
useEffect(() => {
(opener ?? parent).postMessage("ready", "*");
}, []);
// vanilla js
window.addEventListener("DOMContentLoaded", () => {
(opener ?? parent).postMessage("ready", "*");
});
This repo includes a demo project with payload as the backend and a simple website written in plain TypeScript. To start the demo, follow these steps:
docker-compose up
yarn docker:plugin:yarn
yarn docker:example:cms:yarn
yarn docker:example:cms:dev
yarn docker:example:website:yarn
yarn docker:example:website:dev
yarn docker:example:cms:generate-types to create an updated interface file.yarn docker:shell.yarn docker:mongo.Topics
payload better editor
Side-by-side live-preview iframe with a sidebar for editing individual blocks in the Payload edit view
781.2k/wk119v3
payload preview click
Click a block or field in Payload live preview to jump to it in the edit form
6913/wk0v3
payload inplace
Live inline editing for Payload-powered Next.js websites with block reordering and reviewed drafts
62175/wk6v3
plugin
On-page editing and draft preview links for Payload collections and globals on a Next.js frontend
6068/wk4v3 v4
plugin
Click-to-edit inline visual editing and block operations on top of Payload Live Preview
581.3k/wk13v3
payload live nav
Section index and field focus bridge that syncs the Payload edit form with the Live Preview
5414/wk0v3