Ad

Firestore Realtime Updates Or Sockets.io For Live Chat

I need to develop a chat with realtime updates for my web app.

  • Front: React
  • Back: Node
  • Database: Firestore

Today all my data queries are made in my backend through my REST API. I was thinking of using Sockets.IO but saw that Firestore also has data listeners (https://firebase.google.com/docs/firestore/query-data/listen).

Can you help me choosing by pointing out potential pros/cons of each solution?

Note that I never did any realtime chat feature before by myself so I may not see some obvious points. I don't want to start an opinion war and would like to find a solution to my particular problem for an app in production.

For the moment I have:

Firestore data listeners

  • Implementation seems faster but I may not see some things (especially since my authentification is made with JWT on the server and not at all with firestore auth on the client)
  • Offline capabilities out of the box
  • Direct access from the client shall be faster?

Sockets.io

  • More documentation and sources
  • I can migrate if needed
Ad

Answer

Answering my own question.

Things I discovered:

  • Firestore doesn't have a built-in presence system and needs a specific Cloud function that synchronises with realtime firebase to work (https://firebase.google.com/docs/firestore/solutions/presence). I want to notify my users by mails if they are offline so this "hacky" solution is a concern.
  • Didn't find a simple way of using my current stateless auth with JWT to check if the client using firestore is authenticated
Ad
source: stackoverflow.com
Ad