# Build Local-First Kotlin Multiplatform Apps With PowerSync

> The PowerSync Kotlin Multiplatform SDK is now in open alpha. Use it with a Postgres backend database to instantly make your KMP app local-first with PowerSync as the sync layer.

- Published: 2024-03-04
- Author: Benita Volkmann
- Category: Announcement
- Source: https://powersync.com/blog/build-local-first-kotlin-multiplatform-apps-with-powersync

---

The PowerSync Kotlin Multiplatform SDK is now in open alpha. Use it with a Postgres backend database to instantly make your KMP app local-first with PowerSync as a sync layer. Supported targets: Android and iOS. Supabase integration available.

## Kotlin Multiplatform SDK

Today we are announcing the alpha release of the [PowerSync Kotlin Multiplatform SDK](https://github.com/powersync-ja/powersync-kotlin/tree/main).

With this release, Kotlin Multiplatform (KMP) developers can easily build local-first apps to achieve simplified state management and real-time reactivity. This release includes support for Android and iOS targets, with additional targets (JVM, Wasm) being considered for a future release.

### SDK Features

  * Provides real-time streaming of database changes, using Kotlin Coroutines and Flows.
  * Offers direct access to the SQLite database, enabling the use of SQL on both client and server sides.
  * Operations are asynchronous, ensuring the user interface remains unblocked.
  * Supports concurrent database operations, allowing one write and multiple reads simultaneously.
  * Enables subscription to queries for receiving live updates.
  * Eliminates the need for client-side database migrations as these are managed automatically.

### Engineering Notes

Our initial plan was to build a Kotlin Native library targeting Android and iOS but we changed gears to build a Kotlin Multiplatform library, given its popularity and [benefits](https://kotlinlang.org/docs/multiplatform.html). 

We are using [SQLDelight](https://github.com/cashapp/sqldelight)’s API and drivers to connect to and execute queries in SQLite since it provides asynchronous database queries and flows — forming part of PowerSync’s core features. In the future, we plan to integrate with the SQLDelight compiler providing ORM-like capabilities.

The PowerSync library loads a SQLite extension and sets up SQLite native bindings on each platform. On iOS, we use CocoaPods to add a pod dependency and [cinterop](https://kotlinlang.org/docs/native-c-interop.html) compilations to build an iOS framework. On Android, we use a custom database open factory to load our extension and call JNI bindings.

### Current Limitations

Debugging via configurable logging is not yet implemented. The above-mentioned integration with SQLDelight’s compiler for ORM-like capabilities is also planned. This SDK currently supports only a single SQLite database file.

### Native Development

PowerSync support for Kotlin Native and native Swift development is in active development. 

## Demo App

The easiest way to test the SDK is to run the **hello-powersync** demo app. Instructions for this can be found [here](https://github.com/powersync-ja/powersync-kotlin/tree/main/demos/hello-powersync). This app uses Compose Multiplatform and demonstrates real-time streaming of Postgres data and offline CRUD operation queuing & syncing. The demo app also showcases our integration with Supabase.

We would love to hear your feedback. Reach out to us on [Discord](https://discord.gg/powersync) if you have any feedback, need help or have any questions.
