Skip to main content

Saving and loading canvas with Svelte and Konva

Native Konva can serialize a node tree and its serializable attributes with node.toJSON(). It can restore them with Konva.Node.create(json) (see demo). Restore images, event handlers, and custom drawing functions separately.

With svelte-konva, save the application state instead. The state must contain the data that the stage needs. Do not save Konva internals and nodes.

The demo saves and retrieves JSON data from localStorage. You can use a different storage method.