I have a usecase where we need to subscribe to a platform event from an external application. I have tried with this using jsforce from bode js and is working fine. But can we achieve this directly with only client side (browser) javascript?

1 Answer 1


As discussed in this thread, its not possible for an external pure client side web application (like static HTML page) to subscribe to platform events due to the simple reasons:

  1. Front and Back End: Any external modern client side applications, called front end applications today e.g. React.JS, Angular.JS, View.JS are not static HTML, they constantly establish communication with a back end application like Node.JS (similar to Salesforce experience cloud site, or normal Salesforce web interface, which connects to multiple background Salesforce servers and apex code/flow/data platform behind the scenes).
  2. Server Need: Platform Event is a Pub/Sub Model. In this case, salesforce is a publisher of messages. However, it requires a constant polling connection (Listener) on the subscriber side. A static client side web page (like HTML) cannot achieve this. Connecting to Salesforce Sandbox/Production and then constantly subscribing (Listening) for event messages will require a dedicated listener process/job on a server which is the node.JS (comet d) in my earlier answer that helps to achieve this.
  3. Security: If at all it was feasible, the security of connections made by the HTML static front end application will hit a limitation of hardcoding salesforce username and password+security token which will be publicly visible using "view source" right click on web page. Modern applications use a wide variety of authentication options like JWT/OAuth solutions which again needs both front and back end applications.

Hence my recommendation is to get connected with the front end SME and identify which front end and back end they're using. You can then refer this article and standard documentation to achieve Pub Sub with Salesforce. To test this, you can create such applications using Heroku if you have the skillset, or get the code from StackExchange or the Internet.

  • 1
    Thanks for the response Commented Dec 16, 2023 at 5:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .