I have created one messanger component in Lightning web component where i am saving and getting the messages from Object. I want that once i saved the message it should reflect on every users instance whenever i save.currently the message is showing on other user instances when i reload the page.I dont know how to achieve this in Lightning Web Components .

Please help me to find the solution.

Thanks in advance.

1 Answer 1


One option is to create a Push Topic or Platform event that fires whenever a new record is created in your object, and then use lightning-emp-api to listen to those changes in LWC. However, lightning-emp-api is not supported in communities, or off-platform, and there are limits associated with PushTopics/Platform Events.

The other option (which is my recommendation) is to use WebSockets. For a chat use case, using WebSockets is more appropriate, and your component would work on Communities and Off-Platform. Here is an excellent blog post that explains it in detail.

  • Hi @Aditya Naag. i am glad that you responded.this is really helpful for me.Thank you very much. Can you please clear my one doubt that if i used websocket then do i need to make some changes when i try to deploy it on UAT instance or PRODUCTION environment?? Commented Aug 10, 2021 at 3:30
  • Depends on whether or not you create different Heroku endpoints for different environments. For testing and UAT, the free Heroku dyno should be enough. But for Production, it is recommended that you upgrade to a paid one. Commented Aug 10, 2021 at 5:00
  • ok Aditya will do that. Thank you so much for the help Commented Aug 11, 2021 at 6:04

You must log in to answer this question.

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