Learn how to build interactive, real-time UIs with Phoenix LiveView using minimal JavaScript
Learn how to build interactive, real-time UIs with Phoenix LiveView using minimal JavaScript.
Phoenix LiveView lets you build rich, interactive, real-time UIs with minimal JavaScript—most interactivity comes from the Elixir backend over a single persistent WebSocket.
React runs in the browser and updates UI with JS.
LiveView runs most UI logic on the server, sending DOM diffs over a socket—browser just patches DOM; state is held on the server.
router.ex
, use live "/products-live", ProductLive.Index
ShopWeb.ProductLive.Index
) using use ShopWeb, :live_view
mount/3
(like React’s useEffect on mount): fetch data, assign staterender/1
using HEEx (& the ~H
sigil) for HTMLhandle_event/3
(e.g., “like”, “dislike”), mutate assigns, and update UI via socket assignphx-click
, phx-value-*
) to trigger server events and pass data from the clientphoenix_live_view_test
helpers like live/2
, render_click/3
in your test modulesliveSocket.enableLatencySim(ms)
in the browser console to see effect of geographic distancesphx-click
, phx-blur
, phx-focus
, phx-submit
, phx-change
, etc.—hook user events directly to Elixir handlersPhoenix LiveView empowers you to build server-driven, reactive UIs—with little JS and mucho Elixir. It unifies complex frontend interactivity with testable Elixir code, featuring built-in event handling, flexible state, and developer aides for rapid feedback and robust test suites.