hibiki_rails
Rails integration for Hibiki signals.
Each browser tab gets its own signal graph, held by an Action Cable channel. An action writes a signal, the effects that read it render their partials again, and the new HTML reaches the page through Turbo Streams or the gem's own JS client. Think of it like LiveView but for Rails. You write Ruby, and the page updates.
Requires Rails >= 8.0 and Ruby >= 3.4.
Installation
# Gemfile
gem "hibiki"
gem "hibiki_rails"Then run the install generator:
bin/rails g hibiki:rails:installImportmap apps are done at this point. Apps with a JS bundler (esbuild, vite, bun, etc.) also need the client from npm:
npm install hibiki-rails
# or
bun add hibiki-railsYour first reactive component
bin/rails g hibiki:rails:stimulus counter static_pagesThis writes a working counter into app/views/static_pages. The component is an ordinary partial, so you can render it anywhere:
<%= render "static_pages/counter" %>Press +1 and watch the count update from the server.
A reactive CRUD resource
The scaffold generators build a resource with a live index (search, filters, sorting, pagination) and edit-in-place rows:
# A new model, like rails g scaffold
bin/rails g hibiki:rails:scaffold Book title:string author:references
# A model you already have: the schema is read for you
bin/rails g hibiki:rails:scaffold_controller Book
# Phlex components in place of ERB templates
bin/rails g hibiki:rails:scaffold Book title:string --phlexRestart the server after your first scaffold run, so Rails picks up the new app/forms and app/queries folders.
You can then use the add-on generators to extend a scaffolded resource, like adding a nested resource to the reactive form:
# Rebuild the form after adding validators to the model
bin/rails g hibiki:rails:form Book
# A dropdown of songs on the album's form, saved through Track
bin/rails g hibiki:rails:multiselect Album Song Track
# Credits nested into the song's form, saved with it in one go
bin/rails g hibiki:rails:nested Song Credit role:string
# A cover image upload on the album's forms
bin/rails g hibiki:rails:upload_field Album coverDocumentation
Full documentation: https://planetaska.github.io/hibiki/rails-introduction/
- Quick start: installation and a first component
- Rails usage: writing a channel by hand
- Generators: the component shapes
- CRUD scaffolding: the scaffold and its add-ons
- The JS client: the client, loading state, keys and focus
Release notes: CHANGELOG.md.
Development
bundle install && bun install
bundle exec rake # Ruby specs + rubocop
bun run test # the JS client's specsCI runs both. The gem and the npm package share one copy of the client (app/assets/javascripts/hibiki.js) and are released together under the same version.
Contributing
Bug reports and pull requests are welcome at https://github.com/planetaska/hibiki-rails. Please keep both suites green, and add a regression spec for any bug fix.