clerk-webhooks

Verify Clerk webhook signatures and process lifecycle events in Next.js.

Updated Aug 23, 2026
One-click install
npx skills add https://github.com/MichaelFrieze/riffatlas --skill clerk-webhooks-michaelfrieze
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: clerk-webhooks
Source: https://github.com/MichaelFrieze/riffatlas/tree/main/.agents/skills/clerk-webhooks
Command: npx skills add https://github.com/MichaelFrieze/riffatlas --skill clerk-webhooks-michaelfrieze

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill solves the problem of securely receiving and processing Clerk webhook events to keep your application data in sync without relying on synchronous user flows.

Core Features & Use Cases

  • Signature verification everywhere: Verifies every incoming webhook request using verifyWebhook(req) to prevent spoofed events from being processed.
  • Asynchronous, reliable event handling: Supports eventual-consistency workflows such as database synchronization, notifications, and third-party integrations triggered by lifecycle events.
  • Multi-event operational patterns: Covers common Clerk event types including users, sessions, organizations, memberships, billing/subscription, payments, and more, with safe payload narrowing by evt.type.
  • Public webhook routing guidance: Ensures webhook endpoints are excluded from Clerk middleware protection to avoid 401 errors.

Quick Start

Ask to generate a Next.js app router POST webhook endpoint at app/api/webhooks/route.ts that uses verifyWebhook(req) on every request and, on user.created, extracts id, email, and name and writes a corresponding row to your database.

Frequently Asked Questions about clerk-webhooks

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I handle Clerk webhooks in a Next.js App Router application?

To handle Clerk webhooks in Next.js, create a public POST endpoint that uses verifyWebhook(req) with your CLERK_WEBHOOK_SIGNING_SECRET to verify requests, then branch logic by evt.type for database synchronization. Return a 2xx acknowledgement after processing side effects.

Why does my Clerk webhook endpoint return a 401 error in Next.js?

Clerk webhook endpoints return 401 errors when protected by Clerk middleware. You must configure public webhook routing to exclude the webhook endpoint from middleware protection, ensuring unauthenticated external requests can reach the signature verification step.

What Clerk lifecycle events can I sync to my database using webhooks?

You can sync user, session, organization, membership, and billing-related lifecycle events to your database using webhooks. The handler narrows payload types safely by evt.type to execute deterministic database or notification side effects for eventually consistent workflows.

Do I need to verify Clerk webhook signatures manually?

Signature verification is required to prevent spoofed events from being processed. You use the framework-specific verifyWebhook function with the CLERK_WEBHOOK_SIGNING_SECRET environment variable rather than implementing manual cryptographic verification logic.

Can I use Clerk webhooks for asynchronous notifications and third-party integrations?

Clerk webhooks support asynchronous, reliable event handling for eventually consistent workflows. You can trigger notifications and third-party integrations by processing verified lifecycle events and executing deterministic side effects before sending 2xx acknowledgements.