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.
amjadiqbal/laravel-sweetalert2 v1.0.0 is a thin, opinionated convenience layer over SweetAlert2 (11.26.25). It does not introduce a new rendering model; it bridges Laravel's session flash mechanism and Blade/Livewire surface area to a client-side alert library. Architecturally that is a low-coupling fit: a service provider, a facade + global helper, a Blade component/directive, a small runtime, and a config file. Nothing it does is hard to remove later, which is the single most important property for a package of this size.
Strengths for a TPM's purposes: the security posture is deliberate (titles as titleText, escaped button/footer labels, html()/raw() as explicit opt-outs, SRI on the CDN script), the Livewire story is first-class (data-navigate-once, a SweetAlerts trait, wire:click/wire:submit interception), and the multi-popup queue surviving redirect chains removes the most common hand-rolled workaround in admin panels. The php artisan about entry is a small but real operability signal.
Integration feasibility: very high for a standard Blade-rendered Laravel 12/13 app. Drop-in via composer require, publish config, use the directive once in the layout. Low for anything else: Inertia/Vue/React SPAs, API-only services, or teams on Laravel 10/11 are out of scope entirely.
Technical risk is concentrated in four places, not spread:
data-swal-confirm hijacks submit/click on forms, links, and Livewire actions. That is convenient, but it inserts a new failure surface into every destructive action on the page and needs a no-JS / progressive-enhancement story plus a double-submit story before it touches anything financially or medically significant.Maturity risk: this is a first public release, single-maintainer, under a personal vendor namespace, and explicitly a rewrite of prior unpublished work. The 29-test matrix across PHP 8.3/8.4/8.5 × Laravel 12/13 plus Pint/PHPStan/Pest is respectable discipline for the surface area, but it is not a track record. Treat it as a candidate for a bounded pilot, not a platform decision.
Key questions to put to the maintainer / to engineering before sign-off:
data-swal-confirm behave with JS disabled, with wire:submit on a form that also has a native onsubmit, and under rapid double-click?Stack fit. Best fit: server-rendered Blade admin panels, internal tools, and CRUD back-offices already on Laravel 12, especially where Livewire is in use and where developers have been hand-rolling SweetAlert ->with('success', ...) flashes. Poor fit: public high-traffic marketing sites (no need for the dependency), SPA front-ends (the session-flash model does not apply), and anything where the CDN fetch is not reachable.
Migration path. Two distinct cases:
session()->flash alert rendering with swal()->success(...) calls, delete the bespoke JS. This is genuinely small — hours, not weeks.amjadiqbal/sweetalert2: not a drop-in. alert() becomes swal(), type becomes icon, the container binding is now sweetalert2, and the session key is laravel-sweetalert2.alerts. Because the old package was never published, there should be no production code to migrate — confirm this before assuming zero cost.amjadiqbal/alertify without collision, so a phased replacement is possible rather than a flag day.Compatibility checklist before merge: PHP 8.3+ in CI and in prod images; Laravel 12/13 confirmed in composer.lock; CSP policy updated for jsDelivr in script-src plus the nonce pass-through; session driver confirmed as shared (not array); Livewire version confirmed to honour data-navigate-once.
Sequencing.
success and one confirm-guarded destructive action. Confirm CSP, SRI, and Livewire navigate all behave.swal() vs trait methods) in the team's front-end guide.Maintenance. Low code-level maintenance — the package owns little logic. The real maintenance burden is external: the SweetAlert2 version pin (11.26.25) and the jsDelivr dependency. Someone must own "is our alert library current and is the CDN reachable" as a recurring check, ideally folded into the existing dependency-review routine. Bus factor is one; the mitigation is that the abstraction is thin enough to fork.
Support. Ramp-up for a Laravel developer is under an hour: the API is swal()->success('Saved') plus fluent options, and the option names mirror SweetAlert2's documented ones, so existing SweetAlert2 knowledge transfers directly. Document two things internally or you will get repeat questions: the html()/raw() opt-out is a deliberate XSS escape hatch requiring review, and the session-flash model means popups appear after a redirect, not immediately — this surprises people in AJAX flows.
Scaling. Negligible server-side cost; the alert payload rides the session, so it is one small flash entry per request. Client cost is the SweetAlert2 bundle (~70KB) from the CDN, cached across pages. The scaling risk is not throughput, it is concentration: if every destructive action in the estate is guarded by data-swal-confirm, a runtime regression in the intercept logic becomes a cross-product incident. Keep the guard opt-in per action rather than a blanket attribute.
Failure modes to plan for:
data-swal-confirm interception → double-submit if the confirm handler re-triggers the original event; confirm-button copy that misleads on destructive actions; broken behaviour when JS is unavailable. All three need explicit tests.Ramp-up. Trivial for developers, non-trivial for reviewers: the security defaults are good, but raw() and html() introduce a markup path that must be code-review-gated like any {!! !!}. Add that rule to the review checklist at the same time as the pilot, not after.
Recommendation. Adopt for internal Blade/Livewire admin surfaces on Laravel 12+, behind a one-sprint pilot and with two conditions written into the ADR: a documented self-host/CDN fallback, and a named owner for the SweetAlert2 version pin. Do not adopt as a platform-wide standard, and do not adopt at all on Laravel ≤11 or on SPA front-ends.
How can I help you explore Laravel packages today?