Bubble has built-in real-time data updates via its database-to-element binding, but for faster real-time communication like chat or live dashboards, you can use WebSocket plugins or external services like Pusher or Ably. This tutorial covers Bubble's native real-time capabilities and how to extend them with WebSocket integrations.
Overview: Real-Time Communication with WebSockets in Bubble
Bubble provides built-in real-time updates: when data changes in the database, elements bound to searches automatically refresh. For many apps, this is sufficient. But when you need sub-second updates — live chat, multiplayer features, real-time dashboards, or live notifications — you may need external WebSocket services. This tutorial covers both approaches.
Prerequisites
- A Bubble app that needs real-time features
- Basic understanding of Bubble data binding and workflows
- An account with a WebSocket service like Pusher (optional, for external approach)
- The Toolbox plugin installed (for JavaScript-based WebSocket connections)
Step-by-step guide
Understand Bubble's built-in real-time updates
Understand Bubble's built-in real-time updates
Bubble's database has native real-time capabilities. When you bind a Repeating Group to a Do a Search for expression, it automatically updates when records are created, modified, or deleted. This happens through Bubble's internal WebSocket connection. Test this by opening two browser tabs of the same page and creating a record in one — the other tab should show the new record within 1-3 seconds without refreshing.
Pro tip: Bubble's built-in real-time only works for data bound to page elements. Searches inside workflows do not auto-update.
Expected result: You understand that Bubble already provides real-time data binding for element-bound searches.
Identify when you need external WebSocket services
Identify when you need external WebSocket services
Bubble's native real-time has limitations: updates take 1-3 seconds (not instant), it only works for data-bound elements, and heavy real-time usage increases WU consumption. You need external WebSockets when you need sub-second message delivery (live chat), presence detection (showing who is online), real-time typing indicators, live cursor tracking, or when Bubble's polling creates too much WU overhead.
Expected result: You can evaluate whether Bubble's native real-time is sufficient or if you need external WebSocket services.
Set up Pusher as an external WebSocket service
Set up Pusher as an external WebSocket service
Sign up at pusher.com and create a Channels app. Note your app_id, key, secret, and cluster. In Bubble, go to the Plugins tab and install the Toolbox plugin if not already installed. Create an API Connector call to Pusher's HTTP API for triggering events. Set the method to POST, URL to https://api-{cluster}.pusher.com/apps/{app_id}/events, and configure authentication using your Pusher credentials.
1{2 "name": "new-message",3 "channel": "chat-room-123",4 "data": {5 "message": "Hello!",6 "sender": "user_abc",7 "timestamp": "2026-03-28T15:00:00Z"8 }9}Expected result: Pusher is configured and ready to receive events from your Bubble backend workflows.
Subscribe to real-time events on the client side
Subscribe to real-time events on the client side
On the page where users need real-time updates, add a Page is loaded workflow with a Run JavaScript action from the Toolbox plugin. Load the Pusher JavaScript client library and subscribe to your channel. When a new event arrives, use the JavaScript to Bubble bridge to pass the data back to Bubble, then display it using custom states or trigger a custom event. This creates a persistent connection that receives messages instantly.
1// Load Pusher client (add to page header or Run JavaScript)2var pusher = new Pusher('YOUR_PUSHER_KEY', { cluster: 'us2' });3var channel = pusher.subscribe('chat-room-123');4channel.bind('new-message', function(data) {5 // Pass data back to Bubble via JavaScript to Bubble bridge6 bubble_fn_newMessage(JSON.stringify(data));7});Expected result: The page listens for real-time events and receives them instantly when triggered.
Trigger events from backend workflows
Trigger events from backend workflows
When an action occurs that should notify other users in real time (e.g., a new chat message is sent), add the API Connector call to Pusher in your workflow. Pass the channel name and event data. Pusher broadcasts the event to all connected clients on that channel. Combine this with database writes — save the message to your database AND trigger the Pusher event so that users see it instantly while the database record is also persisted.
Expected result: Actions in your app trigger instant real-time notifications to all connected users on the relevant channel.
Build a real-time notification system
Build a real-time notification system
Create a Notification Data Type with fields for recipient (User), message (text), read (yes/no), and type (Option Set). When an event occurs (new order, new message, etc.), create a Notification record AND trigger a Pusher event on a user-specific channel (e.g., user-{unique_id}). On the frontend, subscribe to the user's channel and update a notification counter custom state when events arrive. Display unread notifications in a dropdown with a Repeating Group.
Expected result: Users receive instant notifications when relevant events occur, with a live-updating counter.
Complete working example
1REAL-TIME COMMUNICATION SUMMARY2=================================34APPROACH 1: Bubble's Built-in Real-Time (simplest)5 - Bind Repeating Groups to Do a Search for6 - Data auto-refreshes when records change7 - Latency: 1-3 seconds8 - No additional setup needed9 - Best for: dashboards, lists, activity feeds1011APPROACH 2: External WebSocket Service (Pusher/Ably)12 Setup:13 1. Create Pusher account, get credentials14 2. API Connector: POST to Pusher trigger API15 3. Toolbox: Load Pusher JS client on page load16 4. Subscribe to channels, bind events1718 Backend → Pusher (trigger event):19 API Connector POST:20 URL: https://api-{cluster}.pusher.com/apps/{id}/events21 Body: { name, channel, data }2223 Pusher → Frontend (receive event):24 Run JavaScript:25 pusher.subscribe('channel').bind('event', callback)26 → bubble_fn_handler(data)2728NOTIFICATION SYSTEM:29 Data Type: Notification30 - recipient (User)31 - message (text)32 - read (yes/no, default: no)33 - type (Option Set: Order, Message, Alert)34 - Created Date (auto)3536 On event (e.g., new order):37 1. Create Notification record in DB38 2. Trigger Pusher event on user-{recipient_id} channel39 3. Frontend: increment notification counter custom state4041 Notification UI:42 - Bell icon with badge showing unread count43 - Dropdown Repeating Group: Search Notifications44 where recipient = Current User AND read = no45 - Mark as read on click: Make Changes → read = yes4647WHEN TO USE WHICH:48 Built-in: <3 sec latency OK, data-driven updates49 Pusher/Ably: sub-second needed, chat, typing indicators50 Both: combine for data persistence + instant deliveryCommon mistakes
Why it's a problem: Trying to use WebSockets for everything instead of leveraging Bubble's built-in real-time
How to avoid: Start with Bubble's built-in real-time. Only add external WebSockets for features that specifically need sub-second delivery.
Why it's a problem: Not persisting data alongside real-time events
How to avoid: Always save data to the database AND trigger the WebSocket event. The database serves as the source of truth.
Why it's a problem: Exposing WebSocket credentials in client-side code
How to avoid: Only the public key should be in client-side code. Keep the secret key in backend workflows and API Connector calls.
Best practices
- Start with Bubble's built-in real-time data binding before adding external services
- Always persist data to the database alongside WebSocket events for reliability
- Use user-specific channels for private notifications (e.g., user-{unique_id})
- Keep WebSocket secret keys in backend workflows, never in client-side JavaScript
- Implement reconnection logic in your JavaScript to handle dropped connections
- Monitor WebSocket connection counts and message volumes to stay within service limits
Still stuck?
Copy one of these prompts to get a personalized, step-by-step explanation.
I'm building a Bubble.io app that needs real-time features: a live chat and instant notifications. Bubble's built-in real-time is too slow for chat messages. How do I integrate Pusher or a similar WebSocket service with Bubble?
Add real-time chat to my app using Pusher. I need messages to appear instantly for all users in a chat room. Set up the Pusher integration with API Connector for triggering events and JavaScript for receiving them.
Frequently asked questions
Does Bubble have built-in WebSocket support?
Bubble uses WebSockets internally for its real-time data binding, but does not expose raw WebSocket connections to builders. For custom WebSocket needs, you must use an external service.
How fast is Bubble's built-in real-time?
Typically 1-3 seconds for data changes to appear in bound elements. This is sufficient for dashboards and activity feeds but too slow for live chat.
Which WebSocket service should I use?
Pusher is the most popular choice for Bubble integration. Ably and Socket.IO are alternatives. Choose based on pricing, geographic coverage, and your expected message volume.
Does real-time communication increase my WU usage?
Bubble's built-in real-time uses WUs for each data refresh. External WebSocket services handle the real-time transport externally, potentially reducing WU usage compared to frequent database polling.
Can I build a chat app using only Bubble's native features?
Yes, for basic chat. Store messages in a Data Type and display in a Repeating Group. Messages appear within 1-3 seconds. For instant delivery, add Pusher. RapidDev can help build production-grade real-time features in Bubble.
How do I handle users going offline and coming back online?
The Pusher client automatically reconnects when the connection drops. When users come back online, load missed messages from the database (your source of truth) and display them in the Repeating Group.
Talk to an Expert
Our team has built 600+ apps. Get personalized help with your project.
Book a free consultation