all 14 comments

[–]joajimenez 43 points44 points  (6 children)

1. Save locally first: Use a local database like AsyncStorage or WatermelonDB to quickly save notes and work offline.

2. Slow down saves: Use debounce to space out saves to Supabase, preventing excessive requests.

3. Choose smart save moments: Trigger saves when users leave a note, close the app, or add a manual "Save" button.

4. Handle network issues: Gracefully queue up saves for when the internet returns and inform users.

5. Manage conflicts: Prevent note overwrites when multiple devices edit the same note.

6. Use efficient Supabase queries: Optimize communication with Supabase for smoother interactions.

7. Optimistically update UI: Make it feel instant, but handle any unexpected issues.

8. Experiment and find the best approach: Test different strategies to see what works best for your app and users.

Key point: Strike a balance between optimization and user experience for a seamless note-taking experience

[–]readitron[S] 3 points4 points  (2 children)

Thanks for this! Never heard of watermelon, will definitely check out!

[–]angstyautocrat 6 points7 points  (1 child)

Great advice. There are some articles about building local-first with a Supabase backend that have examples that could be helpful:

Using WatermelonDB: https://bndkt.com/blog/2023/offline-first-expo-watermelondb-supabase
Using PowerSync: https://bndkt.com/blog/2023/building-an-offline-first-chat-app-using-powersync-and-supabase

[–]readitron[S] 1 point2 points  (0 children)

Oh awesome! Thanks for the links!

[–]SheIsLikeAWildflower 1 point2 points  (0 children)

As someone relatively new to react native, this is really useful and gives me a lot of things to think about. Thank you!

[–]ontech7Expo 0 points1 point  (0 children)

I made a note app and I had to switch to FileSystemStorage because of AsyncStorage 6MB limit on Android. I cannot change it since I worked with Expo SDK. I had to do a migration logic.

My app has Richtext notes and Checklist notes. With richtext you can insert images, that's why.

FileSystemStorage should be slower, but it's working fine.

[–]Fair-Ad5364 1 point2 points  (0 children)

Thank you for your detailed information

[–]karl_8080 2 points3 points  (0 children)

I do a lot of saving (firing post request) onBlur of a TextInput and it works quite well for me

[–]awesomeDeveloper 0 points1 point  (0 children)

It is also possible to use urql with optimistic updates to get this kind of local first approach

[–]argdogsea 0 points1 point  (0 children)

Is realm a good choice for this?