Introducing Hub, a realtime framework

Hub icon and splash screen

WebSockets are often used for transmitting data from servers to web browsers and back. However, they can also be used to connect server-side programs, allowing for another way to integrate systems and transmit data between services. For this, we have created a new realtime framework called Hub.

Introducing Hub

Hub is a Node.js framework built using WebSockets, Sarus, and Node.js. It is available from NPM (@anephenix/hub), and you can find out more details about it on GitHub. You can install it via NPM:

Install Hub
npm install @anephenix/hub

Sarus is a JavaScript library for WebSockets. It takes care of issues that you might run into when working with WebSockets, like handling severed connections as an example. As we used it, we realised that we needed to add support for features on the WebSocket server, such as:

  • Handling reconnections when a WebSocket connection is severed
  • Support for channels using a publish/subscribe pattern
  • Authenticate connections & authorise users on channels
  • Control who can send messages to a channel
  • Control who can connect to a WebSocket server based on their IP address or web domain
  • Support for scaling the WebSocket server across multiple servers

As a result, we ended up creating Hub.

What does Hub do?

In short, Hub is a realtime framework using WebSockets and Node.js, that provides the features like:

  • An Isomorphic WebSocket client (it can run in Node.js or in the browser)
  • Bidirectional RPC (remote procedure calls that can be client → server, or server → client)
  • Publish/subscribe (including automatic subscribe/unsubscribe on disconnections/reconnections)
  • Authentication (ensure only authenticated user can access a channel)
  • Control who can send messages to a channel
  • Security (restrict who can connect to the WebSocket server, based on IP address or web domain)
  • Scaling (run the WebSocket server across multiple servers with synchronised state)

Hub is for people who want to craft a bespoke realtime solution for their needs.

Find out more

If you want to explore those features in detail, checkout the README on the GitHub repository.