npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

ably-elsolya

v1.0.0

Published

`ably-elsolya` is a framework-agnostic JavaScript/TypeScript wrapper built on top of the official Ably Realtime SDK.

Downloads

86

Readme

ably-elsolya

ably-elsolya is a framework-agnostic JavaScript/TypeScript wrapper built on top of the official Ably Realtime SDK.

This package provides a clean and simple core layer for working with Ably without depending on any specific framework such as Vue, React, Angular, or Nuxt.

The goal of this package is to make Ably usage reusable, maintainable, and easy to extend across different environments.


Why this package

Many Ably integrations are written as:

  • Vue composables
  • React hooks
  • Angular services

These approaches are not reusable across frameworks.

ably-elsolya solves this by:

  • Removing all framework-specific code
  • Exposing pure JavaScript / TypeScript logic
  • Acting as a shared core that can be used everywhere

Installation

npm install ably-elsolya

Install Ably (required peer dependency):

npm install ably

Core Idea

The package exposes a single main class:

AblyClient

This class:

  • Creates and manages an Ably Realtime connection
  • Provides access to channels
  • Simplifies publishing and subscribing to messages

No UI logic, no state management, and no framework dependencies.


Source Code

import { Realtime } from 'ably'

export class AblyClient {
  private client: Realtime

  constructor(apiKey: string) {
    this.client = new Realtime(apiKey)
  }

  channel(name: string) {
    return this.client.channels.get(name)
  }

  publish(channel: string, event: string, data: any) {
    return this.channel(channel).publish(event, data)
  }

  subscribe(channel: string, callback: (msg: any) => void) {
    this.channel(channel).subscribe(callback)
  }
}

Code Explanation

Importing Realtime

import { Realtime } from 'ably'

Imports the official Ably Realtime client responsible for creating and maintaining a real-time connection with Ably servers.


AblyClient class

The AblyClient class acts as a wrapper around the Ably Realtime client.

  • It hides direct access to the Ably SDK
  • It exposes a simpler and controlled API
  • It keeps the implementation framework-independent

constructor(apiKey: string)

Creates a new Ably Realtime connection using your API key.

const ably = new AblyClient('YOUR_ABLY_API_KEY')

You should usually create one instance and reuse it across your application.


channel(name: string)

Returns an Ably channel instance.

const channel = ably.channel('chat-room')

If the channel already exists, the same instance is returned. If not, Ably creates it internally.


publish(channel: string, event: string, data: any)

Publishes a message to a specific channel.

ably.publish('chat-room', 'message', {
  text: 'Hello world'
})

Parameters:

  • channel: Channel name
  • event: Event name
  • data: Message payload

subscribe(channel: string, callback: Function)

Subscribes to messages on a channel.

ably.subscribe('chat-room', msg => {
  console.log(msg.data)
})

The callback receives an Ably message object containing event name, data, timestamp, and metadata.


Full Usage Example

import { AblyClient } from 'ably-elsolya'

const ably = new AblyClient('YOUR_ABLY_API_KEY')

ably.subscribe('chat-room', msg => {
  console.log('Received message:', msg.data)
})

ably.publish('chat-room', 'message', {
  text: 'Hello from ably-elsolya'
})

Usage with Frameworks

This package works with any framework because it contains no framework-specific code.

React / Next.js

const ably = new AblyClient(process.env.NEXT_PUBLIC_ABLY_KEY)

Vue / Nuxt

const ably = new AblyClient(import.meta.env.VITE_ABLY_KEY)

Angular

const ably = new AblyClient('API_KEY')

What this package does NOT include

  • Vue composables
  • React hooks
  • Angular services
  • State management
  • UI logic

This design keeps the package lightweight and reusable.


License

Ahmed Niazy 01096710328