The SurrealDB SDK for Kotlin is distributed through Maven Central under the com.surrealdb group. You can add it to your project using Gradle or Maven.
The Kotlin SDK is in early development. The current version is 0.1.0-SNAPSHOT and is not yet published to Maven Central. Until the first release is cut, the coordinates below are provisional, and you may need to build the SDK locally with ./gradlew publishToMavenLocal.
Requirements
The SDK is a Kotlin Multiplatform library built with Kotlin 2.1.x. It supports the following targets:
| Target | Requirement |
|---|---|
| JVM | Java 11 or later |
| Android | minSdk 26 or later, Java 11 |
| iOS | iosX64, iosArm64, iosSimulatorArm64 |
It depends on Kotlin Coroutines, kotlinx.serialization, kotlinx.datetime, and Ktor for transport. Embedded (in-process) databases are intentionally not included in this release; connect to a running SurrealDB instance over WebSocket or HTTP instead.
Install the SDK
For a Kotlin Multiplatform project, add the metadata artifact com.surrealdb:kotlin to your commonMain source set. For a single-platform project, you may instead depend on the platform-specific variant (kotlin-jvm, kotlin-android, kotlin-iosarm64, kotlin-iossimulatorarm64, or kotlin-iosx64).
val surrealdbVersion = "0.1.0-SNAPSHOT"
dependencies {
implementation("com.surrealdb:kotlin:$surrealdbVersion")
} Maven projects cannot resolve the Kotlin Multiplatform metadata artifact, so use a platform-specific variant such as kotlin-jvm.
Import the SDK
After installing, import the client from the com.surrealdb.kotlin package.
import com.surrealdb.kotlin.SurrealClient
import com.surrealdb.kotlin.SurrealClientConfigNext steps
Getting started for a complete working example
Connecting to SurrealDB for connection options and protocols
Authentication for signing in and managing credentials