{"id":18413,"library":"helpscout-pusher-js-auth","title":"Pusher Batch Auth Plugin","description":"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.","status":"active","version":"0.0.2","language":"javascript","source_language":"en","source_url":"git://github.com/helpscout/pusher-js-auth","tags":["javascript","pusher","client","auth"],"install":[{"cmd":"npm install helpscout-pusher-js-auth","lang":"bash","label":"npm"},{"cmd":"yarn add helpscout-pusher-js-auth","lang":"bash","label":"yarn"},{"cmd":"pnpm add helpscout-pusher-js-auth","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency; plugin is an authorizer for Pusher JS library, requires version 4.1.x","package":"pusher-js","optional":false}],"imports":[{"note":"ESM default import; CJS require also works but is not recommended for bundlers. The global variable is 'PusherBatchAuthorizer' when using script tags.","wrong":"const PusherBatchAuthorizer = require('pusher-js-auth');","symbol":"PusherBatchAuthorizer","correct":"import PusherBatchAuthorizer from 'pusher-js-auth';"},{"note":"CJS require; named import is incorrect because the package exports a single default.","wrong":"import { PusherBatchAuthorizer } from 'pusher-js-auth';","symbol":"PusherBatchAuthorizer","correct":"const PusherBatchAuthorizer = require('pusher-js-auth');"},{"note":"Script tag usage: the plugin exposes 'PusherBatchAuthorizer' globally. Node_modules path is fragile; use the provided lib file after building.","wrong":"<script src=\"node_modules/pusher-js-auth/dist/pusher-auth.js\"></script>","symbol":"PusherBatchAuthorizer","correct":"<script src=\"lib/pusher-auth.js\"></script>"}],"quickstart":{"code":"import Pusher from 'pusher-js';\nimport PusherBatchAuthorizer from 'pusher-js-auth';\n\nconst pusher = new Pusher('YOUR_APP_KEY', {\n  cluster: 'us2',\n  authorizer: PusherBatchAuthorizer,\n  authDelay: 200,\n  authEndpoint: 'https://example.com/pusher/auth',\n});\n\nconst channel1 = pusher.subscribe('private-channel-1');\nconst channel2 = pusher.subscribe('presence-channel-2');\n\nchannel1.bind('pusher:subscription_succeeded', () => {\n  console.log('Subscribed to channel1');\n});\nchannel2.bind('pusher:subscription_succeeded', () => {\n  console.log('Subscribed to channel2');\n});\n\n// The plugin will batch both auth requests into a single HTTP call.","lang":"javascript","description":"Initializes Pusher with batch authorizer, subscribes to multiple channels to demonstrate single auth request."},"warnings":[{"fix":"Use version 2.0.0 of this plugin for Pusher 4.0 and older, or upgrade Pusher to >=4.1.0.","message":"Version 0.0.2 is only compatible with Pusher 4.1.x and above. Using older Pusher versions will cause issues.","severity":"breaking","affected_versions":">=0.0.0"},{"fix":"Implement a batched auth endpoint that accepts multiple channel_name[] parameters and returns a JSON object per channel.","message":"The server endpoint must handle batched requests. If it expects single channel auth, batch subscriptions will fail.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Set authDelay to a value like 200ms to accumulate subscriptions from different ticks into a single request.","message":"authDelay defaults to 0; if subscriptions are triggered in separate ticks, multiple requests may still occur. Increase delay to batch across ticks.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Consider using the original 'pusher-js-auth' package from npm for better community support.","message":"Package is on npm as 'helpscout-pusher-js-auth' but the plugin's original repository is 'pusher-js-auth'. The npm package may be a fork.","severity":"deprecated","affected_versions":">=0.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Ensure pusher-js is loaded and initialized (e.g., import Pusher from 'pusher-js') before using the plugin.","cause":"Pusher library not loaded before the plugin or incorrect initialization.","error":"Uncaught TypeError: pusher.subscribe is not a function"},{"fix":"If using script tags, include pusher-auth.js after pusher.min.js. If using npm, ensure the package is installed and imported correctly.","cause":"Plugin script not loaded or incorrect import path.","error":"PusherBatchAuthorizer is not defined"},{"fix":"Ensure the server returns a JSON object with channel names as keys, each containing status and data fields as documented.","cause":"The batched auth endpoint returned an unexpected JSON format.","error":"Server returned invalid auth response"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}