Public
Connect to an Automerge sync server and edit a document
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.

Automerge Editor

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.

How it works

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. Serves index.html and transpiles client.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.

Usage

  1. Open the app.
  2. 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.
  3. 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.
  4. Edit the JSON and click Save changes — edits merge into the document and sync to the server. Changes from other clients appear live.

Notes

  • 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.