/elixir-dev:phoenix-app-clipfrom elixir-dev
Use when mounting a React element into a Phoenix LiveView DOM node and moving data between the two — the "app-clip" integration pattern. Trigger this whenever the user wants to render a React component (or any client-side element) from inside a LiveView, embed an SPA-style widget in a LiveView page, use `createRoot`/`ReactDOM` inside a `phx-hook`, pass server data from Phoenix into a React tree, push events or state from React back to a LiveView's `handle_event/3`, share an auth token or trigger navigation from a mounted React component, or mentions app-clips, `phx-hook` `Mount*`, `phx-update` `"ignore"`, `pushEvent`/`handleEvent`, or React-in-LiveView integration. Use it even if they only say "render my React component in a LiveView" or "get data from Phoenix into React". This skill covers ONLY the integration seam — mounting and bidirectional data transfer. What the React component is, and which UI libraries it uses, is the user's own concern.
Ships in elixir-dev. 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.
This skill covers one thing: the seam between a Phoenix LiveView and a React element mounted inside it. Two mechanics:
What the React component is — its UI library, its internal state, its styling — is entirely the user's concern. This skill never prescribes that. It only wires the component into LiveView and the two data channels.
The LiveView renders an empty node and hands it to a hook. Two attributes matter:
<div
id={@id}
phx-update="ignore"
phx-hook="MountClip"
data-props={Jason.encode!(@initial)}
>
</div>
phx-hook="MountClip" names the JS hook that will mount React here.phx-update="ignore" is mandatory. Once React owns this subtree, LiveView
must not patch it, or React's DOM and LiveView's DOM diffing fight and the UI
corrupts. ignore tells LiveView to leave the node's children alone after the
first render. (Consequence: you can't stream live updates by changing the
node's contents — use the event channel below.)data-* attributes carry the initial data from Phoenix into the hook.
Encode anything non-trivial with Jason.encode!/1 and parse it in JS.The hook creates a React root on this.el, renders the user's component, and
unmounts on destroyed() (LiveView navigations call destroyed(); skipping
unmount leaks a root and its listeners every time).
import * as React from 'react';
import { createRoot } from 'react-dom/client';
import { YourComponent } from '@your-scope/your-package';
export const MountClip = {
MountClip: {
mounted() {
this.root = createRoot(this.el); // store before any async work
this.props = JSON.parse(this.el.dataset.props || '{}');
this.render();
},
destroyed() {
this.root?.unmount(); // mandatory
},
render() {
this.root.render(<YourComponent {...this.props} bridge={this.bridge()} />);
},
},
};
mounted() may await import(...) the component for code-splitting — just set
this.root before the await so destroyed() can find it.
| Direction | When | Mechanism |
|---|---|---|
| Phoenix → React | initial values at mount | data-* attribute on the node → read this.el.dataset.* in mounted() → pass as props |
| Phoenix → React | live updates after mount | LiveView push_event/3 → hook this.handleEvent("name", fn) → re-render React with new props |
| React → Phoenix | a user action the server owns | a pushEvent function handed to React (calls this.pushEvent) → LiveView handle_event/3 (optional reply callback) |
| React → Phoenix | navigation | a navigate function handed to React → this.pushEvent("navigate", ...) → LiveView push_navigate/2 |
You hand the two React→Phoenix functions (and the token, etc.) to the component through a small bridge object — either as a prop (as above) or via a React context the component reads. Both are shown in the templates.
// inside the hook
bridge() {
return {
token: this.el.dataset.token,
pushEvent: (event, payload, onReply) => this.pushEvent(event, payload, onReply),
// navigation goes through the server's public push_navigate/2
navigate: (path) => this.pushEvent('navigate', { to: path }),
};
}
// live updates: server push_event('clip:update', payload) → re-render
mounted() {
// ...
this.handleEvent('clip:update', (payload) => {
this.props = { ...this.props, ...payload };
this.render();
});
}
this.el, this.pushEvent, this.handleEvent are all the standard LiveView JS
hook API — no extra packages are required.
See references/data-transfer.md for each channel in full, including reply
callbacks, JSON-encoding rules, and why live updates must go through events rather
than attribute changes.
State two identifiers: name (slug/dir) and Name (PascalCase). Then:
bridge.)assets/js/clips/<name>.js exporting Mount<Name> — copy
assets/phoenix/clip_hook.js. Wire the bridge and any handleEvents.assets/js/hooks.js and pass hooks to your LiveSocket.phx-hook="Mount<Name>", phx-update="ignore", and data-* for initial
data — copy assets/phoenix/live.ex, live_component.ex, index.html.heex.router.ex.data-* arrived as props, and that a
pushEvent from React lands in handle_event/3.Phoenix side (copy into your app):
assets/phoenix/clip_hook.js — the mount + bidirectional bridge hook (the core
of this skill); goes in assets/js/clips/.assets/phoenix/live.ex, live_component.ex, index.html.heex — the
placeholder node and its LiveView shell, showing data-* initial data,
push_event live updates, and handle_event for events from React.React side (illustrative — your component is your own):
assets/react/example_component.jsx — a minimal, library-free stub showing how
a component consumes props + the bridge. Replace it with your own component.assets/react/bridge-context.js — optional context so nested components read
token/pushEvent/navigate via useBridge() instead of a prop.Replace __name__ / __Name__ / __TITLE__ / @your-scope placeholders
(legend at the top of each file).
assets/phoenix/clip_hook.js (opens in a new tab)assets/phoenix/index.html.heex (opens in a new tab)assets/phoenix/live.ex (opens in a new tab)assets/phoenix/live_component.ex (opens in a new tab)assets/react/bridge-context.js (opens in a new tab)assets/react/example_component.jsx (opens in a new tab)references/data-transfer.md (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub gsmlg-dev/code-agent --plugin elixir-dev7 skills in this plugin
/denoxUse when building Elixir applications that need to evaluate JavaScript or TypeScript code, run Deno programs as subprocesses (MCP servers, CLI tools), load ES modules, import npm/jsr packages, call JS functions from Elixir, or use V8 snapshots. Also use when the user mentions Denox, deno_core, Rustler NIF JS runtime, TypeScript transpilation in Elixir, running MCP servers from Elixir, or managing Deno subprocesses with OTP supervision. Make sure to trigger this skill even if the user just says "add JS evaluation" or "run a TypeScript server" in an Elixir project that has denox as a dependency./ectoDesign and debug Elixir persistence with Ecto. Use for schemas, changesets, queries, preloads, transactions, migrations, multi-tenancy, and data access through application contexts. Covers database query performance and connection pools./