Kotlin Multiplatform SDK for Convex — type-safe, coroutine-first, modular backend client for every platform Kotlin runs on.
- Multiplatform — Android, iOS, JVM Desktop, and WasmJs from a single codebase
- Type-safe functions — Call Convex queries, mutations, and actions with compile-time safety
- Result monad —
ConvexResult<T>withmap,flatMap,recover— no exceptions leak to callers - Args DSL — Build function arguments with a clean Kotlin DSL instead of raw JSON
- Modular architecture — Pick only the modules you need: core, client, storage, realtime
- Simple setup — Factory functions for client creation
- File storage — Three-step upload flow, download URLs, and deletion out of the box
- Reactive subscriptions — Observe query results as Kotlin Flows with automatic polling
- Dual auth modes — Bearer tokens (end-user JWT) and admin auth (deploy keys)
- Value-class IDs —
DocumentId,StorageId,FunctionReferenceprevent mixups at compile time
Add the dependencies you need to your build.gradle.kts:
[versions]
convex = "0.1.0"
[libraries]
convex-core = { module = "io.github.androidpoet:convex-core", version.ref = "convex" }
convex-client = { module = "io.github.androidpoet:convex-client", version.ref = "convex" }
convex-storage = { module = "io.github.androidpoet:convex-storage", version.ref = "convex" }
convex-realtime = { module = "io.github.androidpoet:convex-realtime", version.ref = "convex" }kotlin {
sourceSets {
commonMain.dependencies {
implementation(libs.convex.client) // includes convex-core
implementation(libs.convex.storage) // optional
implementation(libs.convex.realtime) // optional
}
}
}val convex = Convex.create("https://your-app.convex.cloud") {
logging = true
}
val convex = createConvexClient(
ConvexConfig(DeploymentUrl("https://your-app.convex.cloud")),
)
val storage = createStorageClient(convex)
val realtime = createRealtimeClient(convex)convex.setAuth("eyJhbG...")
convex.setAdminAuth("prod:deploy-key-abc123")
convex.clearAuth()val messages = convex.query("messages:list", args {
"channel" to "#general"
"limit" to 50
})
messages.onSuccess { data ->
println("Got messages: $data")
}.onFailure { error ->
println("Error: ${error.message}")
}
val id = convex.mutation("messages:send", args {
"body" to "Hello from Kotlin!"
"channel" to "#general"
})
val result = convex.action("actions:sendEmail", args {
"to" to "user@example.com"
"subject" to "Welcome"
})@Serializable
data class Message(
val _id: String,
val body: String,
val channel: String,
val _creationTime: Double,
)
val messages: ConvexResult<List<Message>> = convex.queryTyped("messages:list")val page = convex.queryPaginated(
path = "messages:list",
args = args { "channel" to "#general" },
paginationOpts = PaginationOpts(numItems = 25, cursor = null),
)
page.onSuccess { result ->
println("Page: ${result.page}")
println("Has more: ${!result.isDone}")
println("Next cursor: ${result.continueCursor}")
}val storage = createStorageClient(convex)
val storageId = storage.uploadFile(
data = imageBytes,
contentType = "image/png",
)
val url = storage.getUrl(storageId = StorageId("storage_abc123"))
storage.deleteFile(storageId = StorageId("storage_abc123"))val realtime = createRealtimeClient(convex)
realtime.subscribe("messages:list", args {
"channel" to "#general"
}).collect { result ->
result.onSuccess { messages ->
println(messages)
}
}┌─────────────────────────────────────────────────────────┐
│ Your App │
├──────────┬──────────────┬──────────────┬────────────────┤
│ convex- │ convex- │ convex- │ convex- │
│ realtime │ storage │ client │ core │
│ │ │ │ │
│ Polling │ Upload Flow │ ConvexClient │ ConvexResult │
│ Flow │ Download URL │ HttpTransport│ Args DSL │
│ Subscribe│ Delete │ Auth State │ Value IDs │
│ │ │ Factory API │ Models │
├──────────┴──────────────┼──────────────┤ Serialization │
│ │ Ktor │ │
│ │ OkHttp │ │
│ │ Darwin │ │
│ │ Js │ │
└─────────────────────────┴──────────────┴────────────────┘
| Module | Artifact | Description |
|---|---|---|
| convex-core | io.github.androidpoet:convex-core |
Value types, result monad, args DSL, serialization models |
| convex-client | io.github.androidpoet:convex-client |
HTTP transport, query/mutation/action execution, auth |
| convex-storage | io.github.androidpoet:convex-storage |
File upload (3-step flow), download URLs, deletion |
| convex-realtime | io.github.androidpoet:convex-realtime |
Reactive query subscriptions as Kotlin Flows |
| Platform | Target | Ktor Engine |
|---|---|---|
| Android | androidTarget() |
OkHttp |
| iOS | iosX64() iosArm64() iosSimulatorArm64() |
Darwin |
| Desktop | jvm() |
OkHttp |
| Web | wasmJs() |
Js |
| Layer | Library |
|---|---|
| Language | Kotlin 2.1.10 |
| Networking | Ktor 3.1.1 |
| Serialization | kotlinx.serialization 1.8.0 |
| Coroutines | kotlinx.coroutines 1.10.1 |
| Date/Time | kotlinx-datetime 0.6.2 |
| Publishing | vanniktech maven-publish 0.30.0 |
# Compile all targets
./gradlew compileKotlinJvm
# Run tests
./gradlew jvmTest
# Publish to Maven Central (CI only)
./gradlew publishAllPublicationsToMavenCentral --no-configuration-cacheContributions are welcome! If you've found a bug, have an idea for an improvement, or want to contribute new features, please open an issue or submit a pull request.
Support it by joining stargazers for this repository. ⭐
Also, follow me on GitHub for my next creations! 🤩
MIT License
Copyright (c) 2026 Ranbir Singh
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
