
Unified gRPC client offering a common API, channel builder with TLS, interceptors, generated stubs and protobuf serialization; supports unary and streaming RPCs, gRPC‑Web and native FFI.
This library is a gRPC client library compatible with Kotlin Multiplatform. It provides a common gRPC API across JVM, JavaScript, iOS, macOS, Linux, and Windows platforms. On JVM it uses grpc-java, on JavaScript it uses gRPC-Web over Ktor HttpClient, and on native platforms (iOS, macOS, Linux, Windows) it uses Rust/Tonic via FFI.
| Platform | Implementation | Streaming Support |
|---|---|---|
| JVM | grpc-java + grpc-kotlin-stub + grpc-okhttp | All types |
| JS (IR) | gRPC-Web over Ktor HttpClient | Unary + Server-streaming |
| iOS / macOS | Rust/Tonic FFI via cinterop | All types |
| Linux x64 | Rust/Tonic FFI via cinterop | All types |
| Windows mingwX64 | Rust/Tonic FFI via cinterop | All types |
Below is how to use it with Kotlin on the supported platforms using Gradle. If you are using it on an Apple platform, please refer to kgrpc-spm or kgrpc-cocoapods. Additionally, please check the test code as well.
repositories {
mavenCentral()
}
dependencies {
+ implementation("work.socialhub.kgrpc:core:0.0.1")
}repositories {
+ maven { url = uri("https://repo.repsy.io/mvn/uakihir0/public") }
}
dependencies {
+ implementation("work.socialhub.kgrpc:core:0.0.1-SNAPSHOT")
}All of the above can be added to and used in regular Java projects, too. All you have to do is to use the suffix -jvm when listing the dependency.
Here is a sample Maven configuration:
<dependency>
<groupId>work.socialhub.kgrpc</groupId>
<artifactId>core-jvm</artifactId>
<version>[VERSION]</version>
</dependency>val channel = Channel.Builder
.forAddress("localhost", 50051)
.usePlaintext()
.build()val channel = Channel.Builder
.forAddress("example.com", 443)
.useTransportSecurity()
.build()val stub = MyServiceStub(channel)
val response = stub.myMethod(request)val channel = Channel.Builder
.forAddress("localhost", 50051)
.usePlaintext()
.intercept(object : CallInterceptor {
override fun onSendHeaders(headers: Metadata): Metadata {
headers.put("authorization", "Bearer $token")
return headers
}
})
.build()Channel.Builder)MIT License
This library is a gRPC client library compatible with Kotlin Multiplatform. It provides a common gRPC API across JVM, JavaScript, iOS, macOS, Linux, and Windows platforms. On JVM it uses grpc-java, on JavaScript it uses gRPC-Web over Ktor HttpClient, and on native platforms (iOS, macOS, Linux, Windows) it uses Rust/Tonic via FFI.
| Platform | Implementation | Streaming Support |
|---|---|---|
| JVM | grpc-java + grpc-kotlin-stub + grpc-okhttp | All types |
| JS (IR) | gRPC-Web over Ktor HttpClient | Unary + Server-streaming |
| iOS / macOS | Rust/Tonic FFI via cinterop | All types |
| Linux x64 | Rust/Tonic FFI via cinterop | All types |
| Windows mingwX64 | Rust/Tonic FFI via cinterop | All types |
Below is how to use it with Kotlin on the supported platforms using Gradle. If you are using it on an Apple platform, please refer to kgrpc-spm or kgrpc-cocoapods. Additionally, please check the test code as well.
repositories {
mavenCentral()
}
dependencies {
+ implementation("work.socialhub.kgrpc:core:0.0.1")
}repositories {
+ maven { url = uri("https://repo.repsy.io/mvn/uakihir0/public") }
}
dependencies {
+ implementation("work.socialhub.kgrpc:core:0.0.1-SNAPSHOT")
}All of the above can be added to and used in regular Java projects, too. All you have to do is to use the suffix -jvm when listing the dependency.
Here is a sample Maven configuration:
<dependency>
<groupId>work.socialhub.kgrpc</groupId>
<artifactId>core-jvm</artifactId>
<version>[VERSION]</version>
</dependency>val channel = Channel.Builder
.forAddress("localhost", 50051)
.usePlaintext()
.build()val channel = Channel.Builder
.forAddress("example.com", 443)
.useTransportSecurity()
.build()val stub = MyServiceStub(channel)
val response = stub.myMethod(request)val channel = Channel.Builder
.forAddress("localhost", 50051)
.usePlaintext()
.intercept(object : CallInterceptor {
override fun onSendHeaders(headers: Metadata): Metadata {
headers.put("authorization", "Bearer $token")
return headers
}
})
.build()Channel.Builder)MIT License