It is a simple to-do list application demonstrating use of the PowerSync Kotlin Mutiplatform SDK together with Supabase in a basic Kotlin Multiplatform Compose App.
Supported KMP targets: Android, iOS and Desktop (JVM).
To setup your environment, please consult these instructions.
A step-by-step guide on Supabase<>PowerSync integration is available here.
If you want to use the example with bucket priorities, you can adopt the following sync rules instead of the ones suggested by the simpler integration guide:
bucket_definitions:
all_lists:
priority: 1
parameters: select request.user_id() as "user"
data:
- select * from lists where owner_id = bucket."user"
list_items:
# Separate bucket per list
parameters: select id as list_id from lists where owner_id = request.user_id()
data:
- select * from todos where list_id = bucket.list_id
The project will work with both sync rules, but giving lists a higher priority allows updates to be synchronized before all items have been received.
- Clone this repo:
git clone https://github.com/powersync-ja/powersync-kotlin.git
- Open the repo in Android Studio. This creates a
local.properties
file in root and should contain asdk.dir=/path/to/android/sdk
line. - Sync the project with Gradle (this should happen automatically, or choose File > Sync project with Gradle Files).
- Open the
demos/supabase-todolist
directory in Android Studio and sync this project with Gradle. - Insert your Supabase project URL, Supabase Anon Key, and PowerSync instance URL into the
local.properties
file:
# local.properties
sdk.dir=/path/to/android/sdk
# Enter your PowerSync instance URL
POWERSYNC_URL=https://foo.powersync.journeyapps.com
# Enter your Supabase project's URL and public anon key (Project settings > API)
SUPABASE_URL=https://foo.supabase.co
SUPABASE_ANON_KEY=foo
Choose a run configuration for the Android or iOS target in Android Studio and run it.
For Android, this demo contains two Android apps:
androidApp/
: This is a regular compose UI app using PowerSync.androidBackgroundSync/
: This example differs from the regular app in that it uses a foreground service managing the synchronization process. The service is started in the main activity and keeps running even after the app is closed. For more notes on background sync, see this document.