realrashid/sweet-alert
Laravel wrapper for SweetAlert2 that makes it easy to show stylish alert, toast, and confirmation dialogs. Flash messages from controllers or middleware, with helpers for success/error/warning/info, custom options, and Blade support for quick integration.
Pros:
Alert::success()) aligns with Laravel’s idiomatic patterns (e.g., Cache::get()).html(), image(), and toast() provide hooks for dynamic content, useful for dashboards or marketing sites.Cons:
PublishCommand for asset customization.@stack('scripts')).composer.json constraints).sweetalert.all.js may conflict with existing builds.bootstrap-4) assume the app uses Bootstrap CSS. Misalignment could break styling.@php wrappers if using @{{ }} syntax (fixed in v7.3.1).SweetAlertServiceProvider registers bindings automatically.@include('sweetalert::alert') in layouts and @stack('scripts') for JS.Alert::success() after User::create()).composer require realrashid/sweet-alert
php artisan vendor:publish --provider="RealRashid\SweetAlert\SweetAlertServiceProvider" --tag="sweetalert-config"
return redirect()->with('success', 'Message')) with facades:
Alert::success('Title', 'Message');
alert()->html('<b>HTML</b>', 'Content', 'warning')->autoClose(5000);
@include('sweetalert::alert')
resources/js/app.js):
import Swal from 'sweetalert2';
window.Swal = Swal;
Alert facade).Alert::question() with callbacks.php artisan vendor:publish to customize config/themes without forking.php artisan config:clear).laravel and sweetalert2 for community Q&A.How can I help you explore Laravel packages today?