Clerk webhooks allow you to sync user data from Clerk to your application. The most important events are:
user.created
- Triggers when a new user registersuser.updated
- Triggers when user information changesuser.deleted
- Triggers when a user is removed
-
Set up ngrok
- Create an account at ngrok dashboard
- Install ngrok
- Save your forwarding URL from ngrok (e.g.,
https://your-url.ngrok-free.app
) Do not use the static url (it changes everytime).
-
Configure Clerk Webhook
- Go to Clerk Dashboard > Webhooks
- Add Endpoint:
https://your-url.ngrok-free.app/api/webhooks
- Select events you want to listen to (e.g.,
user.created
) - Copy the Signing Secret
-
Environment Setup
DATABASE_URL="your_database_url" CLERK_WEBHOOK_SECRET="your_signing_secret"
-
Run ngrok You can run ngrok with the following command. This will automatically start ngrok and forward the port api. Only needed if you wish to test webhooks locally.
pnpm clerk:listen
For production, replace the ngrok URL with your actual production URL in the Clerk Dashboard webhook settings.
For detailed information about Clerk webhooks and implementation details, see the Clerk Webhooks Documentation.