liveview-streams
Installation
SKILL.md
LiveView Streams
Phoenix LiveView streams (0.19+) provide efficient rendering of large collections by patching only changed DOM elements.
RULES — Follow these with no exceptions
- Use streams for collections with 100+ items — regular assigns re-render the entire list on every change
- Initialize streams in
mount/3withstream(socket, :name, collection) - Use
stream_insert/3andstream_delete/3for incremental updates — never replace the entire stream - Use
phx-update="stream"in templates — required for stream DOM patching - Set DOM IDs with
idattribute — each streamed item needs a unique DOM ID - Use
stream_configure/3for custom DOM IDs — when default IDs don't match your needs - Combine with pagination or infinite scroll — don't stream unlimited items
- Always use
Repo.preloadbefore streaming — preloading ensures data is loaded - Use
at:option for ordered insertion — control where new items appear in the stream