JavaScript
Set up Pulses in your JavaScript application
Install the SDK
To install the SDK, you can use npm or yarn. Run the following command:
Initialize the SDK
Subscribe to a channel
To subscribe to a channel, you can use the pusher.subscribe
method. Run the following command:
Bind to an event
To bind to an event, you can use the channel.bind
method. Run the following command:
Publish an event from the server
To publish an event from the server, you can use the trigger
method. Run the following command:
If there isn’t an example in a language that you are familiar with then refer to Pusher’s Channels server libraries page to check if anyone has created one in your language.
Unsubscribe from a channel
To unsubscribe from a channel, you can use the channel.unsubscribe
method. Run the following command:
Disconnect from Pusher
To disconnect from Pusher, you can use the pusher.disconnect
method. Run the following command: