Skip to main content

Supabase Realtime

Supabase Realtime lets your app receive instant updates when data changes — perfect for chat apps, live feeds, and collaborative features.

What is Realtime?

Instead of constantly polling for new data, Realtime pushes changes to your app instantly:

Prerequisites


Enabling Realtime

In Supabase Dashboard

  1. Go to Database → Tables
  2. Select your table
  3. Click “Realtime” toggle to enable
Or via SQL:

Basic Subscription

Ask Nativeline:

Subscription Code Pattern


Event Types


Use Cases

Live Chat

Activity Feed

Collaborative Lists

Live Notifications


Filtering Subscriptions

By Column Value

Only listen for messages in a specific chat:

By User

Only listen for the current user’s notifications:

Handling Changes

Insert (New Data)

Update (Modified Data)

Delete (Removed Data)


Unsubscribing

Always clean up subscriptions when leaving a screen:

Realtime + RLS

Realtime respects Row Level Security:
  • Users only receive events for rows they can SELECT
  • Your existing RLS policies apply automatically
  • No additional security configuration needed

Performance Considerations

Don’t subscribe to tables you don’t need. Each subscription uses resources.
Use column filters to reduce events received. Don’t subscribe to all messages if you only need one chat room.
Always unsubscribe when leaving screens. Orphaned subscriptions waste resources.
Supabase handles reconnection automatically, but you may want to refresh data after a reconnection.

Troubleshooting

  • Is Realtime enabled on the table?
  • Are RLS policies allowing SELECT?
  • Is the subscription active?
  • Check Supabase dashboard logs
  • Check filter syntax
  • Verify column name is correct
  • Ensure filter value matches data type
  • May have multiple subscriptions
  • Unsubscribe when view disappears
  • Use unique channel names
Supabase auto-reconnects, but after prolonged disconnection:
  • Refresh data when connection restores
  • Show connection status to user

Example: Building Live Chat

1

Create messages table

  • id (uuid)
  • chat_id (uuid)
  • user_id (uuid)
  • content (text)
  • created_at (timestamp)
2

Add RLS policies

Users can read messages in chats they’re part of.
3

Enable Realtime

Toggle Realtime on the messages table.
4

Subscribe in app

Subscribe to inserts filtered by chat_id.
5

Handle new messages

Append to local array, scroll to bottom.
6

Clean up

Unsubscribe when leaving chat screen.

Next Steps

You now have a complete picture of Supabase:

Authentication

User accounts and sessions

Database

Store and query data

Storage

Upload files

External APIs

Other integrations