Build real-time applications with PubNub pub/sub messaging
Agent Success
Agent success rate when using this tile
94%
Improvement
Agent success rate improvement when using this tile compared to baseline
1.29x
Baseline
Agent success rate without this tile
73%
You are building a real-time analytics dashboard that runs in the browser. The dashboard needs to connect to PubNub to receive live data updates. Multiple pages/components in the single-page application will need access to the PubNub connection. Users log in with an authenticated account before seeing the dashboard.
Write a JavaScript module (pubnub-client.js) that initializes and exports a configured PubNub client for use throughout a browser-based single-page application. The module should handle user identification properly for a production environment where users have authenticated accounts.
pubnub-client.js file that initializes and exports a PubNub instance ready for use across the application.