Not OP, but common solutions in this space represent the state as conflict-free replicated data types (CRDTs). Some popular browser-based libraries for that are Y.js[0] and Automerge[1].
[0]: https://yjs.dev/ [1]: https://automerge.org/
[0]: https://yjs.dev/ [1]: https://automerge.org/
[1]: https://loro.dev/
What features does Loro have that others lack?