Skip to main content

Collaborative Counter

A shared counter that synchronizes across browser tabs. Open in two windows, click increment in one, watch both update. No AI—just the synchronization mechanism that powers all Idyllic applications.

Server Code

When any action modifies state, Idyllic broadcasts to every connected client. You don’t write event-emission code. The framework observes property assignments and handles synchronization.

Client Code

Each client generates a random identifier on mount. The UI shows who made each change.

Running the Example

Open http://localhost:3000 in two browser tabs. Click increment in one—both update. The counter value and “last updated by” identifier match in each tab.

Why This Matters

The same primitives that sync this counter also sync streaming LLM output, conversation history, and multi-agent state. The mechanism transfers directly:
  • Push-based updates: Clients don’t poll. Changes push immediately via WebSocket.
  • Automatic broadcast: No event emission code. The framework intercepts property assignments.
  • Sequential execution: Durable Objects process actions one at a time. No race conditions, no locks needed.