Flash messages are a stable and boring way to transfer messages from one page to the other leveraging session. For example, you want to "flash" a success, error, or even just a message from one action and then in another page you want to display that message.
With this implementation inertia-sails will leverage the new sails-flash hook and share a flash prop for every request. The signature of the flash prop is an object with 3 properties:
With this implementation, in your pages you can then reference the flash prop like flash.success or use the usePage hook to get the flash prop. Here is an implementation from Hagfish that uses the flash messages in AppLayout so flash messages can be seen in the dashboard(my components are in Vue you can adjust accordingly for React or Svelte):
Description
Flash messages are a stable and boring way to transfer messages from one page to the other leveraging session. For example, you want to "flash" a success, error, or even just a message from one action and then in another page you want to display that message.
With this implementation
inertia-sails
will leverage the newsails-flash
hook and share aflash
prop for every request. The signature of theflash
prop is an object with3
properties:With this implementation, in your pages you can then reference the
flash
prop likeflash.success
or use theusePage
hook to get the flash prop. Here is an implementation from Hagfish that uses the flash messages inAppLayout
so flash messages can be seen in the dashboard(my components are in Vue you can adjust accordingly for React or Svelte):Since flash always returns an array, we can loop like so: