Nim’s NATS clients were all FFI bindings to nats.c, which drags in libnats, OpenSSL, libsodium and protobuf-c before you can publish a single message. Natsnim removes that: a NATS client in pure Nim.

It is a translation of the official Go client rather than of nats.c, which turned out to be the right call — the Go client’s structure maps cleanly onto Nim, and the translation came out smaller and more testable than bindings would have been. It was written to be the bus client for Niffler, but knows nothing about any application.

import natsnim/conn as natsconn
let c = natsconn.dial("nats://127.0.0.1:4222")
let sub = c.subscribe("ev.>")
c.publish("ev.thing", "hello")
echo sub.nextMsg(1000).data
  • No C dependency — just Nim and the standard library.
  • Reconnect and resubscribe — with bounded I/O and explicit deadlines.
  • Two surfaces — an idiomatic API, plus a natswrapper-compatible shim for drop-in replacement.