NATS Storage
High-performance durable storage using NATS JetStream and KV
NATS Storage
The @stepflowjs/storage-nats adapter provides a high-performance, distributed storage backend using NATS JetStream and Key-Value (KV) buckets. It is ideal for cloud-native and edge environments.
Installation
pnpm add @stepflowjs/storage-natsUsage
import { Stepflow } from "@stepflowjs/core";
import { NatsStorageAdapter } from "@stepflowjs/storage-nats";
const stepflow = new Stepflow({
storage: new NatsStorageAdapter({
servers: ["nats://localhost:4222"],
streamPrefix: "stepflow_prod",
}),
});Configuration Options
| Option | Type | Description |
|---|---|---|
servers | string | string[] | NATS server URLs (default: localhost:4222) |
streamPrefix | string | Prefix for all streams and KV buckets (default: stepflow) |
connectionOptions | object | Advanced NATS connection options (user, pass, token, etc.) |
Features
- Durable Messaging: Uses NATS JetStream for reliable job queuing.
- Key-Value Store: Uses NATS KV buckets for persisting workflow execution state and step results.
- Distributed: Naturally supports multi-region and edge deployments.
- Real-time: Leverages NATS core pub/sub for instant execution updates.
Environment Variables
NATS_URL=nats://localhost:4222