Official package · Frameworks
Realtime events from Hanami
Register the pusher gem as a Hanami 2 provider, publish Hibira events from actions and operations, and sign channel subscriptions in an action.
pusherRubyGems ↗
Fastest way: one prompt with the Hibira plugin
Install the plugin in your AI coding agent and paste the prompt. The agent signs you in, creates a free app if you need one, writes the code and sends a test event. GitHub ↗
Install the plugin
claude plugin marketplace add hibira-io/agent-plugin claude plugin install hibira@hibiraPaste this prompt
Add Hibira Hanami (pusher) to this project. Follow https://hibira.io/guides/hanami, adapted to how this project is already set up. If I have no Hibira app yet, create a Free one that allows http://localhost so I can test right away. Keep the app key and secret in environment variables, add placeholders to .env.example, and never commit real values or send the secret to a browser. When you are done, send a test event, show me it arriving, and list the files you changed.
Prefer to do it by hand? These are the steps below:
- A provider registers one client; actions and operations get it with Deps.
- An action signs private and presence channels for pusher-js and Laravel Echo.
Sign in to see these snippets with your own cluster host. Sign in
Install
bundle add pusherSet it up
# config/providers/hibira.rb Hanami.app.register_provider(:hibira) do prepare { require "pusher" } start do register "hibira", Pusher::Client.new( app_id: target["settings"].hibira_app_id, key: target["settings"].hibira_app_key, secret: target["settings"].hibira_app_secret, host: "ws.hibira.io", port: 443, use_tls: true ) end end # config/settings.rb: setting :hibira_app_id, setting :hibira_app_key, setting :hibira_app_secretUse it
# app/actions/pusher/auth.rb (config/routes.rb: post "/pusher/auth", to: "pusher.auth") module Bookshelf module Actions module Pusher class Auth < Bookshelf::Action include Deps["hibira"] def handle(request, response) # check the signed-in user may join request.params[:channel_name] first response.format = :json response.body = hibira.authenticate(request.params[:channel_name], request.params[:socket_id]).to_json end end end end end # anywhere: hibira.trigger("orders", "order.shipped", { id: 1042 })
Before you start
- The app secret is shown only once, when you create the app or rotate its secret. Keep it on your server, never in a browser or game build.
- On the Free plan, list every origin your pages load from in the app’s allowed origins (http://localhost:3000 while developing, then your domain). "*" needs a paid plan.
Use the app key from your dashboard; the secret stays on your server. Channels, events and authorization endpoints work exactly as they do with Pusher. Create your free account →