liveview-streams
LiveView Streams
RULES — Follow these with no exceptions
1. Use streams for collections with 100+ items; combine with pagination or infinite scroll — smaller lists use regular assigns; never stream unlimited items
2. Use stream_insert/3 and stream_delete/3 for incremental updates — never replace the entire stream assign
3. Use phx-update="stream" in templates — required for stream DOM patching; missing this causes full re-renders
4. Use reset: true for filtering and sorting — clears existing items before inserting the new result set
5. Call stream_configure/3 before stream/3 — configuring a custom dom_id after the stream is initialized has no effect
6. Re-fetch from the database when sorting or filtering — streams do not keep items in assigns, so you cannot reorder them in memory
End-to-End Workflow
Follow this sequence when implementing LiveView streams: