Flash messages are meant to be used for some important result of action. For example when user successfully recovered password, or has failed to login.
These type of messages are not automatically vanishing, so use sparse. For most cases it is better to use notification messages, which vanish in few seconds after displaying.
Messages can be triggered in any place in code, whether it is normal
AJAX request. To create message, first
FlashMessage, then call any message type.
This example message should be visible on top of page:
(new FlashMessage())->setSuccess('My success message');
<a href="#" onclick="app.flash('My message', 'info');return false;">Show message</a>