Streaming API for Community 'n' Internal, Platform Events subscription using CometD
Salesforce out of the box Streaming API lightning components like lightning-emp-api do not support Salesforce Communities (Community Experience Cloud).
CometD is a great option for these use cases, this supports Streaming API for both Internal and Community uses, lightning emp api is built based this event and message routing bus.
CometD connects to Salesforce like an external application through the Salesforce CometD endpoint.
Implementation of CometD on a Lightning Web Component:
- Download CometD from https://download.cometd.org/
- Not all versions are compatible with Salesforce platform, one version that worked for me is 3.1.1