Skip to main content
This quickstart guide will get you up and running with Ably Pub/Sub. You’ll establish a realtime connection to Ably and learn to publish and subscribe to messages.

Prerequisites

  1. Sign up for an Ably account.
  2. Create a new app, and create your first API key in the API Keys tab of the dashboard.
  3. Your API key will need the publish and subscribe capabilities.

Step 1: Install the SDK

Install the Ably SDK for your platform:

Step 2: Connect to Ably

Create a realtime client instance using your API key:

Step 3: Get a channel

Channels are used to organize messages into different topics:

Step 4: Subscribe to messages

Subscribe to receive messages published to the channel:

Step 5: Publish a message

Publish a message to the channel:

Complete example

Here’s a complete working example:

Next steps