I am creating a pretty much same webapp like hashnode where I want a notification system . I am able to change the color of the bell or notifcation icon using websockets but thinking is it right? I am using reactjs in frontend so i am not sure it will be done via socket. My flow is when a like gets clicked it goes to the api and socket emit the event with like dara from db . Now if the auth user is belonging to the recieving end which is in the like data the it will get notified to that user! Is the flow right?
I just tried opening up the developers console and typed socket because the variable wasn't encapsulated it emits a whole data about the current connection, so they do use sockets.
Yes your flow is right.
Consider user X is the one who receives notifications.
Now user Y hits like button and you make a web request to your backend updating the DB. Now you need to push to that socket client of the user X and manage that data on the receiving end.
It doesn't matter if your are using Reactjs or something else. You can do this.
You can give this a try socket.io , npm package npmjs.com/package/socket.io
You can even keep open the network tab and watch how hashnode handles this.
Usual ways to keep client in sync with server are;
So w.r.t building notification system, I'll write down how I do it, might be of help for you:
Cheers!