amjadiqbal/laravel-sweetalert2
A Laravel wrapper for SweetAlert2 that lets you fire toasts and modal alerts from your controllers using simple flash helpers. It ships with Blade directives, sensible defaults, and publishable config for quick, customizable notifications.
composer require and a config file, not a sprint.data-swal-confirm on any button, link, or form (including wire:click/wire:submit) turns "confirm before delete" into an attribute rather than a JS story. This is the strongest product argument: fewer accidental deletions and misfires, with near-zero implementation cost.data-navigate-once handling and the SweetAlerts trait mean this works under wire:navigate without flicker or duplicate handlers — relevant if the roadmap includes Livewire-first or SPA-feel navigation work.Consider it when:
titleText, button labels and footers are HTML-escaped, with html()/raw() as explicit, greppable opt-outs. That's the right default posture for a team that will inevitably pass user-supplied strings into messages.amjadiqbal/sweetalert2 and want the namespaced session key (laravel-sweetalert2.alerts) and swal() helper that don't collide with amjadiqbal/alertify.Look elsewhere when:
@sweetalert2 directive are dead weight; you'd be adopting half a package.For executives. A small, single-purpose library that adds polished alerts, toasts, and — more importantly — confirmation prompts before destructive actions. The business case is risk reduction: accidental deletes, irreversible submissions, and "did you mean to do that?" moments become handled by default instead of by whichever engineer remembered to write the JS. Cost is a handful of lines in composer.json; there is no vendor lock-in, no data model change, and no migration. Two caveats to state plainly: it is v1.0.0 from a single maintainer with no prior published track record, so pilot it on a non-critical surface first; and it loads SweetAlert2 from a public CDN rather than a bundled asset, which is a policy question for security/ops, not an engineering one. Mitigations exist (SRI hashes, CSP nonces), but the CDN decision should be made deliberately.
For engineering. One composer require amjadiqbal/laravel-sweetalert2. You get a SweetAlert2 facade, a swal() helper, and success/error/warning/info/question/toast/fire that flash to the session — so popups survive redirect chains and multiple popups queue correctly. Fluent options cover timer, position, confirmButton, cancelButton, footer, theme, width, plus option()/raw() escape hatches. Front end is <x-sweetalert2 /> and @sweetalert2, loading SweetAlert2 11.26.25 with SRI, a small runtime, a Vite CSP nonce on every script tag, and data-navigate-once so wire:navigate doesn't double-bind. Livewire components get a SweetAlerts trait ($this->swal(...), $this->swalToast(...)). Security defaults are correct: titles ship as titleText, labels and footers are escaped, and html()/raw() are the explicit opt-outs — enforce those in review. Session key and container binding are namespaced (laravel-sweetalert2.alerts, sweetalert2), so no collision with amjadiqbal/alertify. CI is 29/29 across PHP 8.3/8.4/8.5 × Laravel 12/13 with Pint, PHPStan, and Pest. Note the breaking deltas from the unpublished predecessor: type is now icon, and the global helper is swal(), not alert() — relevant only if anyone copied patterns from that branch.
How can I help you explore Laravel packages today?