Introduction
Good Webhooks is a TypeScript library that adds outbound webhooks to your application, using your PostgreSQL database.
Good Webhooks lets your application send webhooks to the endpoints your users register. You publish an event, and it handles the rest: recipients, signing, retries, history, and replay. It runs inside your app and stores everything in your PostgreSQL database, so there is no extra service to host.
- your appPublish
publish()validates the payload and finds subscribed endpoints. - PostgreSQLStore
The event and one delivery per endpoint commit with your data.
- workerDeliver
A worker signs each request, sends it, and retries failures.
- receiverVerify
The receiver checks the signature and gets a typed event.
In code
import { createWebhooks } from 'good-webhooks'
import { Pool } from 'pg'
import { z } from 'zod'
export const webhooks = createWebhooks({
database: new Pool({ connectionString: process.env.DATABASE_URL }),
encryptionKey: process.env.WEBHOOK_ENCRYPTION_KEY!,
events: {
'invoice.paid': z.object({ invoiceId: z.string(), amount: z.number().int() }),
},
})
await webhooks.publish({
type: 'invoice.paid',
data: { invoiceId: 'inv_123', amount: 4200 }, // type-checked against the schema
})What it handles for you
A fetch() in a request handler loses events when a receiving server is down, sends duplicates on deploys, and can be pointed at internal services. Good Webhooks covers those cases:
- Endpoints: Good Webhooks handles endpoint storage, encrypted secrets, and URL safety checks. You decide who may manage which endpoints.
- Publishing: Good Webhooks handles payload validation, idempotency, and recipient selection. You decide when to publish, and in which transaction.
- Delivery: Good Webhooks handles signing, retries, attempt history, and replay. You decide where the worker runs and how it's supervised.
- Migrations: Good Webhooks handles the migration SQL and schema checks. You decide when migrations run.
- Receivers: Good Webhooks handles signature verification and typed parsing. You decide what the receiver does with the event.
Nothing starts on its own: creating the client opens no connections, runs no migrations, and starts no workers.
Stable API
From 1.0.0 the public API and upgrade path follow the 1.x stability
policy. Throughput beyond the measured
profile is not yet verified.
Try it in five minutes
One file sends a signed webhook to a local receiver.
Add it to your app
Install, create the tables, and connect.
Use Better Auth?
Let signed-in users manage their own endpoints.
Understand the model
Management, delivery, scopes, and guarantees.
See what breaks by hand
A tutorial that builds sending by hand, breaks it, then uses the library.
Compare with alternatives
Svix, Outpost, Convoy, and pg-boss plus fetch.