Skip to main content

Installation

Get the package installed, NATS running locally, and the peer dependencies lined up. If you already have NATS, skip straight to Quick Start.

Install the package

npm install @horizon-republic/nestjs-jetstream

Peer dependencies

The library requires the following NestJS packages as peer dependencies (they are part of any standard NestJS project):

  • @nestjs/common ^10.2.0 || ^11.0.0
  • @nestjs/core ^10.2.0 || ^11.0.0
  • @nestjs/microservices ^10.2.0 || ^11.0.0
  • reflect-metadata ^0.2.0
  • rxjs ^7.8.0

Runtime requirements

  • Node.js >= 20.0.0
  • TypeScript >= 5.7 (required by @nats-io/* v3 typed array generics)
  • NATS Server >= 2.10 with JetStream enabled (>= 2.12 for message scheduling)

Run NATS locally

The fastest way to get a JetStream-enabled NATS server running is with Docker:

docker run -d --name nats -p 4222:4222 nats:2.12 -js

This starts NATS on localhost:4222 with JetStream enabled (-js flag).

To verify it's running:

docker logs nats | head -5
NATS via Docker Compose for local development
docker-compose.yml
services:
nats:
image: nats:2.12
command: -js
ports:
- "4222:4222"
- "8222:8222" # monitoring

The monitoring port (8222) gives you access to the NATS monitoring endpoint for debugging.

What's next?

Once you have the package installed and NATS running, head to the Quick Start to wire up your first handlers.