Here’s an example of how to create, encode, decode, and restore a snapshot. Hope this helps!
https://codesandbox.io/p/devbox/yjs-snapshot-mk3yc4