
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-kased 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 | Status |
|---|---|
| JVM | Full Support |
| Android | Full Support |
| iOS (ARM64) | Full Support |
| iOS Simulator (ARM64) | Full Support |
| macOS (ARM64) | Full Support |
| Linux (x64) | Full Support |
| Linux (ARM64) | Full Support |
| JavaScript (Browser) | Full Support |
| JavaScript (Node.js) | Full Support |
| WasmJS | Full Support |
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 | β | |
| 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!
Please do not rely on the NKEY/Creds authentication features included in this client in a production environment. Although functionally correct, some cryptographic operations have not been formally verified and may have vulnerabilities.
The NKEY implementation uses an Ed25519 algorithm implementation from an un-attested library. This is used to sign authentication requests by the server on connect.
I plan to move the NKEY implementation to use cryptography-kotlin, a multiplatform binding to various other platform-native attested libraries, like JCA, OpenSSL and WebCrypto. This is waiting on the features being developed in that library upstream.
The rest of the secure operations, including secure-random and TLS for TCP and WebSocket transports, use implementations which delegate to platform-native libraries and should not pose a notable security risk.
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-kased 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 | Status |
|---|---|
| JVM | Full Support |
| Android | Full Support |
| iOS (ARM64) | Full Support |
| iOS Simulator (ARM64) | Full Support |
| macOS (ARM64) | Full Support |
| Linux (x64) | Full Support |
| Linux (ARM64) | Full Support |
| JavaScript (Browser) | Full Support |
| JavaScript (Node.js) | Full Support |
| WasmJS | Full Support |
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 | β | |
| 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!
Please do not rely on the NKEY/Creds authentication features included in this client in a production environment. Although functionally correct, some cryptographic operations have not been formally verified and may have vulnerabilities.
The NKEY implementation uses an Ed25519 algorithm implementation from an un-attested library. This is used to sign authentication requests by the server on connect.
I plan to move the NKEY implementation to use cryptography-kotlin, a multiplatform binding to various other platform-native attested libraries, like JCA, OpenSSL and WebCrypto. This is waiting on the features being developed in that library upstream.
The rest of the secure operations, including secure-random and TLS for TCP and WebSocket transports, use implementations which delegate to platform-native libraries and should not pose a notable security risk.
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!