Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Laravel Sonner Laravel Package

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.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture fit. The package is a server-rendered-to-client-hydrated toast layer for Laravel: PHP collects toasts (helper calls, facade, flashed session, Livewire action responses), serialises the queue into the page as escaped JSON, and a bundled plain-JavaScript port of Sonner's Toaster renders it. That fits Blade/Livewire/Alpine applications cleanly and, importantly, fits them without React or an npm build step — a genuine gap in the Laravel ecosystem, where the usual options are either React-dependent (Sonner proper) or visually dissimilar (Filament/Tall Toasts style). It is a weaker fit for Inertia+React/Vue apps, where upstream Sonner is already the idiomatic choice and this package would create a second, parallel toast system.

Integration feasibility. Low effort by the looks of it: composer require, publish config/sonner.php, place <x-sonner /> once in the layout, call toast()->success(...) or dispatch the sonner:toast browser event. Laravel 12/13 and PHP 8.3+ is a current, defensible support matrix. Livewire 3/4 handling (same-response delivery, deferral across redirects, survival across wire:navigate) addresses the two failure modes that usually sink toast packages in Livewire apps.

Technical risk. Three items dominate:

  1. The JS port is the package's core liability. Sonner's Toaster logic is being reimplemented and maintained by hand against upstream 2.x. Parity for stacking, hover-expand, swipe, pause-on-hover/hidden-tab, hotkey and RTL is asserted by the release notes, not evidenced — there is no mention of a browser-level test suite (Dusk/Playwright). Every upstream Sonner release becomes a manual porting exercise, and drift will be invisible until a user reports it. styles.css is bundled unchanged and pinned to 2.0.8, so upstream CSS fixes also require a package release.
  2. CSP coupling. Inline style and script rely on Laravel's CSP nonce. That is correct for nonce-based policies but breaks under hash-only or strict-dynamic-without-nonce setups, and needs scrutiny under full-page cache/CDN and Octane, where nonce generation and response reuse may not behave as assumed. Failure is silent — toasts simply never appear.
  3. Breaking changes and a security history. Removing AmjadIqbal\Sonner\Livewire\UsesSonner and the PHP promise() method will break any dev-main consumer. More significantly, the release confirms that pre-1.0 code was vulnerable to HTML injection via </script> in toast text. Anyone running dev-main in a shared or user-content-driven context should treat this as a security upgrade, not a feature upgrade.

Key questions. Who owns the JS port, and what is the commitment to tracking Sonner releases? Is there an automated browser test suite, and can we see it? What is the licensing/attribution position on redistributing Sonner's CSS and a derivative of its logic? Does the component degrade gracefully without JS? What is the added payload per response for typical toast volume? Are there known conflicts if Sonner is also present via npm? What is the accessibility story (live region, focus handling, Alt+T interaction with existing hotkeys)? Is sonner:toast documented as a stable public API or an implementation detail?

Caveat: this evaluation is based solely on the v1.0.0 release notes; no source, tests, or docs were reviewed.

Integration Approach

Stack fit. Best suited to Laravel 12/13 monoliths using Blade + Livewire 3/4 + Alpine, with no existing React/Vue toast layer. It is self-contained (no npm, no Tailwind dependency for the toast styles themselves), which simplifies deployment for teams without a frontend build in the loop. Poor fit where the frontend is already a SPA and Sonner is installed via npm — you would be running two implementations of the same UI primitive.

Migration path.

  • From dev-main: mandatory, not optional, because of the XSS fix. Remove all UsesSonner trait imports, replace PHP-side promise() calls with the JS toast.promise(), republish config/sonner.php, confirm <x-sonner /> is in the layout, and confirm the CSP nonce is actually reaching the inline tags.
  • From another toast package: run both side by side briefly, convert call sites, then remove the old package and its layout directives in a single follow-up PR.
  • Greenfield: adopt directly; no migration.

Compatibility. Verify (a) Laravel 13 support against your actual constraint, (b) Livewire 3 vs 4 — the redirect and wire:navigate semantics differ enough to warrant explicit testing on whichever you run, (c) your CSP configuration, and (d) absence of a pre-existing npm Sonner, which would duplicate styles and global toast.

Sequencing. (1) Inventory of dev-main API usage and toast call sites. (2) Upgrade on a branch and republish config. (3) Explicit XSS regression test with a </script> and quote-bearing payload, confirming textContent rendering in the DOM. (4) Livewire flow tests: same-response toast, redirect-then-toast, wire:navigate persistence. (5) CSP validation with the real production policy, plus a cached-page check. (6) Visual QA across light/dark/system, rich colors, six positions, RTL if relevant — note the intentional dark-theme rich-color divergence for error/warning. (7) Canary/staged rollout.

Operational Impact

Maintenance. A single-maintainer, 1.0.0 package with a hand-maintained port of a fast-moving upstream is the main ongoing cost. Budget a recurring check each Sonner minor release to decide whether the port and bundled CSS need refreshing, and treat the pinned 2.0.8 styles.css as a dependency to track rather than a fixed asset. Budget is small — days per year — but it is not zero, and it is invisible until something drifts.

Support. Expect issues concentrated in three areas: CSP/nonce misconfiguration (toasts silently absent), Livewire edge cases around redirects and navigation, and visual divergence from Sonner proper. A short internal runbook covering "no toasts appearing" (check nonce, check console for blocked inline script, check queue JSON in page source) will absorb most first-line tickets.

Scaling. Server impact is negligible — a small JSON blob per response and session-flashed entries. Client cost is the Sonner CSS plus the ported JS, which should be measured once and recorded in the frontend budget. Watch two things at scale: full-page cache/CDN behaviour with session-flashed toasts, and any future move to Octane where nonce generation and per-request assumptions should be re-validated.

Failure modes. Missing or mismatched CSP nonce → silent no-op, the most likely production failure. Session-flash loss is now fixed (flashes clear after one render rather than persisting). Toasts dispatched from queued jobs, scheduled commands, or other non-request contexts will not reach the browser — do not let anyone assume they will. Duplicate rendering across wire:navigate transitions or with a second toast system installed. Ported-JS regressions presenting as cosmetic bugs (stacking order, timers not pausing in hidden tabs) that erode trust in the component quietly. And a residual concern that the escape-then-textContent defence could regress in a future refactor without a test to catch it.

Ramp-up. Half a day for a Laravel developer to be productive: composer install, one layout edit, helper/facade surface, browser event for Alpine. Design and QA need a short review pass for theming, dark-mode rich colors (which deliberately differ from Sonner), position choice and RTL. Accessibility review of Alt+T against existing app hotkeys and of screen-reader announcement behaviour is worth an hour before shipping to end users.

Recommendation. Adopt v1.0.0, and block any dev-main usage on the XSS grounds alone. The value proposition — real Sonner ergonomics in a no-npm Laravel stack — is strong and not otherwise served. Proceed with the CSP and Livewire checks in the sequencing above, and treat the ported JS as a tracked dependency with an owner rather than a fire-and-forget vendor drop.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
ignibyte/aic-framework
glavweb/data-schema-bundle
glavweb/datagrid-bundle
tacticmedia/scim-server
uni-method/frame
neika-ai/sdk
adachsoft/php-code-style
pharaonic/laravel-notification-dependencies
beautinow/translug
dev-brainiac/bot-cloaked
octoberrain/html
octoberrain/extension
octoberrain/exception
octoberrain/contracts
adachsoft/api-version-bundle
cgv/localized-resource
noith/settings
kda/laravel-package
kda/filament-dynamic-navigation
bypersoft/signbox