Skip to content

Webhooks

Jamie Barton edited this page Aug 21, 2024 · 1 revision

You can automate the creation of databases per user in the background with webhooks.

Using webhooks locally

It's recommended you use ngrok.io to expose our local server to the internet so Clerk can send webhooks to it.

Install the ngrok CLI, and run the following:

ngrok http 3000

Make sure to change 3000 to the port your Next.js application is running on.

Inside Clerk, go to Webhooks > Add Endpoint and enter the URL provided by ngrok + /webhooks/clerk, and select user.created as the event:

Add webhook endpoint

Next click on the webhook you just created and copy the signing secret:

Copy webhook signing secret

Add this signing secret to .env:

CLERK_WEBHOOK_SECRET=

Now every time a user signs up, Clerk will ping your localhost:3000/webhooks/clerk via your tunnel.

Note: You will need to update the clerk endpoint each time you restart ngrok. Paid ngrok users can set a persistent URL.

Using webhooks in production

You will need to deploy the app to Vercel to obtain the Deployment URL.

Once you have that, update the webhook URL in Clerk:

Update clerk endpoint

Clone this wiki locally