SupabaseS
Supabase•4y ago
Giggiux

New Setup Realtime subscription not receiving data

Ok, so, I know that probably I'm doing something wrong, but the example I have is so simple that I cannot figure it out what I'm doing wrong.

I'm using the free tier Supabase Hosted;
Local SvelteKit frontend;

One extremely simple table, with realtime active and I've also added it to the publication as stated in the online guides:

begin;
  -- remove the supabase_realtime publication
  drop publication if exists supabase_realtime;

  -- re-create the supabase_realtime publication with no tables and only for insert
  create publication supabase_realtime with (publish = 'insert');
commit;

-- add a table to the publication
alter publication supabase_realtime add table "bars";


I'm authenticated, but anyway if my RLS rules allow read to anyone (as I want)

BEGIN;
  ALTER POLICY "Enable read access for all users" ON "public"."bars" USING (true);
COMMIT;


And my code in SvelteKit looks like the following:

onMount(() => {
        const channel = supabase
            .channel('*')
            .on('postgres_changes', { event: '*', schema: 'public' }, (payload) => console.log(payload))
            .subscribe();
    });



The WebSocket connects properly, but every time I update any row in the bars table, nothing gets published to the client.

Can someone spot what am I missing? 😢
Was this page helpful?