I'm building a web app that uses a react like front-end library and communicates view websockets with a node back-end.
As part of the app, I'm trying to develop a mana bar like component. Clicking a button costs mana, and the mana refills over time. If there is not enough mana, the user cannot click the button.
My question is, how do I sync the mana bar with the back-end? I need the back-end to keep track of the users mana, so a user can't bypass the front-end and send a frame anyway, but I also don't want any lag that would be caused by the back-end sending the front-end "eligable to be clicked" signals
This leads me to believe that the best way to achieve this is for both the front-end and the back-end to keep track of mana separately, but I feel like slight differences over time could cause the two to be very out of sync with each other over time.