Client SDK API

Reference for the @summoniq/summon-flow client library.

Installation

bun add @summoniq/summon-flow

Constructor

new SummonFlow(appKey: string, options?: ConnectionOptions)

Options

OptionTypeDefaultDescription
wsHoststringrealtime.summonflow.comWebSocket server hostname
wsPortnumber443WebSocket port
forceTLSbooleantrueForce TLS connection
channelAuthorizationobjectAuth endpoint config
authorizerfunctionCustom auth function
activityTimeoutnumber120Seconds before ping

Methods

subscribe(name)

Subscribe to a channel. Returns the Channel instance.

unsubscribe(name)

Unsubscribe from a channel.

channel(name)

Get an existing channel by name. Returns undefined if not subscribed.

allChannels()

Returns an object of all subscribed channels.

connect()

Manually open the WebSocket connection.

disconnect()

Close the WebSocket connection.

Channel Methods

bind(event, handler)

Listen for an event on this channel.

unbind(event, handler?)

Remove an event listener.

trigger(event, data)

Send a client event (private/presence channels only).

Connection Events

stream.connection.bind('connected', () => {
console.log(stream.connection.socketId);
});

States: initialized, connecting, connected, unavailable, failed, disconnected.

This public SDK is distributed separately from the hosted console and managed web app.