Webhooks

Inbound Webhooks

Receive inbound webhooks from other services.

next-forge has pre-built webhook handlers for several key services.

Payment Events

Payment events are handled in the POST /webhooks/payments route in the api app. This route constructs the event and then switches on the event type to determine how to process the event.

To test webhooks locally, we've configured the Stripe CLI to forward webhooks to your local server. This will start automatically when you run pnpm dev.

Authentication Events

Authentication events are handled in the POST /webhooks/auth route in the api app.

Make sure you enable the webhook events you need in your Clerk project settings.

Local Development

Currently there's no way to easily test Clerk webhooks locally, so you'll have to test them in a staging environment. This means deploying your app to a "production" state Vercel project with development environment variables e.g. staging-api.example.com. Then you can add this URL to your Clerk project's webhook settings.

Database Events

One of the most common use cases for inbound webhooks is to notify your application when a database record is created, updated, or deleted. This allows you to react to changes asynchronously, rather than polling the database, cron jobs or other methods.

If you migrate to Supabase, they have an incredibly powerful feature called Database Webhooks that helps with this.