Overview
meridian-edge is a Cloudflare Workers runtime for Meridian. It compiles the server to WASM and uses Durable Objects for per-namespace state — one DO instance per namespace, co-located with your users at the edge.
The TypeScript SDK connects to it identically to the native server — same WebSocket protocol, same REST API, same token format.
| Native server | Edge (Cloudflare Workers) | |
|---|---|---|
| Runtime | tokio + axum | Cloudflare Workers (WASM) |
| Storage | sled / PostgreSQL / Redis | Durable Objects KV |
| Scaling | Manual (cluster mode) | Automatic (CF global network) |
| Cold start | None | ~0ms (DO always warm) |
| Deploy | Docker / binary | wrangler deploy |
Prerequisites
- Wrangler CLI —
npm install -g wrangler - Rust with
wasm32-unknown-unknowntarget —rustup target add wasm32-unknown-unknown worker-build—cargo install worker-build- A Cloudflare account (free tier works)
Local development
gen_token binary as the native server):
Connect with the SDK
Production deploy
1. Set your signing key as a secret:https://meridian-edge.<your-subdomain>.workers.dev.
3. Issue tokens from your backend:
Architecture
Each namespace maps to one Durable Object instance:- Worker validates the token (ed25519 signature, namespace check)
- Worker looks up the DO for the namespace via
env.NS_OBJECT.idFromName(namespace) - WebSocket is upgraded and forwarded to the DO
- The DO manages all connected WebSockets and broadcasts deltas on every op
Webhooks
Register a URL to be called on every op applied to a namespace. Useful for triggering backend pipelines, notifications, or audit systems without maintaining a persistent WebSocket.POST to the registered URL with this payload:
X-Meridian-Secret header is included if a secret was registered. Use it to verify the request origin.
WAL & point-in-time recovery
Every op written to a Durable Object is persisted to a write-ahead log before being applied to the CRDT snapshot. This means you can replay ops from any sequence number:wrangler.toml reference
Limitations
- Single DO instance per namespace — no cross-region replication at the application level. Cloudflare handles availability automatically; for strict data residency use DO jurisdictions.
- No Prometheus endpoint — Workers have no long-running process to scrape. Use Cloudflare Analytics Engine or Workers Logpush for equivalent observability.
- Query Engine performance —
POST /v1/namespaces/:ns/queryis fully supported but scans allcrdt:*keys in DO KV on every request. For namespaces with thousands of CRDTs, prefer the native server which can use indexed storage backends. - Live query overhead —
SubscribeQuerysubscriptions are persisted to DO KV (one write per subscription). Each op re-evaluates all matching live queries by scanning DO KV. This is acceptable for typical namespaces; for very high-frequency ops with many live subscribers, the native server’s in-memory registry is more efficient.