NUTS
Bridge NATS JetStream messages to the browser via Server-Sent Events. A drop-in Caddy module.
$ xcaddy build --with github.com/ideaconnect/nuts
Features
Real-time SSE streaming
Stream NATS messages to browsers instantly via EventSource
JetStream persistence
Messages stored in NATS JetStream — replay on reconnect
Message replay
Resume from any point with last-id or Last-Event-ID
Multiple topics
Subscribe to many NATS subjects in a single connection
No message drops
Slow clients are disconnected cleanly so they can replay
Caddy native
First-class Caddy module — configure via Caddyfile or JSON
Quick Example
Caddyfile
:8080 {
route /events* {
nuts {
nats_url nats://localhost:4222
stream_name EVENTS
topic_prefix events.
}
}
}
Client (JavaScript)
const es = new EventSource(
'/events?topic=my-topic'
);
es.addEventListener('message', (e) => {
const data = JSON.parse(e.data);
console.log(data.topic, data.payload);
});
Inspired by Mercure
NUTS is deeply inspired by Mercure and wouldn't exist without it. Not a competitor — a complementary tool for teams already running NATS.