legend state realtime with auth
Hey all,
I am building a mobile expo app and working on implementing local-first realtime with legend state. I've followed this tutorial.
I've successfully implemented a basic local-first realtime for a simple feature in my app with RLS policies disabled. However, when I enable RLS policies it no longer works.
I am using Clerk for auth (open to moving to supabase if this makes things easier, but this would be a significant refactor so need to make careful decisions). The Clerk JWT is setup correctly, as I am able to query supabase just fine for normal queries. But this does not seem to be working for realtime.
Can someone help me pinpoint the issue with either the legend state setup or the RLS policies? or maybe this just is not possible with Clerk auth?
3 Replies
i am using
postgres_changes rather than broadcast. Is this still recommended?Broadcast from database is recommended.
But you need to set your token either way.
https://supabase.com/docs/guides/realtime/postgres-changes#custom-tokens
thank you for the response! Claude was recommending that as well but good to hear from a human 😓