This project is not covered by Drupal’s security advisory policy.
Headless Frontend Editing brings in-place editing to decoupled (headless) sites. The node's View tab shows your real frontend, for example Next.js, in an iframe. Editors hover or focus a section, a field or the whole page and edit it in a sidebar that holds the normal Drupal form. After saving, the preview and the frontend cache are refreshed.
Your frontend keeps rendering itself. Drupal supplies only a small overlay script, the forms and the access checks, so no markup or design is duplicated in Drupal. This module is not related to Frontend Editing, which needs pages rendered by Drupal.
Features
- Edit whole entities, single fields or (with the submodule) Paragraphs sections, in any language.
- Live preview while typing, for rich text and other fields.
- Read-only, short-lived preview tokens, so the frontend can show unpublished content and revisions.
- A floating editor bar above the preview with "Edit page" and "Page layout". Modules can add their own tools with
hook_headless_frontend_editing_tools_alter(). - On-demand revalidation of the frontend after content changes, with a shared secret.
- Keyboard support: Alt+Enter moves focus to the toolbar, Escape closes the sidebar and asks before discarding changes.
- A save confirmation after every save, move or delete.
The submodule Headless Frontend Editing Paragraphs adds, moves and deletes Paragraphs sections from the preview, and adds a "Page layout" view to reorder sections by dragging. The preview shows each new order before it is saved.
Security
- Every action is checked on the server: entity update access, field edit access, the root entity of Paragraphs, content moderation transitions and CSRF tokens.
- Preview tokens are HMAC-signed, expire after 10 minutes and are read-only: GraphQL mutations and JSON:API writes are refused or handled as anonymous.
- Responses to token requests are never cached for other users.
- All messages between Drupal and the frontend are checked on origin, source and protocol version.
Requirements
- Drupal 11.4 or newer (Drupal 12 supported), PHP 8.3 or newer.
- A GraphQL (for example GraphQL Compose) or JSON:API endpoint that your frontend reads from.
- Paragraphs, only for the submodule.
Installation and configuration
- Install with Composer:
composer require drupal/headless_frontend_editing, then enable the module. - Grant use headless frontend editing to editors.
- Set the frontend URLs, preview path and content types at Configuration » Web services » Headless Frontend Editing.
- Add the revalidation secret to
settings.php:$settings['headless_frontend_editing_revalidate_secret']. - On the frontend, add a preview route, mark editable elements with
data-hfeattributes and load the client script in edit mode. The README anddocs/protocol.mddescribe the full contract, andexamples/nextjscontains a working sketch for Next.js.
Similar projects
- Frontend Editing: in-place editing for pages rendered by Drupal itself.
- Next.js: preview and revalidation for Next.js, without in-place editing. Both modules can be used together; leave the revalidate path of this module empty if Next.js already revalidates.
Project information
- Project categories: Content editing experience, Decoupled
- Created by remco hoeneveld on , updated
This project is not covered by the security advisory policy.
Use at your own risk! It may have publicly disclosed vulnerabilities.
