← Topics

Migrate Rails from Pusher: keep the pusher gem, change the host

Move a Rails app off Pusher Channels: set the pusher gem’s host, add wsHost to pusher-js, publish to both services while pages reload, and keep your auth and webhook code.

A Rails app that publishes to Pusher Channels with the pusher gem can move to a Pusher-compatible service by changing where that gem sends its requests. Your Pusher.trigger calls, the auth action and the pusher-js code in your views keep working; the gem, pusher-js and Turbo stay where they are.

What changes and what stays

Step 1: point the gem at the new host

The gem sends to api-CLUSTER.pusher.com unless you give it a host. Set one in config/initializers/pusher.rb and keep the credentials in your environment or Rails credentials:

require 'pusher'

Pusher.app_id = ENV.fetch('PUSHER_APP_ID')
Pusher.key = ENV.fetch('PUSHER_APP_KEY')
Pusher.secret = ENV.fetch('PUSHER_APP_SECRET')
Pusher.host = ENV.fetch('PUSHER_HOST', 'ws.hibira.io')

HTTPS on port 443 is the gem's default, so there is nothing else to set. If you build clients with Pusher::Client.new, pass host: there instead. The options are in the pusher-http-ruby README, checked on 2026-11-18.

Step 2: point pusher-js at it

Wherever your layout or a Stimulus controller creates the client, add the host:

const pusher = new Pusher(window.PUSHER_KEY, {
  cluster: 'mt1',
  wsHost: 'ws.hibira.io',
  wsPort: 443,
  wssPort: 443,
  forceTLS: true,
  enabledTransports: ['ws', 'wss'],
  channelAuthorization: { endpoint: '/pusher/auth', transport: 'ajax' },
});

The cluster value is required by pusher-js but not used once wsHost is set. Your auth action stays as it is:

class PusherController < ApplicationController
  def auth
    channel = params[:channel_name]
    return head :forbidden unless current_user.can_join?(channel)

    render json: Pusher.authenticate(channel, params[:socket_id],
      user_id: current_user.id, user_info: { name: current_user.name })
  end
end

Step 3: switch without a gap

Pages already open keep their Pusher connection until they reload. For a day or two, publish to both from one place, such as a small wrapper or a job:

LEGACY = Pusher::Client.new(app_id: ENV['OLD_PUSHER_APP_ID'], key: ENV['OLD_PUSHER_KEY'],
                            secret: ENV['OLD_PUSHER_SECRET'], cluster: ENV['OLD_PUSHER_CLUSTER'])

def broadcast(channel, event, data)
  Pusher.trigger(channel, event, data)
  LEGACY.trigger(channel, event, data)
end

Remove LEGACY when Pusher's dashboard shows no more connections.

Step 4: webhooks

Add your webhook URL on the new app. Pusher.webhook(request).valid? checks the same X-Pusher-Key and X-Pusher-Signature headers, so the controller stays.

Using Turbo Streams or Action Cable?

If your live updates come from broadcasts_to and turbo_stream_from rather than Pusher, the hibira-rails gem sends Turbo Stream broadcasts through Hibira, with no Action Cable server or Redis to run. For other Ruby code, the Ruby guide shows the gem on its own.

Questions

Do I have to replace the pusher gem?

No. The official gem takes a host, so you keep it, along with trigger, trigger_batch, authenticate, channel_info and webhook.

Why does pusher-js still connect to Pusher?

The browser code still has the old key or no wsHost. Check the key and host you render into the page, and that cached JavaScript has been replaced.

Can I publish from Active Job or Sidekiq?

Yes. Publishing is an HTTP request from the gem, so it works from any job. Sending from a job also keeps requests from waiting on the network.

What about Pusher Beams push notifications?

Hibira's push notifications use a Beams-compatible API for iOS, Android and the web; the push notifications guide shows the setup.

Product names are trademarks of their owners.