Configuration object.
Called for each webhook event: (field, value) => Promise<boolean>.
field — Event field name.value — Event payload.
Return true to acknowledge; return false to respond with HTTP 500.The verify token you configured in the Meta Developer Portal.
Object with GET and POST — export as your route's handlers.
// app/api/webhooks/threads/route.ts
import { setupThreadsWebhook } from "naystack/socials";
export const { GET, POST } = setupThreadsWebhook({
secret: process.env.WEBHOOK_SECRET!,
callback: async (field, value) => {
console.log("Threads event:", field, value);
return true; // Return false to respond with 500
},
});
Sets up GET (verification) and POST (event handling) route handlers for the Threads webhook.
hub.verify_tokenagainstsecret).callbackfor each event.