Skip to content
Docs

Update the moment you publish

Without a webhook, your site shows a new article the next time it reads the feed. With one, it can show it within seconds. The pattern is the same everywhere: verify, then refresh.

  1. Make an endpoint that verifies the signature. webhookHandler does it for you.

  2. Refresh in the way your site needs: start a build, clear a cache, or revalidate a path.

  3. Add the endpoint in the app and keep its secret in CITEDSEO_WEBHOOK_SECRET.

webhookHandler is in @citedseo/feed and every framework package. It checks the signature, so onPost only ever runs for a post from us, and it answers 500 when onPost throws, so a refresh that failed is tried again.

Start a build through your host’s deploy hook. Keep the hook’s address in an environment variable; it is a secret too.

import { webhookHandler } from '@citedseo/feed';
export const POST = webhookHandler({
secret: process.env.CITEDSEO_WEBHOOK_SECRET!,
onPost: async () => {
const res = await fetch(process.env.DEPLOY_HOOK_URL!, { method: 'POST' });
// Throwing answers 500, so CitedSEO tries the post again.
if (!res.ok) throw new Error(`The deploy hook answered ${res.status}`);
},
});

A webhook can be missed: your endpoint was down, or a deploy was mid-flight. Don’t let that leave your site stale for good.

  • Still refresh on a timer. Read the manifest again every few minutes to an hour, so a missed post heals itself. It is one small file.
  • Catch take-downs from the feed. Nothing is posted when an article is taken down, so a store built only from webhooks keeps it. Compare against the feed now and then and drop what is gone.