Using LiveComponents to Set Flash Messages in Phoenix LiveView

129
clicks
Using LiveComponents to Set Flash Messages in Phoenix LiveView

Source: andrewtimberlake.com

Type: Post

The article discusses how to set flash messages in Phoenix LiveView when using LiveComponents. Normally, the flash message from a LiveComponent is only sent to the parent LiveView during navigation events. However, it demonstrates how to use message passing to send flash messages directly to the parent LiveView without triggering navigation. The article provides example code for both the LiveComponent and the parent LiveView, outlining how they communicate through message passing. Additionally, it suggests making the message handling more generic by adding a method in a shared module, along with a reference to global broadcasts in LiveView.

© HashMerge 2025