© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
SupabaseS
Supabase•2mo ago•
98 replies
ElPuto

Unable to listen to postgres_changes

realtime
Hi guys!
I'm trying to listen to INSERT events on the table
messages
messages
on my react native app.
I already impersonated the user on the realtime dashboard and filtered for postgres changes only and I can indeed see the new message showing up there, but for some reason, on my app, the listeners never trigger and I'm running out of ideas.
The broadcast listener works perfectly but
postgres_changes
postgres_changes
listener doesn't work at all.

This is my code
 const channel = supabase
      .channel("notifications")
      // New messages
      .on(
        "postgres_changes",
        { event: "INSERT", schema: "public", table: "messages" },
        (payload) => {
          const msg = payload.new as {
            conversation_id: string;
            sender_id: string;
          };
          console.log(msg, " new message");

          if (msg.sender_id === user.id) return;

          setUnreadConversations((prev) => {
            const next = new Set(prev);
            next.add(msg.conversation_id);
            return next;
          });

          queryClient.invalidateQueries({ queryKey: ["conversations"] });
        }
      )
 const channel = supabase
      .channel("notifications")
      // New messages
      .on(
        "postgres_changes",
        { event: "INSERT", schema: "public", table: "messages" },
        (payload) => {
          const msg = payload.new as {
            conversation_id: string;
            sender_id: string;
          };
          console.log(msg, " new message");

          if (msg.sender_id === user.id) return;

          setUnreadConversations((prev) => {
            const next = new Set(prev);
            next.add(msg.conversation_id);
            return next;
          });

          queryClient.invalidateQueries({ queryKey: ["conversations"] });
        }
      )
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
Next page

Similar Threads

Listen changes to a specific column
SupabaseSSupabase / help-and-questions
4y ago
How to listen for changes and update state?
SupabaseSSupabase / help-and-questions
4y ago
Listen to single row changes with v2-client
SupabaseSSupabase / help-and-questions
4y ago
unable to subscribe to changes realtime
SupabaseSSupabase / help-and-questions
10mo ago