You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

ably

Package Overview
Dependencies
Maintainers
8
Versions
198
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ably

Realtime client library for Ably, the realtime messaging service

2.10.1
latest
Source
npmnpm
Version published
Weekly downloads
149K
-17.21%
Maintainers
8
Weekly downloads
 
Created

What is ably?

Ably is a real-time messaging service that allows you to build powerful real-time applications. It provides features such as pub/sub messaging, presence, message history, and more, making it suitable for chat applications, live updates, and collaborative tools.

What are ably's main functionalities?

Pub/Sub Messaging

This feature allows you to publish and subscribe to messages on a channel. The code sample demonstrates how to publish a message to a channel and subscribe to receive messages from that channel.

const Ably = require('ably');
const realtime = new Ably.Realtime('YOUR_API_KEY');
const channel = realtime.channels.get('test-channel');

// Publishing a message
channel.publish('greeting', 'Hello, world!', (err) => {
  if (err) {
    console.error('Unable to publish message; err = ' + err.message);
  } else {
    console.log('Message successfully sent');
  }
});

// Subscribing to a channel
channel.subscribe('greeting', (message) => {
  console.log('Received message: ' + message.data);
});

Presence

This feature allows you to track the presence of users in a channel. The code sample demonstrates how to enter presence and subscribe to presence events to track when users join the channel.

const Ably = require('ably');
const realtime = new Ably.Realtime('YOUR_API_KEY');
const channel = realtime.channels.get('presence-channel');

// Entering presence
channel.presence.enter('user1', (err) => {
  if (err) {
    console.error('Unable to enter presence; err = ' + err.message);
  } else {
    console.log('Entered presence');
  }
});

// Subscribing to presence events
channel.presence.subscribe('enter', (member) => {
  console.log('Member entered: ' + member.clientId);
});

Message History

This feature allows you to retrieve the history of messages sent on a channel. The code sample demonstrates how to fetch and display past messages from a channel.

const Ably = require('ably');
const realtime = new Ably.Realtime('YOUR_API_KEY');
const channel = realtime.channels.get('history-channel');

// Retrieving message history
channel.history((err, resultPage) => {
  if (err) {
    console.error('Unable to retrieve message history; err = ' + err.message);
  } else {
    resultPage.items.forEach((message) => {
      console.log('Message: ' + message.data);
    });
  }
});

Other packages similar to ably

FAQs

Package last updated on 16 Jul 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts