Decypher Yjs update Uint8Array

Hey there!

I am currently trying to implement a history feature that visualizes all the changes made to a YDoc.

E.g. User X updated field Y at time Z.

For that I am trying to make sense of the Yjs Update that is received in the yjs.on(“update”, () => {}) function. I need the information on the update to save a description of what happened, when, by whom.

Is there a better way to implement such a feature or a way to derive the YMapEvent from an update?

Thanks a lot for your help!


Hi, welcome. You can use the undocumented Y.decodeUpdate function to decode an update.

Not sure if that is the best way to create a history view though. Maybe somebody else who has succeeded in this regard can share their approach.

Note that you won’t be able to get the “user” directly from the update. YJS does not have a built-in concept of user. Each update has a clientId which may change from one session to the next. If your user is authenticated, maybe you can store a separate user id with each update.

Also note that YJS has no concept of “time”. It has an ordering mechanism (lamport clocks), but it does not have a centralized 24h clock to determine the human-readable time of each update. If you have a server to synchronize time, or you trust the clients’ local time, then you could store that information in the update yourself.

Hi Raine,

Thanks a lot for your feedback! You are right, I think the decode update is not the best way to built such a history feature. Do you have any Idea how this could be done or know somebody who has solved this problem already?


I don’t, unfortunately.

I know this feature has been requested before, and I know there are people who have solved it. I don’t know if they are here reading this message though ;).

It may be possible to use the UndoManager to recreate the version history.

1 Like

We had the same feature that built the change history as Google doc, please see my comment here Identify ydoc update event - #9 by folencao, hope it helps.

1 Like