Official package · Frameworks
Realtime events from Sinatra
Publish Hibira events, sign channel subscriptions and check webhooks from a Sinatra app with the pusher gem pointed at your Hibira host.
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 Sinatra (pusher) to this project. Follow https://hibira.io/guides/sinatra, 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:
- The pusher gem publishes events and signs private and presence channels.
- Webhooks are checked against the app secret before your code runs.
Sign in to see these snippets with your own cluster host. Sign in
Install
bundle add pusherUse it
require "sinatra" require "pusher" HIBIRA = Pusher::Client.new( app_id: ENV.fetch("HIBIRA_APP_ID"), key: ENV.fetch("HIBIRA_APP_KEY"), secret: ENV.fetch("HIBIRA_APP_SECRET"), host: "ws.hibira.io", port: 443, use_tls: true ) post "/orders/:id/ship" do HIBIRA.trigger("orders", "order.shipped", { id: params[:id].to_i }) 204 end post "/pusher/auth" do halt 403 unless session[:user_id] # check the user may join params[:channel_name] content_type :json HIBIRA.authenticate(params[:channel_name], params[:socket_id]).to_json end post "/hibira/webhooks" do webhook = Pusher::WebHook.new(request, HIBIRA) halt 401 unless webhook.valid? webhook.events.each { |event| logger.info(event["name"]) } 200 end
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 →