Livewire Alert is a Laravel Livewire package that brings SweetAlert2 notifications to your Livewire components through a fluent, chainable API. Configure and trigger beautiful, interactive alerts with a clean PHP interface — no JavaScript required.
Full documentation, live examples, and an interactive playground are hosted at:
Every feature — icons, positions, toasts, timers, buttons, confirm dialogs, loading alerts, in-place updates, inputs, flash alerts, images, custom classes, dependency injection and more — is documented there with copy-pasteable snippets and runnable demos.
- PHP 8.1 or higher
- Laravel 10.x or higher
- Livewire 3.x or 4.x
- Composer
Require the package with Composer:
composer require jantinnerezo/livewire-alertOptionally publish the config file:
php artisan vendor:publish --tag=livewire-alert:configInstall SweetAlert2 via npm or yarn:
npm install sweetalert2yarn add sweetalert2Then import it in resources/js/app.js:
import Swal from 'sweetalert2'
window.Swal = SwalOr include it via CDN before the closing </body> tag:
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>Register SweetAlert2 as a Filament asset in your AppServiceProvider:
use Filament\Support\Facades\FilamentAsset;
use Illuminate\Support\Facades\Vite;
use Filament\Support\Assets\Js;
public function boot()
{
FilamentAsset::register([
Js::make('sweetalert2', Vite::asset('resources/js/sweetalert2.js')),
// Or via CDN:
// Js::make('sweetalert2', 'https://cdn.jsdelivr.net/npm/sweetalert2@11'),
]);
}use Jantinnerezo\LivewireAlert\Facades\LivewireAlert;
public function save()
{
LivewireAlert::title('Changes saved!')
->success()
->show();
}For everything else — head to the documentation site.
The last v3 release was v3.0.3 (March 11, 2024). v4 is a major refactor introducing the fluent Facade API, dependency injection, and many more features. For v3:
composer require jantinnerezo/livewire-alert:^3.0Upgrading to v4 is recommended for new and ongoing projects.
composer testPlease see CONTRIBUTING for details.
If you discover any security related issues, please email erezojantinn@gmail.com instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.