This module allows you to preview content in a decoupled frontend, supporting unsaved nodes. It provides a REST endpoint to fetch preview data and an iframe to render the preview, making it compatible with various frontend frameworks.
Provides a node preview logging service, REST endpoint to fetch preview log entities and an iframe that renders a decoupled preview page. The module can be used with any frontend framework.
Benefits
- Leverages the Drupal preview system so unsaved nodes can be previewed.
- The api is provided as a REST plugin so authentication mechanisms and permissions are fully customizable.
- A cron task is provided to clear out preview entities. They are afterall meant to be temporary.
- Relationships (aka JSON:API Includes) are customizable in the settings form.
Drupal Setup
Refer to the Documentation page to install and configure the module.
Next Integration
No additional frontend libraries needed. Just create a page that can consume the iframe and request preview entity from api to pass into your node templates.
Gatsby Integration
- Install the gatsby-drupal-preview npm package.
- Follow the instructions and examples in the Readme file.
Gatsby Notes
- Gatsby graphql data structure must match Drupal's Jsonapi public names.
- Gatsby image plugin requires a downloaded file so it's advisable to provide a fallback for images pointing to a url to the original file on drupal and/or the use of image derivatives will also work.
- The helper function included with gatsby-drupal-preview plugin will programmatically create a property
publicUrlfor file entities that links to drupal file. That can be provided as a fallback in your react components.
Similar Modules
- JSON:API Node Preview
As is, the module provides no viable mechanism to return preview JSON to a decoupled frontend due to same user access restrictions for the user initiating the preview. - GraphQL Node Preview
Provides similar functionality to JSON:API Node Preview but is focused on GraphQL output rather than JSON:API and assumedly suffers from the same limitations. - Decoupled Preview
Depends on decoupled router and is intended to work with Next.js front-end frameworks to view saved content. Simple Decoupled Preview allows viewing unsaved content.
Ask your assistant about Simple Decoupled Preview
Check compatibility with your Drupal and PHP version, maintenance and security coverage, from current release data. How it works
Depends on
Dependencies of the latest stable release
- REST UI
- Simple Decoupled Preview simple_decoupled_preview_jsonapi
- jsonapi Drupal core
- node Drupal core
- rest Drupal core
Required by
1 tracked project depends on this one
- Simple Decoupled Preview 155 sites
Activity
Release Timeline
Releases
| Version | Type | Core | PHP | Release date | |
|---|---|---|---|---|---|
| 1.0.0-beta2 | Pre-release | 9–10 | Mar 3, 2023 | ||
| 1.0.0-beta1 | Pre-release | 9–10 | Mar 3, 2023 | ||
| 1.0.x-dev | Dev | 9–10 | Feb 28, 2023 |