Sqkon

Type-safe JSONB-powered key-value store for Kotlin Multiplatform.

Get Started View on GitHub API Reference

Maven Central Version GitHub branch check runs License: Apache 2.0

Install

// build.gradle.kts
dependencies {
    implementation("com.mercury.sqkon:library:{{ site.sqkon_version }}")
}

30-second taste

@Serializable
data class Merchant(
    val id: String,
    val name: String,
    val category: String,
)

// Android needs context + scope; JVM needs scope only.
val sqkon = Sqkon(context = applicationContext, scope = appScope)
val merchants = sqkon.keyValueStorage<Merchant>("merchants")

// Insert (sync) — Sqkon dispatches the SQLite work internally.
merchants.insert("m_1", Merchant("m_1", "Chipotle", "Food"))

// Observe — emits whenever the store changes. Collect from a coroutine.
appScope.launch {
    merchants.selectAll().collect { list ->
        println("Now have ${list.size} merchants")
    }
}

// One-shot reads use Flow.first() inside a suspend block.
suspend fun loadFood(): List<Merchant> =
    merchants.select(where = Merchant::category eq "Food").first()

Why Sqkon?

Kotlin Multiplatform

One codebase, Android + JVM. iOS on the roadmap.

JSONB queries

Query nested fields and lists with a type-safe DSL — no manual SQL, no DAOs.

Reactive Flows

Every read returns a Flow. Writes auto-invalidate observers.

AndroidX Paging

Built-in keyset and offset PagingSources for Compose and views.

TTL / Expiry

First-class expiry on every entry. Perfect for caches.

Built on SQLDelight

Battle-tested SQLite, with type-safe codegen underneath.

Next steps