@rails/actioncable

The client-side JavaScript half of Action Cable, Rails' full-stack framework for building WebSocket-powered realtime features.

Framework
npm
v8.1.400
58,782 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
95 /100 Excellent
Development Activity 100
Maintenance 84
Community 96
Maturity 60
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
88 /100 Excellent
Architecture 90
Code Quality 85
Innovation 75
Learning Curve 100

@rails/actioncable is the browser-side JavaScript client for Action Cable, the full-stack WebSocket framework shipped as part of Ruby on Rails. It establishes and maintains a single WebSocket connection to a Rails server, then lets an app create per-feature Subscriptions to server-defined Channel classes — the same organizing pattern Rails uses for HTTP controllers, but for long-lived, bidirectional connections.

On the server, Channel classes handle subscribe/unsubscribe lifecycle events and expose public methods the client can invoke, while broadcasts fan out to subscribers through a pluggable adapter (Redis, PostgreSQL LISTEN/NOTIFY, in-process async, or a synchronous inline adapter for tests) — letting a Rails app move from single-process development to a horizontally-scaled deployment without changing Channel code. This npm package is published from the same rails/rails monorepo as the Ruby gem, and versions in lockstep with it.

What You Get

  • The @rails/actioncable npm package: a small JS client (Consumer/Connection/Subscriptions) for connecting to and subscribing on an Action Cable server
  • Automatic connection monitoring and reconnection via ConnectionMonitor, with configurable stale-connection thresholds
  • A symmetric server-side Ruby framework (the actioncable gem, published alongside this npm package from the same rails/rails monorepo) providing Channel base classes and pluggable broadcast adapters
  • Rails generators (rails generate channel) that scaffold matching server Channel and client subscription boilerplate

Common Use Cases

  • Real-time chat, notifications, and presence indicators in a Rails app
  • Live-updating dashboards and activity feeds driven by background jobs
  • Collaborative multi-user features like shared live-editing indicators
  • Streaming updates from model callbacks or Active Job out to subscribed clients

Under The Hood

