Skip to main content

XState actors for NATS

@jr200-labs/xstate-nats coordinates a NATS WebSocket connection, subject subscriptions, request/reply, key-value operations, and short-lived credentials using XState v5.

pnpm add @jr200-labs/xstate-nats xstate @opentelemetry/api

Start with the browser demo: configure a connection, subscribe, publish a message, and watch the active state. Its default sandbox needs no broker. Live mode connects directly from your browser to your own NATS WebSocket endpoint.

Task Guide
Create an actor and connect Getting started
Subscribe, publish, and request a reply Subjects
Create a bucket, store values, and watch keys Key-value
Load and refresh authentication Credentials
Understand events, states, and errors Reference
Inspect spans, metrics, and lifecycle logs Observability

NATS still requires a server for real messaging. The hosted documentation and demo UI are static files; GitHub Pages does not host a broker. The sandbox adapter belongs only to the demo and is not shipped as part of the library.