Usage
Macros
| Macro | Toast color | Notes |
|---|---|---|
withSuccess(string $message) | Green | |
withInfo(string $message) | Blue | |
withWarning(string $message) | Yellow | |
withError(string $message) | Red | Also adds the message to the general error bag key |
withWorkflow(StoredWorkflow $workflow, ?string $message) | — | Live progress toast; see below |
Workflow Progress Toast
withWorkflow() is used when a background workflow has been dispatched and you want the user to see live progress without leaving the page. Instead of a static message, it shows a loading toast that polls the workflow’s status every 2 seconds, updating the count in real time:
- While running:
Processing 12 of 50 items - On completion:
Processed 50 items— then reloads all Inertia page props automatically - On failure: shows the original
$messageas an error toast
$message is used as the toast label before progress counts are available (e.g. while the workflow is still pending). It is optional — if omitted, a generic “Processing in background…” label is shown.
The workflow status is fetched via a signed URL so users without manage_workflows permission can still see their own progress.
How It Works
- The macro stores
flash.{type}in the session with a uniqueid. HandleInertiaRequestsshares theflashpayload on every response viaInertia::always.- The
FlashMessagecomponent watches forflash.*.idchanges and fires a Sonner toast. - For
flash.workflow,WorkflowToastManagercreates a loading toast and mounts a polling component that updates it until the workflow reaches a terminal state. - Session flash data is cleared after it is read.
useGlobalProps() hook under flash.
Manual Flashing
For non-redirect flows, flash directly to the session:Only one message per type is shown per request. If you call the same macro twice, the last one wins.
Related
- Actions — Actions commonly return redirects with flash messages.
- Workflow Card — Embed workflow progress inline on a page rather than in a toast.