supabase-community / supabase-kt

A Kotlin Multiplatform Client for Supabase.
https://supabase.com/docs/reference/kotlin/introduction
MIT License
392 stars 37 forks source link

[Feature request]: Add support for offline data persistence #760

Open jan-tennert opened 4 hours ago

jan-tennert commented 4 hours ago

General Info

Feature request

As requested by a bunch of developers: In many cases such as Mobile Apps, you will want to allow the user to use your app while having no connection to Supabase. For that, you currently have to implement data caching yourself. supabase-kt should support this, but I'm not completely sure which way I'd go to support:

If data gets removed/modified locally while offline, syncing should also be done automatically when back online.

Firebase/Firestore does support this.

Proposal:

For Postgrest: The idea would be to have a local SQLite database via SQLDelight or SQLite and cache the data when any postgrest request is made.

With this approach, we have to device how we get the table schemas, which obviously should be created before any caching is done.

For Realtime: If the device looses connection, the device listens to the local DB for changes \ Maybe only for the high-level functions such as selectAsFlow

I put Storage in parenthesis, because other libraries such as Coil basically do that for us.

Usecase

No response

jan-tennert commented 3 hours ago

@grdsdev @dshukertjr, would love to hear your thoughts on this!