// `document` calls `getContextRepo` internally to access the closest `Repo`. // alternatively, you may pass in a specific repo as the second parameter constdoc=document<{count?:number}>(docId) constincrement= () => { doc.change((d) =>d.count= (d.count||0) +1) } </script>
<buttonon:click={increment}> count is {$doc?.count||0} </button>
Svelte store for Automerge Repo
Example Usage
For a working example, see the Svelte counter demo.
Example
Contributors
Originally written by Dylan MacKenzie (@ecstatic-morse). *