/phoenix-live-islands:phoenix-live-islandsfrom phoenix-live-islands
Use when embedding a small, self-contained LiveView into an otherwise dead (controller-rendered) Phoenix page with live_render/3, when a controller page needs one dynamic card or widget without converting the whole route to a LiveView, or when debugging an embedded LiveView that renders statically but never connects.
Ships in phoenix-live-islands. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
A "live island" embeds an independent LiveView into a controller-rendered page
with live_render(@conn, Module, ...). The host page remains static HTML. The
shared LiveSocket joins a channel and starts a process for each island, updating
only that island's DOM subtree.
Use an island when:
Do not use one when:
push_patch, push_navigate, or URL-driven state.Phoenix.LiveView.JS or a hook.Embed the island in the dead template. Pass only identifiers through :session.
Use an explicit :id when tests or diagnostics need a stable selector.
<div class="grid gap-6 lg:grid-cols-2">
<div class="card">...dead controller content...</div>
{live_render(@conn, MyAppWeb.AccountStatsLive,
id: "account-stats",
session: %{"account_id" => @account.id}
)}
</div>
Disable the layout, authenticate from the session, and defer expensive reads:
defmodule MyAppWeb.AccountStatsLive do
use MyAppWeb, :live_view
@impl true
def mount(_params, %{"user_token" => token, "account_id" => account_id}, socket) do
current_user = Accounts.get_user_by_session_token(token)
account = Accounts.get_account_for_user!(current_user, account_id)
socket =
assign_async(socket, :stats, fn ->
{:ok, %{stats: Stats.for_account(account.id)}}
end)
{:ok, socket, layout: false}
end
@impl true
def render(assigns) do
~H"""
<div class="card">
<.async_result :let={stats} assign={@stats}>
<:loading>Loading statistics...</:loading>
<:failed :let={_reason}>Statistics temporarily unavailable.</:failed>
<div class="text-2xl font-bold">{stats.total}</div>
</.async_result>
</div>
"""
end
end
Adapt the authentication functions and session key to the application.
layout: false from mount/3, or define a layout-free
:live_island macro in web.ex.:not_mounted_at_router as the
first argument to mount/3, not a params map. Match _params.live_session hooks do not protect the island's connected mount.
Authenticate from the Plug session and authorize resource ids in mount/3 and
again in mutating handle_event/3 callbacks.:session option are signed,
not encrypted. Pass serializable identifiers, never structs, credentials, or
sensitive values.socket.router is nil, so push_patch and push_navigate do
not work. Use redirect(socket, to: ~p"/path") for a full-page navigation.live_render/3 adds a div by default. Use :container when that
wrapper would disrupt grid, flex, table, or list layout.mount/3 synchronously. Use
assign_async/3 for expensive reads, and guard subscriptions or other
connected-only setup with connected?(socket).Plug.Session, and the dead layout must include the CSRF token and JavaScript
that calls liveSocket.connect().Use live_isolated/3 for the static-to-connected lifecycle. Use render_async/2
to wait for assign_async/3 or start_async/3 tasks.
test "loads stats after connection", %{conn: conn} do
user = user_fixture()
account = account_fixture(user, stats_total: 42)
conn = log_in_user(conn, user)
{:ok, view, html} =
live_isolated(conn, MyAppWeb.AccountStatsLive,
session: %{"account_id" => account.id}
)
assert html =~ "Loading statistics..."
assert render_async(view) =~ "42"
end
In controller tests, assert the dead response contains the island's container id,
data-phx-session, and loading state. live/2 does not apply because there is no
live route.
Read references/gotchas.md for endpoint configuration, layout resolution,
session and flash behavior, navigation limits, container options, PubSub and async
ordering, multi-island coordination, and detailed testing guidance.
What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
npx claudepluginhub dvcrn/skills --plugin phoenix-live-islands