HeadlessNext Connector

Beskrivning

HeadlessNext Connector seamlessly links your WordPress CMS with modern decoupled frontends like Next.js, Vercel, Nuxt, SvelteKit, or Remix.

When editors publish, update, or delete posts and pages in WordPress, HeadlessNext Connector sends a fast, asynchronous, non-blocking webhook (POST request) to your frontend API route. This triggers Incremental Static Regeneration (ISR), updating your static site’s cache instantly without rebuilding the entire website!

Key Features:

  • On-Demand ISR Revalidation: Trigger instant cache invalidation on Next.js (revalidatePath() or revalidateTag()) when posts or pages change in WordPress.
  • Asynchronous & Non-Blocking: Fires requests in the background so WordPress post publishing is never delayed waiting for external server responses.
  • Shared Secret Security: Send an X-HeadlessNext-Secret HTTP header to verify that revalidation requests originate exclusively from your authorized WordPress site.
  • Universal Compatibility: Works with any active WordPress theme, Gutenberg block editor, Classic Editor, and custom REST API / GraphQL setups.
  • Zero Overhead: Completely inert when no Frontend URL is configured. Zero external tracking or phone-home requests.

Skärmdumpar

Installation

  1. Upload the headlessnext-connector directory to /wp-content/plugins/ or install directly via Plugins Add New in your WordPress dashboard.
  2. Activate HeadlessNext Connector.
  3. Go to Settings HeadlessNext Connector.
  4. Enter your Frontend Base URL (e.g. https://my-site.com) and Revalidation Path (e.g. /api/revalidate).
  5. (Optional) Set a shared secret token for request verification.
  6. Check ”Automatically ping the frontend on post publish or update” and save changes.

Quick Next.js App Router Integration Example

Create app/api/revalidate/route.ts in your Next.js project:

import { revalidatePath } from 'next/cache';
import { NextResponse } from 'next/server';

export async function POST(request: Request) {
  const secret = request.headers.get('x-headlessnext-secret');
  if (secret !== process.env.REVALIDATE_SECRET) {
    return NextResponse.json({ message: 'Invalid secret' }, { status: 401 });
  }

  const body = await request.json();
  const slug = body.slug || '/';

  // Revalidate the updated page path
  revalidatePath(/${slug}`);

revalidatePath(’/’); // Revalidate homepage list

return NextResponse.json({ revalidated: true, now: Date.now() }); } `

Vanliga frågor

Does this plugin require a specific WordPress theme?

No! HeadlessNext Connector works standalone with any theme, including Twenty Twenty-Four or custom block/classic themes.

How does On-Demand ISR work with Next.js?

Next.js uses Incremental Static Regeneration (ISR) to serve fast static pages. When content changes in WordPress, HeadlessNext Connector sends a webhook payload containing the post ID, slug, and post type to your Next.js API route. Next.js then runs revalidatePath() to update that static page in the background.

What data is sent in the Webhook payload?

The POST JSON payload includes:
* post_id: The ID of the post/page
* post_type: ’post’, ’page’, etc.
* slug: The URI slug of the post
* permalink: Full permalink URL
* action: ’publish’, ’update’, or ’delete’
* home_url: The WordPress site home URL

How do I secure my revalidation endpoint?

Configure a Revalidation Secret in the settings page. HeadlessNext Connector sends this secret in the X-HeadlessNext-Secret request header. Check this header in your Next.js API route before calling revalidatePath().

Is there any performance impact on WordPress?

None. All webhook pings use non-blocking HTTP requests (wp_remote_post with blocking => false), ensuring the WordPress admin publishing flow remains fast and responsive.

Recensioner

Detta tillägg har inga recensioner.

Bidragsgivare och utvecklare

”HeadlessNext Connector” är programvara med öppen källkod. Följande personer har bidragit till detta tillägg.

Bidragande personer

Översätt ”HeadlessNext Connector” till ditt språk.

Intresserad av programutveckling?

Läs programkoden, kika på SVN-filförvaret eller prenumerera på utvecklarloggen via RSS.

Ändringslogg

1.0.0

  • Initial public release: settings page, non-blocking on-demand ISR revalidation webhook, secret header validation.