Docs Menu

MongoDB Realm Kotlin Multiplatform SDK (Alpha)icons/link.png

On this page

  • Local Realm Database
  • Define an Object Schema
  • Query Realm Database
  • Update Objects
  • Get Started
Alpha Release

This SDK is currently offered as an alpha release. We encourage you to try out the feature and give feedback. However, be aware that APIs and functionality are subject to change.

The MongoDB Realm Kotlin Multiplatform SDK allows you to use Realm Database from Android and iOS applications written with Kotlin Multiplatform Mobile (KMM).

Sync Support In Development

The SDK currently supports some, but not all, Realm Sync functionality. For more information about supported behavior, see the API reference.

With the MongoDB Realm Kotlin Multiplatform SDK, you can access objects stored in a local instance of Realm Database. With Realm Database, you can:

Define your object schema with marked Kotlin classes:

class Frog : RealmObject {
var name: String = ""
var age: Int = 0
var species: String? = null
var owner: String? = null

Query for stored objects:

val config = RealmConfiguration.with(schema = setOf(Frog::class))
val realm =
val frogsQuery = realm.objects<Frog>()
val numTadpoles = frogsQuery.query("age > $0", 2).count()
println("Tadpoles: $numTadpoles")
val numFrogsNamedJasonFunderburker = frogsQuery.query("name == $0", "Jason Funderburker").count()
println("Frogs named Jason Funderburker: $numFrogsNamedJasonFunderburker")
val numFrogsWithoutOwners = frogsQuery.query("owner == null").count()
println("Frogs without owners: $numFrogsWithoutOwners")

Update objects in Realm Database by updating field values on an instance of the object within a transaction:

val config = RealmConfiguration.with(schema = setOf(Frog::class))
val realm =
// start a write transaction
realm.writeBlocking {
// get a frog from the database to update
val frog = objects<Frog>()
.query("name == $0 LIMIT(1)", "Benjamin Franklin")
// change the frog's name
frog[0].name = "George Washington"
// change the frog's species
frog[0].species = "American bullfrog"
} // when the transaction completes, the frog's name and species
// are updated in the database

To start using the MongoDB Realm Kotlin Multiplatform SDK in your KMM application, see Install Realm for Kotlin Multiplatform to add the Kotlin Multiplatform SDK dependency and then check out the Quick Start.

Kotlin Multiplatform SDK is Currently in Alpha

The Kotlin Multiplatform SDK, like KMM itself, is currently in alpha. The API may change in future releases.

Give Feedback
MongoDB logo
© 2021 MongoDB, Inc.


  • Careers
  • Investor Relations
  • Legal Notices
  • Privacy Notices
  • Security Information
  • Trust Center
© 2021 MongoDB, Inc.