Esta página se muestra en inglés. Una traducción al español está en curso.
ConfigsMay 16, 2026·3 min de lectura

Phoenix LiveView — Rich Real-Time UIs Without JavaScript

Phoenix LiveView is an Elixir library that enables real-time, server-rendered interactive web interfaces over WebSocket, eliminating the need for a separate JavaScript frontend framework.

Listo para agents

Este activo puede ser leído e instalado directamente por agents

TokRepo expone un comando CLI universal, contrato de instalación, metadata JSON, plan según adaptador y contenido raw para que los agents evalúen compatibilidad, riesgo y próximos pasos.

Native · 98/100Política: permitir
Superficie agent
Cualquier agent MCP/CLI
Tipo
Skill
Instalación
Single
Confianza
Confianza: Established
Entrada
Phoenix LiveView
Comando CLI universal
npx tokrepo install 91432155-5166-11f1-9bc6-00163e2b0d79

Introduction

Phoenix LiveView enables rich, real-time user experiences with server-rendered HTML. By maintaining a persistent WebSocket connection between browser and server, LiveView can push DOM updates in milliseconds without writing custom JavaScript. State lives on the server in an Elixir process, giving you the full power of the BEAM VM for concurrency, fault tolerance, and distributed computing.

What Phoenix LiveView Does

  • Renders initial HTML on the server and establishes a WebSocket connection
  • Pushes minimal DOM diffs to the browser when server state changes
  • Handles user events (clicks, form inputs, key presses) via the WebSocket
  • Supports file uploads, client hooks, and JS interop for complex interactions
  • Provides real-time form validation and live navigation without page reloads

Architecture Overview

Each LiveView is a GenServer process on the BEAM VM. On first request, the server renders full HTML and sends it to the browser. Once connected via WebSocket, user events flow to the process, which updates its assigns (state), re-renders the template, and diffs the new HTML against the previous render. Only changed DOM nodes are sent as a compact binary patch, which the client-side JavaScript library applies to the page.

Self-Hosting & Configuration

  • LiveView is included in new Phoenix projects by default (Phoenix 1.6+)
  • Configure the WebSocket endpoint in endpoint.ex with transport options
  • Set connect_info for session data, CSRF tokens, and user identification
  • Tune process limits and WebSocket timeouts in config/runtime.exs
  • Deploy on any server with Elixir installed, or use Docker with the official Elixir image

Key Features

  • Server-rendered real-time UI with no custom JavaScript required
  • Automatic DOM diffing sends only changed bytes over WebSocket
  • Built-in support for file uploads with progress tracking
  • LiveComponents for reusable stateful UI elements
  • Streams API for efficient rendering of large collections without full re-renders

Comparison with Similar Tools

  • Hotwire (Turbo + Stimulus) — Hotwire augments server-rendered HTML with JS sprinkles; LiveView provides full bidirectional real-time state management
  • HTMX — HTMX adds AJAX/WebSocket via HTML attributes; LiveView manages a persistent stateful server process per connection
  • Laravel Livewire — Livewire brings similar server-driven UI to PHP/Laravel; LiveView leverages Elixir's concurrency for handling millions of connections
  • React/Next.js — React requires a full client-side JS runtime; LiveView ships no application JavaScript
  • Blazor Server — Blazor Server uses a similar WebSocket model in .NET; LiveView benefits from BEAM's lightweight process model

FAQ

Q: How many concurrent connections can LiveView handle? A: Each LiveView is a lightweight BEAM process. A single server can handle hundreds of thousands of concurrent WebSocket connections depending on hardware and state complexity.

Q: Do I need to write any JavaScript? A: For most use cases, no. LiveView handles interactions server-side. For browser-specific APIs (clipboard, geolocation, animations), you can use JS hooks.

Q: What happens when the WebSocket disconnects? A: LiveView automatically reconnects and re-renders the current state. The client shows a connection indicator and queues events during brief disconnections.

Q: Can I use LiveView for mobile apps? A: LiveView Native extends the model to iOS and Android, rendering native UI components driven by server-side Elixir processes.

Sources

Discusión

Inicia sesión para unirte a la discusión.
Aún no hay comentarios. Sé el primero en compartir tus ideas.

Activos relacionados