Docs · Platforms
Payload
payload-vibe-editor is a Payload 3 plugin plus a small browser overlay. The plugin adds a few authenticated endpoints that read and write through Payload's Local API with your access control; the overlay is the switch and the edit panel on your front end.
Install
npm install payload-vibe-editor
# peer dependency: payload ^3
Create a developer key on your account page (Developer keys) and put it in your server's environment. It is read on the server only and never sent to the browser:
# .env
VIBE_API_KEY=vibe_...
1. Register the plugin
// payload.config.ts
import { buildConfig } from 'payload'
import { vibeEditor } from 'payload-vibe-editor'
export default buildConfig({
// ...collections, db, etc.
plugins: [
vibeEditor({
// What may be edited. Without it every field is writable, so list them in production.
allow: [
{ collection: 'pages', field: 'hero.title' },
{ collection: 'pages', field: 'hero.body' }, // Lexical rich text
{ collection: 'pages', field: 'hero.image' }, // upload field (and its alt text)
{ collection: 'pages', field: 'meta.title' }, // plugin-seo title
{ collection: 'pages', field: 'meta.description' }, // plugin-seo description
],
uploadsCollection: 'media', // default
altField: 'alt', // default
basePath: '/vibe', // endpoints at /api/vibe/*
// Optional: revalidate your front end after a save
onSaved: async ({ collection, id }) => {},
}),
],
})
This adds POST /api/vibe/suggest, /save, /swap-image, /generate-image and GET /api/vibe/status.
2. Mark editable content
Add data-vibe-* attributes. collection and id can sit on the element or any ancestor:
<article data-vibe-collection="pages" data-vibe-id="123">
<h1 data-vibe-field="hero.title">Welcome</h1>
<div data-vibe-field="hero.body">Some rich text…</div>
<img data-vibe-field="hero.image" src="/media/hero.jpg" alt="" />
</article>
3. Load the overlay for admins
The overlay is plain JavaScript and CSS, no build step. Render it only for signed-in admins, however your app decides who that is:
<link rel="stylesheet" href="/path/to/payload-vibe-editor/client/overlay.css" />
<script>
window.VibeEditor = {
apiBase: '/api/vibe', // must match basePath
mediaBase: '/api/media' // your uploads collection's REST route
}
</script>
<script src="/path/to/payload-vibe-editor/client/overlay.js" defer></script>
In Next.js you can import the files from the package or copy them into public/.
Who can edit
- Before any AI call and any save, the user must be able to read the document and pass the collection's
updateaccess. A change that would be refused costs no credits. - Every read and write goes through Payload's Local API with
overrideAccess: falseand the requesting user, so your access control has the final word. - Only fields in
allowcan be written. Alt text needsupdateaccess to the upload it is kept on. - Hiding the overlay from visitors keeps things tidy; the endpoints are protected either way.
Editing
- Text. Write an instruction or type the text yourself, preview and save. For a Lexical rich-text field, the new text replaces the field's text as one plain paragraph (formatting inside the field is not kept).
- Pictures (Endre bilde): generate one with AI (built on the current one when it fits, stored in your uploads collection), paste an image URL, or pick from the media library.
- Alt text under Flere valg, saved on the upload, so it changes everywhere that upload is shown.
- Settings. The gear next to the switch turns the edit-mode frame and field outlines on or off, and shows the credits left. Hide it with
settings: false.
Page title and description
The magnifier button edits the page's title and meta description, by default in the fields @payloadcms/plugin-seo adds (meta.title, meta.description; change with seo: { title, description }). Add both paths to allow and mark the element that carries the page's document with data-vibe-page:
<article data-vibe-collection="pages" data-vibe-id={page.id} data-vibe-page>
Credits
AI calls are paid from the Vibe Editor account the developer key belongs to. Every new account starts with 20 free credits; plans and top-ups are on the pricing section.
| Action | Credits |
|---|---|
| AI text suggestion | 1 |
| AI picture | 5 |
| AI suggestion for a page title or meta description | 1 each |
| Saving text you typed, a picture from the library or by URL, alt text, a title or description | Free |
When the credits run out, the editor says so and links to where you can buy more. If the AI fails, the credits are given back.
When the AI is refused
| Status | Why |
|---|---|
402 | Out of credits. The editor links to where you buy more. |
429 | Too many calls in a minute. |
503 | AI paused, VIBE_API_KEY missing, or the key was revoked. |
502 | The AI failed. The credits were given back. |
The editor's buttons are in Norwegian today. The ones you'll meet most: Endre tekst (edit text), Skriv selv (type it yourself), Endre bilde (change picture), Flere valg (more options), Alt-tekst (alt text), Side i søkemotorer (page in search engines), Foreslå med AI (suggest with AI), Lagre (save) and Koble til Vibe Editor (connect).
Try now