jeremylongshore/claude-code-plugins-plus-skills
clerk-pack
plugins/saas-packs/clerk-pack/skills/clerk-webhooks-events/SKILL.md
January 22, 2026
Select agents to install to:
npx add-skill https://github.com/jeremylongshore/claude-code-plugins-plus-skills/blob/main/plugins/saas-packs/clerk-pack/skills/clerk-webhooks-events/SKILL.md -a claude-code --skill clerk-webhooks-eventsInstallation paths:
.claude/skills/clerk-webhooks-events/# Clerk Webhooks & Events
## Overview
Configure and handle Clerk webhooks for user lifecycle events and data synchronization.
## Prerequisites
- Clerk account with webhook access
- HTTPS endpoint for webhooks
- svix package for verification
## Instructions
### Step 1: Install Dependencies
```bash
npm install svix
```
### Step 2: Create Webhook Endpoint
```typescript
// app/api/webhooks/clerk/route.ts
import { Webhook } from 'svix'
import { headers } from 'next/headers'
import { WebhookEvent } from '@clerk/nextjs/server'
export async function POST(req: Request) {
const WEBHOOK_SECRET = process.env.CLERK_WEBHOOK_SECRET
if (!WEBHOOK_SECRET) {
throw new Error('CLERK_WEBHOOK_SECRET not set')
}
// Get Svix headers
const headerPayload = await headers()
const svix_id = headerPayload.get('svix-id')
const svix_timestamp = headerPayload.get('svix-timestamp')
const svix_signature = headerPayload.get('svix-signature')
if (!svix_id || !svix_timestamp || !svix_signature) {
return Response.json({ error: 'Missing headers' }, { status: 400 })
}
// Get body
const payload = await req.json()
const body = JSON.stringify(payload)
// Verify webhook
const wh = new Webhook(WEBHOOK_SECRET)
let evt: WebhookEvent
try {
evt = wh.verify(body, {
'svix-id': svix_id,
'svix-timestamp': svix_timestamp,
'svix-signature': svix_signature,
}) as WebhookEvent
} catch (err) {
console.error('Webhook verification failed:', err)
return Response.json({ error: 'Invalid signature' }, { status: 400 })
}
// Handle event
const eventType = evt.type
console.log(`Received webhook: ${eventType}`)
switch (eventType) {
case 'user.created':
await handleUserCreated(evt.data)
break
case 'user.updated':
await handleUserUpdated(evt.data)
break
case 'user.deleted':
await handleUserDeleted(evt.data)
break
case 'session.created':
await handleSessionCreated(evt.data)