What is Phoenix LiveView?
Answer
Phoenix LiveView enables rich, real-time user interfaces without writing JavaScript. A LiveView component renders HTML on the server and maintains a persistent WebSocket connection with the browser. When server state changes, LiveView computes a minimal HTML diff and sends it to the browser — which efficiently patches the DOM. Key features: Server-side rendering: initial page load is fast (full HTML). Real-time updates: push updates to the client over WebSocket. Event handling: phx-click, phx-change, phx-submit attributes send DOM events to the server. LiveComponents: stateful, isolated UI components within a LiveView. Streams: efficiently manage large lists without sending all data. Example use cases: forms with live validation, real-time dashboards, search-as-you-type, collaborative tools. LiveView eliminates the need for a separate JavaScript SPA in many cases, reducing complexity and keeping all logic on the server in Elixir.