© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
SupabaseS
Supabase•4mo ago•
8 replies
Daniel de Oliveira

Realtime not working in Node SSR

Hello! I'm struggling a lot to implement a feature in my Express app that needs Realtime capabilities, can someone help me out? 😓

My idea is to use realtime channels to listen and forward events from an
"ambulance"
"ambulance"
table for users that connect to a
"watch"
"watch"
route. To accomplish that, I'm using the
@supabase/ssr
@supabase/ssr
package.

I've verified that Realtime is active in my
"ambulance"
"ambulance"
table and the user I'm using to test is allowed by the RLS rules, as I've tested by fetching ambulances while connected as they.

The problem is that even though my connection succeds, as my
subscribe
subscribe
callback logs
SUBSCRIBED
SUBSCRIBED
, the callback passed to the
on
on
method - responsible for notifying changes - is not being called when I make changes to
"ambulance"
"ambulance"
in the DB
.

Here's the code in my ambulance controller that connects to realtime channels:

 typescript
export function watch(req: WatchRequest, res: Response) {
  const { user, supabase } = req;

  if (!supabase)
    throw new Error("Supabase client is required to watch ambulances");
  if (!user) throw new Error("You must be authenticated to watch ambulances");

  const channel = supabase
    .channel(`ambulance-${user.id}`)
    .on(
      "postgres_changes",
      { event: "*", schema: "public", table: "ambulance" },
      (payload) => {
        switch (payload.eventType) {
          case "INSERT":
            res.json(payload.new);
            break;
          case "UPDATE":
            res.json(payload.new);
            break;
          case "DELETE":
            res.json(payload.old);
        }
      }
    )
    .subscribe((status, error) => {
      if (error) {
        throw error;
      } else {
        console.log(status);
      }
    });
}
 typescript
export function watch(req: WatchRequest, res: Response) {
  const { user, supabase } = req;

  if (!supabase)
    throw new Error("Supabase client is required to watch ambulances");
  if (!user) throw new Error("You must be authenticated to watch ambulances");

  const channel = supabase
    .channel(`ambulance-${user.id}`)
    .on(
      "postgres_changes",
      { event: "*", schema: "public", table: "ambulance" },
      (payload) => {
        switch (payload.eventType) {
          case "INSERT":
            res.json(payload.new);
            break;
          case "UPDATE":
            res.json(payload.new);
            break;
          case "DELETE":
            res.json(payload.old);
        }
      }
    )
    .subscribe((status, error) => {
      if (error) {
        throw error;
      } else {
        console.log(status);
      }
    });
}


Also, here's a Minimal Reproduction Project, so the project structure can be better understood: https://github.com/ambulab-fenix/supabase-ssr-realtime

Thanks in advance to anyone that can give me a hand! 🙏
GitHub
GitHub - ambulab-fenix/supabase-ssr-realtime
Contribute to ambulab-fenix/supabase-ssr-realtime development by creating an account on GitHub.
GitHub - ambulab-fenix/supabase-ssr-realtime
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
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

Realtime not working
SupabaseSSupabase / help-and-questions
4mo ago
Realtime not working
SupabaseSSupabase / help-and-questions
4y ago
Realtime subscriptions not working
SupabaseSSupabase / help-and-questions
8mo ago
Realtime not working properly
SupabaseSSupabase / help-and-questions
4y ago