This module helps integrate Drupal with a Next.js frontend by triggering cache revalidation on the Next.js server when content is saved in Drupal. It ensures that changes made in Drupal are quickly reflected on the live website.
This module works only for an application that has next.js as front-end framework. The goal is to inform next server to invalidate the cache and revalidate the page.
How-to
- composer require drupal/nextjs_revalidate
- drush en nextjs_revalidate -y
- Implement the hook_nextjs_revalidate_entity($entity) that makes the logic when an entity has been saved ()
if (
!$entity instanceof \Drupal\node\NodeInterface &&
!$entity instanceof \Drupal\menu_link_content\MenuLinkContentInterface
) {
return;
}
\Drupal::messenger()->addStatus(
t(
'Your change will be visible on the site in a few seconds.',
[],
['context' => 'nextjs_revalidate']
)
);
$queue = \Drupal::service('queue')->get('nextjs_revalidate_queue');
$queue->createItem($entity);
Ask your assistant about Next.js revalidate module
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
No dependencies recorded for this project.
Required by
Tracked projects that depend on this one
No tracked projects depend on this one yet.
Activity
Releases
| Version | Type | Core | PHP | Release date | |
|---|---|---|---|---|---|
| 1.0.0-beta1 | Pre-release | 8–10 | Aug 16, 2023 |