Pusher to get Real Time Updates For Your WebApp.

Introduction

I recently discovered Pusher that provides real time communication amongst different processes.

I followed this tutorial for a MERN stack based messaging app I am currently working on. With just a few lines of code after setti…


This content originally appeared on DEV Community and was authored by mrsharm

Introduction

I recently discovered Pusher that provides real time communication amongst different processes.

I followed this tutorial for a MERN stack based messaging app I am currently working on. With just a few lines of code after setting up the Pusher project, I was able to receive updates of my MongoDb instance on my frontend.

Basics

Pusher allows you to send and receive events from channels.

Server Side

From the server side, you trigger events based on the event names on a particular channel such as the following:

The library to be used on the server can be installed by the following command:

npm i pusher

Client Side

The client side, you subscribe to particular channels and bind to events both based on the respective names such as the following useEffect:

The library to be used on the client side can be installed by the following command:

npm i pusher-js

Conclusion

To summarize in the context of MERN apps, in your server, you observe changes to your data from MongoDB and send those updates on particular channels and with specific event names. And on your front end, you subscribe to the channel and bind to the event names for your real time updates.

The setup was smooth and the free tier benefits are definitely generous with great documentation.

I'd be interested to hear about your experience with other similar technologies or any other information about Pusher.


This content originally appeared on DEV Community and was authored by mrsharm


Print Share Comment Cite Upload Translate Updates
APA

mrsharm | Sciencx (2021-11-07T09:36:25+00:00) Pusher to get Real Time Updates For Your WebApp.. Retrieved from https://www.scien.cx/2021/11/07/pusher-to-get-real-time-updates-for-your-webapp/

MLA
" » Pusher to get Real Time Updates For Your WebApp.." mrsharm | Sciencx - Sunday November 7, 2021, https://www.scien.cx/2021/11/07/pusher-to-get-real-time-updates-for-your-webapp/
HARVARD
mrsharm | Sciencx Sunday November 7, 2021 » Pusher to get Real Time Updates For Your WebApp.., viewed ,<https://www.scien.cx/2021/11/07/pusher-to-get-real-time-updates-for-your-webapp/>
VANCOUVER
mrsharm | Sciencx - » Pusher to get Real Time Updates For Your WebApp.. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/11/07/pusher-to-get-real-time-updates-for-your-webapp/
CHICAGO
" » Pusher to get Real Time Updates For Your WebApp.." mrsharm | Sciencx - Accessed . https://www.scien.cx/2021/11/07/pusher-to-get-real-time-updates-for-your-webapp/
IEEE
" » Pusher to get Real Time Updates For Your WebApp.." mrsharm | Sciencx [Online]. Available: https://www.scien.cx/2021/11/07/pusher-to-get-real-time-updates-for-your-webapp/. [Accessed: ]
rf:citation
» Pusher to get Real Time Updates For Your WebApp. | mrsharm | Sciencx | https://www.scien.cx/2021/11/07/pusher-to-get-real-time-updates-for-your-webapp/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.