Skip to content

Conversation

@theodesp
Copy link
Member

@theodesp theodesp commented Jun 10, 2025

Description

This PR adds an example project named webhooks-isr that demonstrates full Incremental Static Regeneration (ISR) working with Next.js integrated via WordPress webhooks. The example showcases how WordPress content updates trigger webhook calls to a Next.js API route, which then performs on-demand page revalidation using ISR. This provides a practical reference for developers to implement real-time frontend updates with a decoupled WordPress backend and Next.js frontend.

Related Issue

#173

Dependant PRs

Type of Change

  • ✨ New feature (non-breaking change which adds functionality)
  • 📄 Example update (no functional changes)
  • 📝 Documentation update

How Has This Been Tested?

Testing was performed by following the instructions in the README file of the webhooks-isr example project, which includes setting up environment variables, running the Next.js app, and configuring WordPress webhooks.

Testing Steps:

  • Create a new post in WordPress.
    Publish or update a post in your WordPress backend.

  • Review the post on the headless Next.js website.
    Visit the corresponding page on your Next.js frontend to verify the content appears as expected.

  • Update the content in WordPress.
    Make changes to the post content and save.

  • Verify the headless post updates automatically.
    The Next.js site should reflect the updated content without a full rebuild, thanks to ISR triggered by the webhook.

  • Inspect the Next.js server logs.
    You should see logs similar to the following, indicating the webhook revalidation process:

[Webhook] Received revalidation request
[Webhook] Secret from header: Provided
[Webhook] Expected secret is set: Yes
[Webhook] Secret token validated successfully
[Webhook] Request body parsed: { post_id: 242, path: '/posts/new-post/' }
[Webhook] Path to revalidate: /posts/new-post/

This confirms that the webhook was received, the secret validated, and the ISR revalidation was triggered successfully.

Screenshots

Checklist

  • I have read the CONTRIBUTING document
  • My code follows the project's coding standards
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation (if applicable)
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works (if applicable)
  • Any dependent changes have been highlighted, merged or published

@theodesp theodesp changed the title feat: first iteration of example feat: first iteration of Webhooks Example project Jun 10, 2025
@github-actions
Copy link

ℹ️ Download the wp-graphql-headless-webhooks plugin artifact from this workflow run (see the 'Artifacts' section at the bottom).

@theodesp theodesp marked this pull request as ready for review June 11, 2025 11:43
@theodesp theodesp requested a review from a team as a code owner June 11, 2025 11:43
Copy link
Member

@colinmurphy colinmurphy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@theodesp LGTM 🚀 🚀 🚀

Thanks for leaving the comments in the various files, that was super helpful ❤️

@theodesp theodesp enabled auto-merge June 13, 2025 11:24
@theodesp theodesp added this pull request to the merge queue Jun 13, 2025
Merged via the queue into main with commit 1087e94 Jun 13, 2025
3 of 4 checks passed
@theodesp theodesp deleted the feat-webhooks-isr-example branch June 13, 2025 11:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants