That's for reading, sync would be more for writing...
# off-topic
m
That's for reading, sync would be more for writing.
g
I think the confusion is coming from you using the name "realtime" which is the subscription concept for supabase. You can use realtime to sync reads or writes to a table back to your app. But I think you are asking for the caching the firebase client does using local storage/indexed db. Supabase does not support anything like that.
I'm using localforage to do though a similar thing
I cache reads and update cache with writes. I have a queue in the localforage storage for writes if off line and execute them when back online. I use a subscription on a status table to detect online/offline and for updates to table if from another device. My app though only has a user able to access their own data, so only worried about them updating their own data on other devices. Also like you point out I'm not worried about the eventual RLS check for the cached writes, because the RLS is only to make sure it is that user's data.
m
Ok cool, thanks. I had no heard of localforage
g
There are many local database utilities, I just like it's simplicity, that it uses indexedDB and that I can easily have a separate clearable "cache" for writes, data read by type and queries and clear anyone of them without clearing them all.
It is only one tool though. You still have to write all the logic to deal with offline and updating, clearing etc. It is just part of the solution I used.
Oh it also stores files and images as js file objects so I can even queue those for later update to supabase.
m
If you don't need to worry as much about "offline" adaptability, I would recommend using something like
reactQuery
with optimistic mutation updates. I believe this will map well with the write syncing you're looking for.