Public
Connect to an Automerge sync server and edit a document
1 Like
1 BranchVal Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
A tiny web app that connects to an Automerge sync server over WebSocket and lets you view and edit a document's contents as JSON.
Val Town can't accept incoming WebSocket connections, and the Automerge sync protocol runs over WebSocket. The trick: Val Town only serves a static client, and the browser opens the WebSocket directly to your sync server. This sidesteps the platform's WebSocket limitation entirely.
Rendering mermaid diagram...
server.ts— HTTP handler. Servesindex.htmland transpilesclient.tsx→/client.js.index.html— page shell (Twind for styling, mounts the React app).client.tsx— the whole app: WASM init, repo connection, JSON editor.
- Open the app.
- Enter your sync server's WebSocket URL (defaults to the public
wss://sync.automerge.org). Point it at your own server, e.g.wss://your-server.example.com. - Either paste an existing document URL (
automerge:...) and click Open document, or click New document to create one. Share the generated URL with another client to collaborate. - Edit the JSON and click Save changes — edits merge into the document and sync to the server. Changes from other clients appear live.
- Automerge's core is WebAssembly. Browsers can't import WASM as an ES module, so the
app loads it manually via
initializeBase64Wasm(the base64 blob variant) before touching the repo — no bundler required. - This editor treats documents as plain JSON objects. For text/rich-text CRDT features you'd use Automerge's text APIs instead.