Understanding Live Providers
A live provider handles pub/sub functionality for real-time updates:Supported Solutions
Refine has built-in integrations with:- Ably - Real-time messaging platform
- Supabase - PostgreSQL real-time subscriptions
- Hasura - GraphQL subscriptions
- Appwrite - Real-time API
- Custom - Build your own with WebSockets, SSE, etc.
Quick Setup
# Ably
npm install @refinedev/ably ably
# Supabase (already includes live features)
npm install @refinedev/supabase
# For custom WebSocket implementation
npm install socket.io-client
Live Modes
Auto Mode
Automatically refetch data when updates occur:Manual Mode
Receive events without automatic refetch:Off Mode
Disable live updates:Using Live Hooks
In Lists
In Detail Views
In Forms
Publishing Events
Automatic Publishing
Refine automatically publishes events when using mutation hooks:Manual Publishing
Event Subscription
Subscribe to Specific Events
Subscribe to Multiple Channels
Filter Events by ID
Advanced Patterns
Optimistic Updates
Combine with optimistic mutation mode:Presence Detection
Show who’s viewing/editing:Conflict Resolution
Handle concurrent edits:Typing Indicators
Live Notifications
Server-Side Implementation
Event Format
Publish events in this format:Example: Node.js + Socket.io
Best Practices
- Use auto mode for data views - Lists, tables, detail pages
- Use manual mode for critical operations - Forms, editors
- Filter subscriptions by ID - Reduce unnecessary updates
- Handle connection states - Show offline indicators
- Implement reconnection logic - Auto-reconnect on disconnect
- Debounce frequent updates - Prevent UI thrashing
- Clean up subscriptions - Unsubscribe on unmount
- Test offline scenarios - Ensure graceful degradation
Troubleshooting
Events Not Received
- Check live provider is configured
- Verify channel names match
- Ensure
liveModeis not “off” - Check network connection
- Verify server is publishing events
Too Many Refetches
- Use manual mode with controlled refetch
- Implement debouncing
- Filter subscriptions by ID
- Consider batching updates
Memory Leaks
- Always unsubscribe on unmount
- Clean up timers and intervals
- Use proper dependency arrays
Next Steps
- Learn about Tables
- Explore Notifications
- Discover Data Providers