Configuration object.
Called for each webhook event: (type, value, pageId) => Promise<void>.
type — Event type (e.g. "messaging", "changes").value — Event payload.id — The page/account id from the entry.The verify token you configured in the Meta Developer Portal.
Object with GET and POST — export as your route's handlers.
// app/api/webhooks/instagram/route.ts
import { setupInstagramWebhook } from "naystack/socials";
export const { GET, POST } = setupInstagramWebhook({
secret: process.env.WEBHOOK_SECRET!,
callback: async (type, value, id) => {
if (type === "messaging") {
console.log("New message from page", id, value);
}
},
});
Sets up GET (verification) and POST (event handling) route handlers for the Instagram webhook.
hub.verify_tokenagainstsecret).callbackfor each event in the payload.