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}`);
},
});

Every publish, change and take-down is posted, so a site that refreshes on each post stays current with nothing else. If your endpoint is down, the post is tried again. If it never takes it, the site’s owner sees it in Needs you with Try again, and it is sent again once the endpoint is fixed.