Livewire Alert Livewire Alert

Advanced

Flash Alerts

Use Laravel session flashing when an alert should appear after a redirect or after a fresh component mount.

Flash alert

Flash whatever structure your app needs, then read it from mount().

Live demo
SweetAlert2
PHP
LivewireAlert
public function mount()
{
    if (session()->has('saved')) {
        LivewireAlert::title(session('saved.title'))
            ->text(session('saved.text'))
            ->success()
            ->show();
    }
}

Redirect flow

Set the flash data before redirecting. The destination component can read and show it.

PHP
LivewireAlert
public function changesSaved()
{
    session()->flash('saved', [
        'title' => 'Changes Saved!',
        'text' => 'You can safely close the tab!',
    ]);

    $this->redirect('/dashboard');
}