We’re on Product Hunt (opens in a new tab)

Client SDK · Mobile, web & desktop

Flutter / Dart SDK

Dart 3.4+ or a compatible Flutter SDK. Supports web, mobile and desktop. Android release builds need android.permission.INTERNET.

Install from GitHub

The SDK source is public on the main branch. Use the release installation instructions below; source branches can differ from published packages.

Installation
# In pubspec.yaml:
dependencies:
  pubb:
    git:
      url: https://github.com/pubbio/sdk-dart.git
      ref: main

# Then run flutter pub get or dart pub get.

Commit pubspec.lock in your application to pin the resolved revision.

Subscribe to events

Use your public app key from the Pubb dashboard. Subscribe before publishing a matching event from your trusted backend.

realtime.dart
import 'package:pubb/pubb.dart';

void startRealtime(Pubb pubb) {
  pubb.errors.listen((error) => print(error));
  pubb.subscribe('notifications').on('message.sent').listen((data) => print(data));
  pubb.connect();
}
// Own Pubb(appKey: 'YOUR_PUBLIC_APP_KEY') outside widget build().
// On teardown, cancel listeners and call pubb.dispose().

connect starts asynchronously; observe states or read state and socketId. disconnect retains channels for later reuse, while dispose permanently closes the client. Automatic reconnect attempts are bounded. Refresh durable state after reconnecting.

Private and presence channels

Create HttpChannelAuthorizer with your authenticated backend URL and a callback for current session headers, then pass auth.call as authorizer to Pubb. Close the authorizer when its owner ends. Observe the presence channel's members and pubb:member_added / pubb:member_removed events.

Your backend receives socket_id and channel_name, checks the authenticated user’s access, and returns auth plus channel_data for presence. Derive the presence user ID from the session and forward the signed channel_data unchanged.

Keep the app secret on your trusted server. Public channels must not carry personal or restricted data. Read the WebSocket Protocol Reference for channel authorization and exact wire messages.

Client events

Applications can opt into scoped WebSocket publishing. The updated JavaScript and Unity clients accept a separate publishing permission; JavaScript and .NET server helpers issue it after your access checks. Other SDK releases can use the documented wire protocol. Read Client events for setup, expiry, revocation and acknowledgement semantics.

Verify your integration

  1. Subscribe to notifications in your app or the dashboard’s Live console.
  2. Publish message.sent to the same application and channel from your backend.
  3. Check the event payload, connection cleanup and recovery after a disconnect. Test denied access as well as successful private subscriptions.

The repositories include automated tests and examples. Verify end-to-end delivery with your own application before sending production traffic. Refetch durable state after reconnecting; missed events are not replayed.