
High-performance NATS client enables messaging support across platforms with features like TCP and WebSocket transport, coroutine-based reactive programming, and a clean API for versatile application deployment.
A fully multiplatform, Ktor-based NATS client in pure Kotlin
NATS.kt is a high-performance NATS client built specifically for Kotlin Multiplatform. Powered by Ktor's networking stack, it brings NATS messaging to every platform Kotlin supports - including servers, mobile apps, browsers and native applications.
| Platform | Support |
|---|---|
| JVM | Full |
| Android | Full |
| iOS (ARM64) | Full |
| iOS Simulator (ARM64) | Full |
| macOS (ARM64) | Full |
| Linux (x64) | Full |
| Linux (ARM64) | Full |
| JavaScript (Browser) | Full |
| JavaScript (Node.js) | Full |
| WasmJS | Full |
Minimum JVM: 17
Minimum Kotlin: 2.1
Gradle:
commonMain.dependencies {
implementation("io.github.n-hass:natskt-core:0.7.0")
// and if you want jetstream:
implementation("io.github.n-hass:natskt-jetstream:0.7.0")
}import io.natskt.NatsClient
// Simple connection
val client = NatsClient("nats://localhost:4222")
client.connect()
// Advanced configuration
val client = NatsClient {
server = "nats://localhost:4222"
transport = TcpTransport
}
val client = NatsClient {
server = "ws://localhost:4222"
transport = WebSocketTransport.Factory(CIO)
}
// Subscribe to messages
val subscription = client.subscribe("orders.new")
subscription.messages.collect { message ->
println("Received: ${message.data}")
}NATS.kt is under active development.
| Feature | Status | Notes |
|---|---|---|
| Core Protocol | ||
| Multiplatform TCP/WebSocket transport | ✅ | |
| Authentication | ✅ | * See security notice below! |
| Publish/Subscribe | ✅ | |
| Request/Reply | ✅ | |
| Jetstream | ||
| Basic API client | ✅ | |
| Pull consumer | ✅ | |
| Push consumer | 🟠 | Functional, missing server liveness timeout |
| Key-Value Store | ✅ | |
| Object Store | ❌ | |
| JetStream Management | ||
| Streams | ✅ | |
| Consumers | ✅ |
Legend: ✅ Complete | 🟠 Partially Complete | 🚧 In Progress | ❌ Planned
Check out our examples directory for comprehensive usage examples:
More coming soon!
The upcoming 1.0.0 stable release of NATS.kt will include a new platform-native cryptography library that was not used in pre-release versions (0.1.0 – 0.7.0).
If you are concerned about potential security vulnerabilities when using an un-attested Ed25519 implementation, please use the 1.0.0-rc.1 pre-release:
commonMain.dependencies {
implementation("io.github.n-hass:natskt-platform:1.0.0-rc.1")
}NATS.kt is released under the Apache 2.0 License.
Ready to build the next generation of distributed Multiplatform applications? Star ⭐ this repo and join our community!
A fully multiplatform, Ktor-based NATS client in pure Kotlin
NATS.kt is a high-performance NATS client built specifically for Kotlin Multiplatform. Powered by Ktor's networking stack, it brings NATS messaging to every platform Kotlin supports - including servers, mobile apps, browsers and native applications.
| Platform | Support |
|---|---|
| JVM | Full |
| Android | Full |
| iOS (ARM64) | Full |
| iOS Simulator (ARM64) | Full |
| macOS (ARM64) | Full |
| Linux (x64) | Full |
| Linux (ARM64) | Full |
| JavaScript (Browser) | Full |
| JavaScript (Node.js) | Full |
| WasmJS | Full |
Minimum JVM: 17
Minimum Kotlin: 2.1
Gradle:
commonMain.dependencies {
implementation("io.github.n-hass:natskt-core:0.7.0")
// and if you want jetstream:
implementation("io.github.n-hass:natskt-jetstream:0.7.0")
}import io.natskt.NatsClient
// Simple connection
val client = NatsClient("nats://localhost:4222")
client.connect()
// Advanced configuration
val client = NatsClient {
server = "nats://localhost:4222"
transport = TcpTransport
}
val client = NatsClient {
server = "ws://localhost:4222"
transport = WebSocketTransport.Factory(CIO)
}
// Subscribe to messages
val subscription = client.subscribe("orders.new")
subscription.messages.collect { message ->
println("Received: ${message.data}")
}NATS.kt is under active development.
| Feature | Status | Notes |
|---|---|---|
| Core Protocol | ||
| Multiplatform TCP/WebSocket transport | ✅ | |
| Authentication | ✅ | * See security notice below! |
| Publish/Subscribe | ✅ | |
| Request/Reply | ✅ | |
| Jetstream | ||
| Basic API client | ✅ | |
| Pull consumer | ✅ | |
| Push consumer | 🟠 | Functional, missing server liveness timeout |
| Key-Value Store | ✅ | |
| Object Store | ❌ | |
| JetStream Management | ||
| Streams | ✅ | |
| Consumers | ✅ |
Legend: ✅ Complete | 🟠 Partially Complete | 🚧 In Progress | ❌ Planned
Check out our examples directory for comprehensive usage examples:
More coming soon!
The upcoming 1.0.0 stable release of NATS.kt will include a new platform-native cryptography library that was not used in pre-release versions (0.1.0 – 0.7.0).
If you are concerned about potential security vulnerabilities when using an un-attested Ed25519 implementation, please use the 1.0.0-rc.1 pre-release:
commonMain.dependencies {
implementation("io.github.n-hass:natskt-platform:1.0.0-rc.1")
}NATS.kt is released under the Apache 2.0 License.
Ready to build the next generation of distributed Multiplatform applications? Star ⭐ this repo and join our community!