Getting Started

Counter

Assigns become props; clicks become handle_event

  • props
  • phx-click
  • local state

Key concepts

Every assign that is not a reserved name is passed to React as a prop. count lives on the server; the step slider lives in React's useState, and the server never sees it.

0

How it works

Clicking a button calls pushEvent("set_count", …), which reaches handle_event/3 exactly as phx-click would. The server reassigns count, LiveReact diffs the props and sends only what changed, and React re-renders.

Dragging the slider changes nothing on the server — that is the point. Local UI state stays local, and only what the server owns round-trips.