#local-storage #auto-merge #persistent #document #persisting #adapter #persister

automerge-persistent-localstorage

A web-based localstorage adapter for persisting Automerge documents

4 releases (breaking)

0.4.0 May 13, 2023
0.3.0 Mar 8, 2023
0.2.0 Dec 20, 2022
0.1.0 Sep 26, 2022

#6 in #persisting

MIT license

39KB
677 lines

A persister targetting LocalStorage in the browser.

let storage = web_sys::window()
    .unwrap()
    .local_storage()
    .map_err(LocalStoragePersisterError::StorageError)?
    .unwrap();

let persister = LocalStoragePersister::new(storage, "document".to_owned(), "changes".to_owned(), "sync-states".to_owned())?;
let doc = PersistentAutomerge::load(persister).unwrap();

Dependencies

~14MB
~283K SLoC