A plugin for the Pusher JavaScript library (v4.1.x) that batches multiple private and presence channel authentication requests into a single HTTP call. Version 0.0.2 is the latest stable release, with low release cadence. It reduces network overhead when subscribing to many channels simultaneously by aggregating auth requests into one POST. Key differentiator: enables batch authentication endpoint (not available in Pusher's default authorizer). Requires Pusher JS 4.1+ and a server endpoint that handles batched requests.
npm install helpscout-pusher-js-authVerified import paths — ran on the pinned version, not inferred.
Initializes Pusher with batch authorizer, subscribes to multiple channels to demonstrate single auth request.
Use version 2.0.0 of this plugin for Pusher 4.0 and older, or upgrade Pusher to >=4.1.0.
Implement a batched auth endpoint that accepts multiple channel_name[] parameters and returns a JSON object per channel.
Set authDelay to a value like 200ms to accumulate subscriptions from different ticks into a single request.
Consider using the original 'pusher-js-auth' package from npm for better community support.
Ensure pusher-js is loaded and initialized (e.g., import Pusher from 'pusher-js') before using the plugin.
If using script tags, include pusher-auth.js after pusher.min.js. If using npm, ensure the package is installed and imported correctly.
Ensure the server returns a JSON object with channel names as keys, each containing status and data fields as documented.