Next.js Direct publishing
Publish articles straight to your own Next.js site and rebuild pages instantly with on-demand revalidation.
Next.js Direct publishing
Next.js Direct publishes articles straight to your own Next.js site — no third-party CMS in between. When you publish, EarlyForge writes the article to your site and then calls a revalidation endpoint so the affected pages rebuild on demand. Your readers see the new content within seconds.
This is the fastest path for teams who run their own Next.js front end and want full control over how articles are stored and rendered.
How it works
EarlyForge sends the article to your site
On publish, EarlyForge delivers the article — title, content, intro, lead image, language, and SEO metadata — to your connected Next.js site.
Your site stores it
Your Next.js app saves the article wherever you keep content. Re-publishing the same article updates it in place rather than creating a duplicate.
EarlyForge triggers revalidation
EarlyForge calls your revalidation endpoint with the path that changed. Your app revalidates that path using Next.js on-demand ISR.
Readers see the update
The static page regenerates and the new article goes live within seconds.
Set up Next.js Direct
Add a revalidation endpoint to your site
Create an API route in your Next.js app — for example app/api/revalidate/route.ts — that EarlyForge will call after publishing. It verifies the request is genuine, then revalidates the changed path:
import crypto from 'crypto';
import { revalidatePath } from 'next/cache';
import { NextRequest } from 'next/server';
export async function POST(request: NextRequest) {
const body = await request.text();
const signature = request.headers.get('X-Webhook-Signature') ?? '';
const secret = process.env.EARLYFORGE_REVALIDATE_SECRET!;
// Verify the HMAC-SHA256 signature before trusting the payload
const expected =
'sha256=' +
crypto.createHmac('sha256', secret).update(body).digest('hex');
const valid =
signature.length === expected.length &&
crypto.timingSafeEqual(Buffer.from(signature), Buffer.from(expected));
if (!valid) {
return new Response('Invalid signature', { status: 401 });
}
const { path } = JSON.parse(body); // e.g. "/articles/ai-adoption-newsrooms"
revalidatePath(path);
return Response.json({ revalidated: true, path });
}Connect Next.js Direct in EarlyForge
Go to Sites → select your site → Connections → Next.js Direct and provide:
- Revalidation URL — your endpoint, for example
https://yoursite.com/api/revalidate - Revalidation secret — a shared secret used to sign every request
The secret is stored inside the site's connection and encrypted by EarlyForge. Add the same value to your Next.js app as a server-side environment variable (EARLYFORGE_REVALIDATE_SECRET).
Test the connection
Click Test connection. EarlyForge sends a signed test request to your revalidation URL and confirms it responds successfully.
Save the connection
Click Save. Next.js Direct is now an active publishing destination.
Keep the revalidation secret server-side only. Never expose it in client-side code or public environment variables — anyone with the secret could trigger revalidations on your site.
Verifying the request
Every call EarlyForge makes to your revalidation endpoint is signed with HMAC-SHA256 using your shared secret, sent in the X-Webhook-Signature header as sha256={digest}. Always verify this signature before acting on the request, as shown in the example above. This is the same signature scheme used by Webhooks.
Scheduled publishing
Scheduled publishing is available on Pro and higher plans.
Articles generated from a brief on a schedule can publish to your Next.js site automatically, triggering revalidation each time without any manual step.
Reliability
If several publish attempts fail in a row — for example your endpoint is temporarily unreachable — EarlyForge briefly pauses and retries automatically once it recovers. No articles are lost in the meantime.
What's next?
- Publish to WordPress — use a traditional CMS instead
- Publish to Ghost — newsletter-driven distribution
- Webhooks — the full signed-event pattern for custom integrations