© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
SupabaseS
Supabase•4y ago•
4 replies
user8923

Realtime and CRUD in React, best practices?

Let us say we create a React Todo app with simple CRUD operations. We want this app to be realtime so that changes are instantly seen by other connected clients.

When I add a new todo via a form, I make a call into supabase to insert a new todo row and immediately select the result in order to obtain an todo object that includes the auto-generated id column. I then add this todo object to my state.

The problem is that I'm also receiving that same todo via the realtime subscription, as if it had been created by someone else. To avoid duplication I compare the id of the newly insert todo with the one just received from the sub, and if they match I do not update the UI.

Is this the right approach? Is there a way to avoid pushing changes to the client that initiated it?
Supabase banner
SupabaseJoin
Supabase gives you the tools, documentation, and community that makes managing databases, authentication, and backend infrastructure a lot less overwhelming.
45,816Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

React realtime
SupabaseSSupabase / help-and-questions
4y ago
Database recovery and best practices
SupabaseSSupabase / help-and-questions
5mo ago
Branching Best Practices
SupabaseSSupabase / help-and-questions
3mo ago
Best Practices using NextJS
SupabaseSSupabase / help-and-questions
13mo ago