Skip to main content
Flash messages display toasts after a redirect without requiring any extra frontend state. Chain a macro on your redirect response and the toast appears automatically on the next page load.

Usage

return redirect()
    ->route('dashboard')
    ->withSuccess(__('Record created successfully.'));

Macros

MacroToast colorNotes
withSuccess(string $message)Green
withInfo(string $message)Blue
withWarning(string $message)Yellow
withError(string $message)RedAlso 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 $message as an error toast
$workflowStub = MyWorkflow::start(...);
$storedWorkflow = StoredWorkflow::find($workflowStub->id());

return back()->withWorkflow(
    $storedWorkflow,
    __('50 items queued for background processing.')
);
The $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

  1. The macro stores flash.{type} in the session with a unique id.
  2. HandleInertiaRequests shares the flash payload on every response via Inertia::always.
  3. The FlashMessage component watches for flash.*.id changes and fires a Sonner toast.
  4. For flash.workflow, WorkflowToastManager creates a loading toast and mounts a polling component that updates it until the workflow reaches a terminal state.
  5. Session flash data is cleared after it is read.
Flash data is available in the useGlobalProps() hook under flash.

Manual Flashing

For non-redirect flows, flash directly to the session:
use Illuminate\Support\Facades\Session;

Session::flash('flash.success', [
    'message' => __('Saved.'),
    'id' => uniqid(),
]);
Only one message per type is shown per request. If you call the same macro twice, the last one wins.
  • Actions — Actions commonly return redirects with flash messages.
  • Workflow Card — Embed workflow progress inline on a page rather than in a toast.