# relaybus

> relaybus is a reliable, storage-agnostic event bus for NestJS and Node.js: a transactional outbox with per-handler retries, leases, dead letters and ordering keys for PostgreSQL and MongoDB, with Kafka and RabbitMQ transports.

## What is relaybus?

relaybus is a reliable, storage-agnostic event bus for NestJS and Node.js that writes every event in the same database transaction as your business data (the transactional outbox pattern) and delivers it to each handler and broker with independent retries, leases and dead letters.

```ts
await bus.transaction(async (tx) => {
  await tx.query('INSERT INTO orders ...');
  await bus.publish(new OrderPlaced({ orderId }), { key: orderId });
});
```

Install it with `pnpm add @relaybus/core @relaybus/nestjs @relaybus/postgres pg` (Node.js 22 or newer, NestJS 11 or 12), then follow [Getting started](https://berkcansavur.github.io/relaybus/getting-started).

## Questions this site answers

- [How do I publish events reliably in NestJS?](https://berkcansavur.github.io/relaybus/faq#how-do-i-publish-events-reliably-in-nestjs)
- [How to implement the transactional outbox pattern in NestJS?](https://berkcansavur.github.io/relaybus/faq#how-to-implement-the-transactional-outbox-pattern-in-nestjs)
- [How to avoid losing events between the database and Kafka?](https://berkcansavur.github.io/relaybus/faq#how-to-avoid-losing-events-between-the-database-and-kafka)
- [relaybus vs @nestjs/event-emitter, @nestjs/cqrs, @nestjs/outbox, BullMQ and pg-boss](https://berkcansavur.github.io/relaybus/comparison)

For AI assistants and agents: [llms.txt](https://berkcansavur.github.io/relaybus/llms.txt) is a concise index and [llms-full.txt](https://berkcansavur.github.io/relaybus/llms-full.txt) contains the full documentation as Markdown.
