clerk-webhooks

Implement verified Clerk webhook handlers for user, organization, and billing event synchronization.

Updated Aug 22, 2026
One-click install
npx skills add https://github.com/Rajaryan1726/ai-code-review-system --skill clerk-webhooks-rajaryan1726
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: clerk-webhooks
Source: https://github.com/Rajaryan1726/ai-code-review-system/tree/main/client/.agents/skills/clerk-webhooks
Command: npx skills add https://github.com/Rajaryan1726/ai-code-review-system --skill clerk-webhooks-rajaryan1726

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Building Clerk webhook endpoints requires correct signature verification, raw-body parsing, public route configuration, and event payload handling — mistakes in any of these cause 401 errors, spoofed-event vulnerabilities, or missing database records. This Skill provides complete, verified webhook handler patterns so events like user signups and organization changes reliably sync to your database, email, and Slack. ## Core Features & Use Cases - Signature-Verified Handlers: Generates handlers using verifyWebhook from framework-specific packages (@clerk/nextjs/webhooks, @clerk/express/webhooks, etc.) that read CLERK_WEBHOOK_SIGNING_SECRET automatically. - Full Event Catalog Coverage: Handles user, session, organization, organization membership, billing/subscription, and payment events with typed payload field references. - Framework-Specific Guidance: Includes per-framework examples for Next.js, Express, Astro, Fastify, Nuxt, React Router, and TanStack Start, plus a troubleshooting table for common failures like 401s and Express body-parsing issues. - Use Case: When a user signs up, automatically create a row in your Postgres users table via Prisma, send a welcome email through Resend, and post a notification to your Slack channel — all from one verified webhook handler. ## Quick Start Ask the assistant to set up a Clerk webhook handler in your Next.js app that verifies the signature and creates a database record whenever a user.created event fires.

Frequently Asked Questions about clerk-webhooks

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

FAQPage Schema
How do I set up a Clerk webhook handler in Next.js?▼

Create a POST route at app/api/webhooks/route.ts that calls verifyWebhook(req) from @clerk/nextjs/webhooks, then branch on evt.type such as user.created. You must also exclude /api/webhooks(.*) from clerkMiddleware protection so the route is public.

Why is my Clerk webhook endpoint returning 401 errors?▼

A 401 usually means the webhook route is still protected by Clerk middleware. Add /api/webhooks(.*) to your public route matcher in clerkMiddleware so unauthenticated Svix requests can reach the handler.

How do I verify Clerk webhooks in Express?▼

Use verifyWebhook from @clerk/express/webhooks and mount the route with express.raw({ type: 'application/json' }) instead of express.json(). Signature verification requires the raw request body bytes, and the signing secret comes from CLERK_WEBHOOK_SIGNING_SECRET.

What events can Clerk webhooks send to my app?▼

Clerk sends user, session, organization, organization membership, organization domain, invitation, email/SMS, waitlist, permission, role, subscription, subscription item, and payment attempt events. Each event type narrows evt.data to a typed JSON payload such as UserJSON.

Should I use webhooks or the Clerk session token for user data?▼

Use the session token or Backend API for data the current user just created in a synchronous flow, since webhooks are asynchronous and eventually consistent. Use webhooks for database sync, notifications, and integrations involving other users or lifecycle events.

How do I test Clerk webhooks locally?▼

Run clerk webhooks listen with a token from clerk webhooks token and forward to your local endpoint, then add the printed relay URL as a webhook endpoint in the Clerk Dashboard. Svix headers are preserved so verifyWebhook works against the endpoint's signing secret.