dart_nats
1.7.1, released 2 weeks ago by an unverified publisher
A Dart and Flutter client library for the NATS messaging system.
What it does
Allows Dart and Flutter applications to communicate with NATS messaging servers. Supports publish-subscribe, request-reply patterns, JetStream persistence, and multiple authentication methods across TCP and WebSockets.
AI-written summary of version 1.7.1, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need to connect a Flutter app or Dart service to a NATS messaging cluster
- You require real-time pub/sub or request-reply messaging patterns
- You want support for WebSockets on the web and raw TCP sockets on native platforms
Skip it when
- Your backend is built around HTTP/REST or GraphQL without a NATS intermediary
- You are looking for a general-purpose state management or local storage solution
Strengths
- Supports both TCP and WebSocket transports for native and web platforms
- Includes robust connection lifecycle management, background retries, and heartbeats
- Offers advanced features like queue groups, wildcard subscriptions, and experimental JetStream support
Weaknesses
- JetStream, Key-Value, and Object Store APIs are currently experimental
- Requires a running NATS server infrastructure to be useful
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 5
Add the dependency to pubspec.yaml and connect using a NATS server URI.
final client = Client();
await client.connect(Uri.parse('nats://localhost:4222'));
final sub = client.sub('sensors.temperature');
sub.stream.listen((Message msg) {
print('Received payload: ${msg.string}');
});Alternatives
Packages that do the same job and could replace dart_nats.
- connectanum
A Dart/Flutter client implementing the WAMP protocol for RPC and Pub/Sub.
69Compare - stomp_dart_client
Dart STOMP client for messaging interoperability in Flutter and Dart applications.
67Compare - vmodal_sdk_flutter
Typed VModal API client for Flutter to upload videos and search moments by meaning.
67Compare - sync_http
Synchronous HTTP client for Dart using RawSynchronousSockets.
50Compare
Works with
Packages commonly used together with dart_nats: ones it builds on, ones built on it, and its own family.
- cryptodart_nats depends on itProvides SHA, MD5, and HMAC hashing functions for Dart.
- web_socket_channeldart_nats depends on itCross‑platform WebSocket channel wrapper for Dart
- ed25519_edwardsdart_nats depends on itEd25519 signature implementation for Dart, compatible with RFC 8032 keys.
- base32dart_nats depends on itBase32 encoder and decoder for Dart, supporting multiple variants and OTP secrets.