Architecture Action Cable follows a layered pub/sub architecture split across client (JS) and server (Ruby) halves that communicate over a WebSocket protocol. On the server, engine.rb registers the Rails engine, server/base.rb boots a connection manager backed by a server/worker.rb thread pool and server/connections.rb registry; incoming socket frames are parsed in server/socket.rb via nio4r/websocket-driver into JSON messages routed to channel/base.rb subclasses, which mirror ActionController semantics (subscribed/unsubscribed lifecycle callbacks, action dispatch via public methods). Broadcasting fans out through pluggable subscription_adapter/* adapters (redis.rb, postgresql.rb, async.rb, inline.rb) implementing a common Base interface with a SubscriberMap for thread-safe subscriber bookkeeping — this is the core abstraction whose replacement requires no changes to Channel code. The client (app/javascript/action_cable/*) is a parallel state machine: Consumer owns a Connection (WebSocket lifecycle plus reconnect via ConnectionMonitor heartbeats) and a Subscriptions registry managing Subscription instances; message dispatch in connection.js switches on a small message_types protocol (welcome/disconnect/ping/confirmation/rejection) to drive subscription lifecycle callbacks.

Tech Stack The package ships as a dual-runtime component — the npm package (built from app/javascript/action_cable via Rollup into a UMD bundle and an ESM build) plus the actioncable RubyGem, which requires activesupport/actionpack at the exact same Rails version, nio4r for socket I/O, websocket-driver for the WebSocket handshake/framing, and zeitwerk for autoloading. Pluggable pub/sub backends are represented by the subscription_adapter classes — Redis via the redis-client gem, Postgres via LISTEN/NOTIFY. JS-side tooling uses a flat ESLint config for linting and the web-test-runner plus QUnit and mock-socket for browser tests, built and versioned from the same rails/rails monorepo as every other Rails framework component.

Code Quality Extensive dual-language test coverage exists — the Ruby side has dozens of test files across connection/, channel/, server/, and subscription_adapter/ directories, using Rails’ own test-case conventions plus a purpose-built Channel/Connection TestCase and test helper that ships as public API for consumers to test their own channels. The JS side has its own unit tests run through web-test-runner and QUnit with mock-socket standing in for real WebSocket objects. Error handling is explicit and deliberate, with inline comments explaining tricky concurrency edge cases (such as recovering a dead listener thread) and retry/backoff logic around dropped Redis connections. Naming is consistently Rails-idiomatic in Ruby and conventional in JS. Neither language layer is statically typed, but the surrounding rails/rails monorepo runs a full CI matrix against every change.

API Design Action Cable’s developer-experience contribution is making full-duplex realtime feel like ordinary Rails MVC: a Channel class mirrors a Controller (public methods become callable client actions, subscribed/unsubscribed act as lifecycle hooks), and the client API mirrors this symmetry when creating a subscription and defining its received callback. The pluggable adapter layer (Redis/Postgres/async/inline) behind that same Channel abstraction is what lets identical application code scale from a single dev box to a distributed, Redis-backed fleet with no code changes — a meaningful ergonomic win over hand-rolling raw WebSocket handlers, even though the underlying WebSocket and pub/sub technology itself is standard.

Used by 10 apps in this directory

TypeScript
53%
Other

Chaskiq

CRM · Customer Support

3,574

Self-hosted live chat, video calls, help center, and marketing automation — a full-stack Intercom alternative you run on your own infrastructure.

View details
57
Repo Health
66
Technical
66
Dependency
Built with
TypeScript 53%
Ruby 36%
Updated 3 months ago
TypeScript
53%
Other

Chaskiq

CRM · Customer Support

3,574

Self-hosted live chat, video calls, help center, and marketing automation — a full-stack Intercom alternative you run on your own infrastructure.

View details
57
Repo Health
66
Technical
66
Dependency
Built with
TypeScript 53%
Ruby 36%
Updated 3 months ago
TypeScript
53%
Other

Chaskiq

CRM · Customer Support

3,574

Self-hosted live chat, video calls, help center, and marketing automation — a full-stack Intercom alternative you run on your own infrastructure.

View details
57
Repo Health
66
Technical
66
Dependency
Built with
TypeScript 53%
Ruby 36%
Updated 3 months ago
Ruby
50%
Other

Chatwoot

Customer Support

37,254

Open-source omnichannel customer support platform with AI-powered agents, live chat, and self-hosting — a full Intercom and Zendesk alternative.

View details
95
Repo Health
78
Technical
69
Dependency
Built with
Ruby 50%
Vue 25%
JavaScript 22%
Updated 5 days ago
Ruby
50%
Other

Chatwoot

Customer Support

37,254

Open-source omnichannel customer support platform with AI-powered agents, live chat, and self-hosting — a full Intercom and Zendesk alternative.

View details
95
Repo Health
78
Technical
69
Dependency
Built with
Ruby 50%
Vue 25%
JavaScript 22%
Updated 5 days ago
Ruby
50%
Other

Chatwoot

Customer Support

37,254

Open-source omnichannel customer support platform with AI-powered agents, live chat, and self-hosting — a full Intercom and Zendesk alternative.

View details
95
Repo Health
78
Technical
69
Dependency
Built with
Ruby 50%
Vue 25%
JavaScript 22%
Updated 5 days ago
Ruby
64%
AGPL 3.0

Forem

Blogging · Community

22,783

Open source Ruby on Rails platform for building developer communities with articles, discussions, and social profiles—the same software that powers dev.to.

View details
83
Repo Health
79
Technical
67
Dependency
Built with
Ruby 64%
JavaScript 19%
HTML 13%
Updated 6 days ago
Rust
65%
Other

GitButler

AI Development · Developer Tools · Devops

21,726

Git, but better — a modern version control client with stacked branches, parallel workflows, unlimited undo, and first-class support for AI-powered development.

View details
89
Repo Health
84
Technical
66
Dependency
Built with
Rust 65%
TypeScript 22%
Svelte 10%
Updated 4 days ago
Ruby
67%
Other

GitLab

Developer Tools · Devops

24,552

The complete DevOps platform that unifies Git hosting, CI/CD, issue tracking, and security scanning into a single self-hostable application.

View details
87
Repo Health
86
Technical
67
Dependency
Built with
Ruby 67%
JavaScript 20%
Updated 4 days ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers