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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@lluzak/reactive_component

v0.9.1

Published

Stimulus controller and renderer for the reactive_component Rails gem

Readme

ReactiveComponent

CI Docs Ruby Rails

Reactive server-rendered components for Rails via ActionCable. Build ViewComponent components that automatically re-render on the client when data changes — no full page reloads needed.

ReactiveComponent compiles your ERB templates to JavaScript at boot time and uses ActionCable to push updates in real time.

Documentation | Quick Start | DSL Reference

Quick Example

class MessageRowComponent < ApplicationComponent
  include ReactiveComponent

  subscribes_to :message
  broadcasts stream: ->(message) { [message.recipient, :messages] }
  live_action :toggle_star
  client_state :selected, default: false

  def initialize(message:)
    @message = message
  end

  private

  def toggle_star
    @message.toggle_starred!
  end
end
<div class="message-row">
  <span><%= @message.sender.name %></span>
  <span><%= @message.subject %></span>
  <button data-action="click->reactive-renderer#performAction"
          data-reactive-renderer-action-param="toggle_star">
    <%= @message.starred? ? "Unstar" : "Star" %>
  </button>
</div>

When the message is updated anywhere in the system, the component re-renders on every connected client automatically.

Installation

Add to your Gemfile:

gem "reactive_component"

Mount the engine in your routes:

# config/routes.rb
mount ReactiveComponent::Engine => "/reactive_component"

Using esbuild, Vite, Rspack, or another bundler instead of importmap? Install the Stimulus controller from npm under the reactive_component alias:

pnpm add reactive_component@npm:@lluzak/reactive_component

See Other bundlers for details.

See the Installation guide for full setup instructions.

Features

  • Declarative DSL — subscribes_to, broadcasts, live_action, client_state
  • Automatic ERB-to-JS compilation — no separate client templates to maintain; compiled on Prism's own tree
  • Compile-time errors, not guesses — anything the compiler can't make reactive raises CompileError naming the source
  • ActionCable-powered live updates — instant re-renders when data changes
  • Secure server actions — HMAC-signed tokens prevent tampering
  • Client-side state — ephemeral UI state managed in the browser
  • Multi-Rails support — tested against Rails 7.1, 7.2, and 8.0

How It Works

ReactiveComponent compiles your ERB templates into JavaScript render functions at boot time: Prism parses the template, and one pass over its tree lifts every Ruby expression to the server and turns the remaining skeleton — literals, conditionals, loops — into JavaScript. When a model changes:

  1. after_commit callbacks (auto-wired by subscribes_to) trigger a broadcast.
  2. The server evaluates only the dynamic expressions from your template and sends compact JSON data over ActionCable.
  3. The client-side Stimulus controller runs the compiled JS template with the new data and updates the DOM.

No full page reload. No custom JavaScript. Your existing ERB templates are the single source of truth.

See the full architecture guide for details.

Advanced Features

  • Nested components -- Render reactive components inside other reactive components. Guide
  • Collection loops -- Use .each in templates with automatic per-item data extraction. Guide
  • Broadcast compression -- Gzip-compress ActionCable payloads for large components. Configuration
  • Notify mode -- Re-render from the server on change, and drop rows that no longer match a filtered list. Guide
  • Derived entities -- Subscribe a component to an object built from several models. Guide

Development

bin/setup
bundle exec rake test
npm run test:js

Releasing

  1. Bump lib/reactive_component/version.rb and package.json to the same version, and date its CHANGELOG.md heading.
  2. Commit Release vX.Y.Z on main, tag vX.Y.Z, and push both.

The tag runs the Release workflow: it checks both versions match the tag, builds the gem, publishes the JS package to npm, and creates the GitHub release with the changelog section and the .gem attached. Push the gem to RubyGems yourself with gem push reactive_component-X.Y.Z.gem.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/lluzak/reactive_component.

License

The gem is available as open source under the terms of the MIT License.