[Help] Supabase Realtime stuck on joining when using multiple components in Next.js
i’m building a cursor map game where when you enter the site your cursor shows to other players. i want to split logic into two components:
- Room → handles showing other players
- MainPlayer → handles movement + sending my position
the problem: with supabase realtime, sometimes it connects and sometimes it gets stuck on joining. docs don’t explain how to handle two connections for the same channel from two separate components in nextjs. anyone know the right way to structure this?
3 Replies
You normally can't open and close the same channel name in two different places in something like useEffect where you shut down the channel when you leave. The channel close from the useEffect can overlap the open from the other and close them both.
so i need to open the connection from one component?
If you are using presence or broadcast where the channel name means something. If postgres changes then you could use different channel names.