An event when documents have synced

@dmonad Kevin Jahns
Mon, 29 Sep 2025 10:30:32 +0000

y-websocket should emit the sync event once the client receives all data from the server. If that doesn’t work, it would be a bug.

It could be, that your specific y-websocket implementation syncs before it receives the data from the database (in which case, your backend would sync an empty document). That is a known bug when using y-leveldb, for example.

An easy workaround is to set some kind of flag on the server once the data is fetched. E.g. if (ydoc.getMap().get('isSynced') == null) ydoc.getMap().set('isSynced', true) after it synced with the database. Then you can listen to changes on isSynced on the client.