amjadiqbal/laravel-sonner
Laravel Sonner brings elegant, Sonner-inspired toast notifications to Laravel applications. Flash success, error, and info messages from controllers or Blade views and render them with a clean, customizable API, keeping user feedback consistent and simple to set up.
Alt+T hotkey. The decision to build is now hard to justify unless the UX needs to diverge from Sonner.toast() helper, Sonner facade, a browser API that mirrors Sonner (toast.success(), toast.promise(), toast.dismiss(), toast.getToasts()), a <x-sonner /> Blade component, and a sonner:toast event for Alpine/Livewire dispatches. That means one design language whether the trigger is a controller, a Blade view, an Alpine handler, or a Livewire action — a real reduction in per-feature front-end decisions.wire:navigate, and wait for the next page after a redirect. This unblocks "instant feedback" patterns in Livewire-heavy admin and dashboard surfaces without adding a JS framework.php artisan about gives support/ops a cheap way to confirm what's deployed.textContent, and the queue is serialized as JSON with <, >, &, and quotes escaped. Any feature that surfaces user-supplied strings (validation messages, imported names, API error passthrough) in a toast is now safe by default. Treat this as a reason to prioritize the upgrade over the feature work it displaces.config/sonner.php plus full prop parity on <x-sonner /> means design/PM can tune position, theme, and duration without engineering tickets — useful for A/B-ing notification prominence.dev-main: the UsesSonner Livewire trait and the PHP promise() method are gone (use toast.promise() in JS instead), and dark-theme rich-color error/warning toasts are now neutral rather than Sonner's dark red/olive. If anything internal was built against dev-main, budget a short migration rather than assuming a drop-in.Adopt when most of these hold:
Look elsewhere or defer when:
For executives: This is a free, small-footprint package that gives our Laravel app polished, accessible in-app notifications without hiring front-end specialists or standing up a JavaScript build pipeline. It closes a security gap — user-supplied text in a toast could previously inject HTML into the page — and it unblocks our Laravel 12/13 upgrade, which was gated on it. The main caveat is maintenance risk: it is a single-maintainer package that mirrors an open-source JavaScript library, so we should pin the version and review on our normal dependency cadence rather than assume it is set-and-forget.
For engineering leads: v1.0.0 is the first stable release and is not fully backward compatible with the previous dev-main branch. Two removals to check for: the AmjadIqbal\Sonner\Livewire\UsesSonner trait (no longer needed) and the PHP-side promise() method (call toast.promise() from JavaScript instead). Also note the deliberate dark-theme change for rich-color error and warning toasts, which now use a neutral background — a design review item if anyone has screenshots or specs pinned to the old look. Everything else is additive: the full Sonner prop surface on <x-sonner />, defaults centralized in config/sonner.php, a JSON-serialized queue with proper escaping, textContent rendering, CSP nonce support, and a php artisan about line for deployment verification. Integration is a Blade component plus a facade or helper — no npm, no React, no asset pipeline changes. Livewire 3/4 is first-class, and flashed toasts now correctly leave the session after one render instead of lingering.
Suggested next step: pilot on one surface with user-generated text in the message (the highest-value case for the XSS fix), confirm CSP nonce behavior in staging, then roll out as the standard notification primitive with the version pinned.
How can I help you explore Laravel packages today?