phoenix-liveview-essentials

Enforce consistent Phoenix LiveView lifecycle and event handling patterns.

149|15|Updated Jan 23, 2026
One-click install
npx skills add https://github.com/j-morgan6/elixir-phoenix-guide --skill phoenix-liveview-essentials-j-morgan6
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: phoenix-liveview-essentials
Source: https://github.com/j-morgan6/elixir-phoenix-guide/tree/main/skills/phoenix-liveview-essentials
Command: npx skills add https://github.com/j-morgan6/elixir-phoenix-guide --skill phoenix-liveview-essentials-j-morgan6

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

LiveView development often suffers from inconsistent patterns, missing lifecycle best practices, and subtle bugs that arise from mounting, rendering, and event handling in the wrong order. This Skill provides a vetted, opinionated set of rules and examples to standardize Phoenix LiveView code across projects.

Core Features & Use Cases

  • A mandatory RULES section with 6-11 non-negotiable patterns that must be followed when writing LiveView modules, ensuring consistent use of @impl, assigned state, and error handling.
  • Lifecycle clarity covering mount/3, handle_params/3, and two-phase rendering to prevent common static vs connected render mistakes.
  • Event handling and info flow guidance for handle_event, handle_info, and safe navigation of PubSub and timers.
  • PubSub and presence best practices to subscribe only when connected and to handle broadcasts safely.
  • Performance and safety patterns like temporary assigns, avoiding heavy work in every phase, and proper component usage.

Quick Start

Read and apply the LiveView essentials before creating mount/handle_event handlers and templates to ensure correct lifecycle usage.

Frequently Asked Questions about phoenix-liveview-essentials

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
What are the best practices for Phoenix LiveView lifecycle management?

Phoenix LiveView lifecycle management requires following strict patterns for mount/3, handle_params/3, and two-phase rendering to prevent common static vs connected render mistakes. This Skill enforces non-negotiable rules ensuring consistent @impl usage, safe assigns, and error handling across these phases.

How do I handle PubSub subscriptions safely in Elixir LiveView?

To handle PubSub safely in Elixir LiveView, you must subscribe only when the socket is connected and handle broadcasts with proper event and info flow guidance. This ensures safe navigation of PubSub and timers without causing memory leaks or race conditions.

Does Phoenix LiveView require explicit @impl usage for event handlers?

Yes, Phoenix LiveView requires explicit @impl usage for event handlers to satisfy lifecycle discipline and prevent subtle bugs. This Skill enforces mandatory patterns for handle_event, handle_info, and other callbacks to standardize module implementations.

How do I prevent rendering bugs during LiveView mount and handle_params?

To prevent rendering bugs during LiveView mount and handle_params, apply lifecycle clarity rules that separate static and connected rendering phases. This Skill enforces proper component composition, temporary assigns, and avoids heavy work in every phase to ensure safe rendering.

Why does my Phoenix LiveView crash when handling PubSub broadcasts?

Your Phoenix LiveView might crash because subscriptions are not restricted to connected sockets or broadcasts are handled without proper error handling. This Skill provides PubSub and presence best practices, including safe broadcast navigation and timer management, to prevent these failures.