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

Sweet Alert Laravel Package

realrashid/sweet-alert

Laravel package that brings SweetAlert2 to your app with a fluent PHP API. Flash success, error, and toast alerts, or build confirm dialogs right from your controllers—no JavaScript boilerplate needed.

View on GitHub
Deep Wiki
Context7
v8.0.0

Version 8 rebuilds the package around a fluent, Laravel-native builder. The v7 API was one 700-line Toaster class; v8 is three purpose-built builders, five composable concerns, three enums, and a test suite that covers behaviour rather than the shape of the code.

Your existing code keeps working. alert()->success(), toast() and confirmDelete() display immediately the way they always did. A survey of five real applications using this package found Alert::success() in 52 files and none of the changed signatures anywhere.

Highlights

  • AlertBuilder, ToastBuilder and InputBuilder, each with its own defaults
  • Full SweetAlert2 coverage — deny buttons, progress steps, every input type, pre-confirm and pre-deny routes, per-alert themes, animations
  • PHP 8.3 enums (AlertType, InputType, Position) with IDE completion
  • when()/unless() and macro() on every builder
  • [@sweetAlert](https://github.com/sweetAlert) Blade directive, replacing [@include](https://github.com/include)('sweetalert::alert')
  • Livewire v4 trait and Inertia middleware
  • Laravel Boost guideline and skill, so AI assistants write v8 rather than v7
  • VitePress documentation, Pest suite with architecture tests, Pint, PHPStan level 5

Guarded actions

A dialog that can only ask a question is half a feature. v8 acts on the answer with no JavaScript on your side:

<a href="{{ route('posts.destroy', $post) }}" data-confirm-delete>Delete</a>

<a href="{{ route('posts.publish', $post) }}" data-confirm data-confirm-method="PUT">Publish</a>

<form method="POST" action="{{ route('orders.refund', $order) }}" data-confirm>
    [@csrf](https://github.com/csrf)
    <button type="submit">Refund</button>
</form>

Override the copy per element with data-confirm-title, -text, -icon, -button and -cancel. On confirm the package builds a form with the CSRF token and the right method and submits it.

data-confirm-delete worked this way before, but only on the request where confirmDelete() had been flashed — on any other render the link was an ordinary link and the browser opened the destroy URL with a GET. The listener is always present now. Closes #174 and #183.

SweetAlert2 is fetched on the first click, so a page carrying only a guarded link ships no JavaScript until someone uses it. If it cannot be fetched, the browser's own confirm() is used — a guarded delete never goes through unasked because a CDN was down.

submitTo()

The answer reaches your server instead of vanishing when the dialog closes:

Alert::input('What should we call you?')
    ->submitTo(route('profile.name'), 'POST', 'name')
    ->flash();

Closes #147.

topLayer()

Puts a popup in the browser's top layer, above any z-index — the answer to a toast rendering behind a navbar. Closes #158.

Upgrading

php artisan alert:upgrade --dry-run

The command rewrites the two methods whose signatures changed, the container binding, the moved SessionStore, the Blade include, and the config keys that break theming. It reads your code with PHP's own tokeniser rather than searching for text, so a ->html() call on an unrelated object, or the old binding name inside a comment, is reported rather than edited. Nothing is written without confirmation and vendor/ is never touched.

Run against five real third-party applications it scanned 1,065 files and rewrote 16, with no false positives and no broken syntax.

It exists because of html() specifically. v7's signature was html($title, $code, $icon); v8's is html($html). PHP ignores surplus arguments, so an un-migrated call does not error — it just stops working.

Two config keys to check if you published the config under v7: background, width and padding are now null by default. SweetAlert2 applies each as an inline style that beats every stylesheet, so a background value means no theme can ever change the popup colour. alert:upgrade fixes this for you.

Requirements

PHP 8.3+ and Laravel 11, 12 or 13.

Full upgrade path: https://realrashid.github.io/sweet-alert/guide/upgrade-guide

v7.3.2

v7.3.2 - 2026-03-29

  • Laravel 12 compatibility fix for Alert facade (Closes #181)
  • Fixed: Corrected SweetAlertServiceProvider::register() — the bind() call was incorrectly passing a third argument (ToSweetAlert class string as $shared), causing Alert::warning and other facade methods to fail under Laravel 12's stricter container resolution
  • Added [@method](https://github.com/method) PHPDoc annotations to the Alert facade for full IDE and static-analysis support
v7.3.1

v7.3.1

Release Notes

  • Fixed: Prevent Blade from compiling example route in resources/boost/guidelines/core.blade.php by escaping Blade braces in the example (use @{{ … }}). Fixes #190 — reported by @mohammedterfa.
  • Docs Updated

Upgrade notes:

  • This is a documentation-only fix; there are no breaking changes.
v7.3.0
  • Added Laravel 13 Support
  • Updated bundled SweetAlert2
  • Added Laravel Boost AI guidelines and Boost Skill
  • Docs Updated

Upgrade notes:

  • Ensure your application meets Laravel 13 PHP requirements before upgrading.
  • Keep using asset('vendor/sweetalert/sweetalert.all.js') if you rely on the bundled JS path.
v7.2.0

v7.2.0 - 2024-06-15

  • Added Laravel 11 Support
  • Upgraded SweetAlert2 to the latest version
  • Bug Fixes
  • Updated Documentation

What's Changed

  • Fixed: Issue with Always/Never load JS config not working as expected (PR #172) by @hoRacy

New Contributors

  • @hoRacy made their first contribution in PR #172

Full Changelog: https://github.com/realrashid/sweet-alert/compare/v7.1.1...v7.2.0

v7.1.1
  • Added Laravel 10 Support
v7.1.0

v7.1.0 - 2023-08-08

  • Upgraded SweetAlert2 to latest version
  • Customizable default confirm/cancel button texts. by @hakimzulkufli
  • Bug Fixes
  • Docs Updated

Full Changelog: https://github.com/realrashid/sweet-alert/compare/v7.0.0...v7.1.0

v7.0.0

v7.0.0 - 2023-04-20

  • Added confirmDelete function
  • Added themes feature
  • Upgraded SweetAlert2 to latest version
  • Bug Fixes
  • Docs Updated
v6.0.0

v6.0.0 - 2023-02-15

  • Added Laravel 10 Support
  • Bug Fixes
  • Docs Updated

What's Changed

Full Changelog: https://github.com/realrashid/sweet-alert/compare/v.5.1.1...v6.0.0

v.5.1.1
  • Docs Updated
v5.1.0

v5.1.0

  • Added Laravel 9 Support
  • Bug Fixes
  • Docs Updated
v5.0.0

v5.0.0

  • Added Laravel 9 Support
  • Bug Fixes
  • Upgraded SweetAlert2 to latest version
  • Docs Updated
v4.1.0

v4.1.0 - 2021-11-05

  • Bug Fixes
  • Upgraded SweetAlert2 to latest version
  • Docs Updated
v4.0.0
  • Bug Fixes
  • Upgraded SweetAlert2 to latest version
  • added .gitattributes file
  • Docs Updated
v3.2.3
  • Bug Fixes
  • Upgraded SweetAlert2 to latest version
  • Docs Updated
v3.2.2
  • Remove Laravel 6 Support
  • Upgraded SweetAlert2 to latest version
  • Docs Updated
v3.2.1
  • Fixed PHP 8 Issues
  • Upgraded SweetAlert2 to latest version
  • Docs Updated
v3.2.0
  • Added PHP8 Support
  • Upgraded SweetAlert2 to latest version
  • Docs Updated
v3.1.7
  • Added Support for Laravel 8
  • Upgraded SweetAlert2 to latest version
  • Minor Changes
  • Docs Updated
v3.1.6
  • Added flexibility to Always load the sweetalert.all.js and Never load the sweetalert.all.js by farhanianz
  • Upgraded SweetAlert2 to latest version
  • Minor Changes in Middleware.md
  • Docs Updated
v3.1.5
  • Upgraded SweetAlert2 to latest version
  • Minor Changes in Middleware
  • Docs Updated
v3.1.4
  • Upgraded SweetAlert2 to latest version
  • Added ability to custom css classes
  • Docs Updated
v3.1.3
  • Upgraded SweetAlert2 to latest version v9.8.1
v3.1.2
  • Upgraded SweetAlert2 to latest version 🎉
  • Prepare Laravel 7 🎉
v3.1.1
  • Upgraded SweetAlert2 to latest version 🎉
  • Added ability to activate or not the middleware error messages 🎉
  • Docs Updated 🎉
  • Fixed #64
v3.1.0
  • Upgraded SweetAlert2 to latest version :tada:
  • Added Tidelift to funding.yaml :tada:
  • Added SECURITY.md in .github/SECURITY.md :tada:
  • Added timerProgressBar() method :tada:
  • Added PublishCommand to easily publish the package assets :tada:
  • Updated question() alert method :tada:
  • Refactor SweetAlertServiceProvider class :tada:
  • Refactor Toaster class :tada:
  • Refactor functions.php file :tada:
  • Updated PHPDocBlocks :tada:
  • Docs Updated :tada:
v3.0.1
  • Updated animation($showClass = [], $hideClass = []) to animation($showAnimation, $hideAnimation)
  • Docs Updated
  • Fixed animations issue
  • Fixed #59
v3.0
  • :tada: Upgraded SweetAlert2 to latest version
  • :tada: Added option to pass SweetAlert2 CDN link from included view
  • :tada: Updated animation($showClass = [], $hideClass = []) method
  • :tada: Added buttonsStyling() method
  • :tada: Added iconHtml() method
  • :tada: Docs Updated
  • :tada: Fix some bugs
v2.0.3

Added symfony/thanks Docs Updated Fix some bugs

v2.0.2

Added Missing ^ indicator prevents Laravel from updating to 6.0.1 and up Docs Updated Fix some bugs

v2.0.1

Added support for Laravel 6.0.

This release fixed #46 .

Thank to @jnbn for his contribution.

v2.0

v2.0 - 2019-06-14

  • Upgraded SweetAlert2 to latest version
  • Added width() helper method
  • Added padding() helper method
  • Added background() helper method
  • Added animation() helper method
  • Added focusConfirm() helper method
  • Added focusCancel() helper method
  • Added CDN Support
  • Docs Updated
  • Fix some bugs

Changes

// From
public function toast($title = '', $type = '', $position = 'bottom-right'){...}
// To
public function toast($title = '', $type = ''){...}

// set the default position in package config file or use the helper method position()
v1.1.2

v1.1.2 - 2019-03-29

  • Upgraded SweetAlert2 to latest version
  • Added hideCloseButton() helper method
  • Added reverseButtons() helper method
  • Added image() method
  • Added addImage() helper method
  • Added position() helper method
  • Docs Updated
  • Fix some bugs
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.
adachsoft/changelog-linter
adachsoft/collection
payerurl/telegrambot-crypto-payment-instant-payout
dskripchenko/laravel-hybrid-search
riorizkyrainey/lara-ced
mehedimi/static-vel
zharp/zharp
nonsapiens/bigquery-model-sync
lgu-bayambang-ict-office/lgu-laravel-development-standards
andydefer/laravel-support
se7enxweb/flysystem
lampwick/laravel
jeslage/statamic-emojis
micahdshackelford/rmap-laravel
draftsmaninc/draftsman
square-bit/laravel-volition
himito/laravel-mailman
htinlynn/genius-helper
maco-studios/hephaestus
adachsoft/php-code-style