Skip to Content
JavaScriptJs Realtime

Last Updated: 3/9/2026


PocketBase v0.36.6

Realtime messaging

By default PocketBase sends realtime events only for Record create/update/delete operations (and for the OAuth2 auth redirect), but you are free to send custom realtime messages to the connected clients via the $app.subscriptionsBroker() instance.

$app.subscriptionsBroker().clients() returns all connected subscriptions.Client indexed by their unique connection id.

The current auth record associated with a client could be accessed through client.get("auth")

Note that a single authenticated user could have more than one active realtime connection (aka. multiple clients). This could happen for example when opening the same app in different tabs, browsers, devices, etc.

Below you can find a minimal code sample that sends a JSON payload to all clients subscribed to the “example” topic:

const = new SubscriptionMessage({name: "example", data: JSON. stringify({...}),});// retrieve all clients (clients id indexed map) const =. subscriptionsBroker(). clients() for(let in){if([]. hasSubscription("example")){[]. send()}}

From the client-side, users can listen to the custom subscription topic by doing something like:

import from 'pocketbase'; const = new PocketBase('http://127.0.0.1:8090');... await.. subscribe('example',(e) =>{. log()})

import'package:pocketbase/pocketbase.dart''package:pocketbase/pocketbase.dart'; final = PocketBase('http://127.0.0.1:8090''http://127.0.0.1:8090');... await.. subscribe('example' 'example',(){print()})


Prev: Sending HTTP requests Next: Filesystem