Skip to main content

NatsPubsub

Production-ready pub/sub messaging for NATS JetStream

๐ŸŽฏ

Declarative API

Clean, intuitive subscriber API inspired by Rails and NestJS. Write less boilerplate, focus on business logic.

๐Ÿ”’

Battle-Tested Reliability

Built-in Inbox/Outbox patterns, Dead Letter Queue, and automatic retries ensure your messages are delivered.

๐ŸŒ

Cross-Language

Full TypeScript and Ruby implementations with identical APIs. Build polyglot microservices with ease.

โšก

Production Ready

Comprehensive monitoring, health checks, and observability. Battle-tested in high-throughput production systems.

๐Ÿงช

Developer Experience

Extensive testing utilities, fake modes, and comprehensive documentation make development a breeze.

๐Ÿ”ง

Auto-Topology

Automatic JetStream stream and consumer management. No manual NATS configuration required.

JavaScript/TypeScript

import { Publisher, Subscriber } from 'nats-pubsub';

// Publish a message
const publisher = new Publisher(config);
await publisher.publish('order.created', {
  orderId: '123',
  amount: 99.99
});

// Subscribe to messages
class OrderSubscriber extends Subscriber {
  constructor() {
    super('order.created');
  }

  async handle(message, metadata) {
    await processOrder(message);
  }
}

Ruby

require 'nats_pubsub'

# Publish a message
NatsPubsub.publish('order.created', {
  order_id: '123',
  amount: 99.99
})

# Subscribe to messages
class OrderSubscriber < NatsPubsub::Subscriber
  subscribe_to 'order.created'

  def handle(message, context)
    process_order(message)
  end
end

Ready to get started?

Choose your language and start building in minutes