StepflowStepflow

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-nats

Usage

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

OptionTypeDescription
serversstring | string[]NATS server URLs (default: localhost:4222)
streamPrefixstringPrefix for all streams and KV buckets (default: stepflow)
connectionOptionsobjectAdvanced 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

On this page