DEV Community

Rashid Ali
Rashid Ali

Posted on

Laravel SweetAlert

Laravel SweetAlert

Laravel SweetAlert 2 is a Laravel package that integrates the popular JavaScript SweetAlert 2 with Laravel.

Using the package’s Alert facade or alert() helper, you can queue up SweetAlert 2 alerts on the frontend from your controller:

It so easy to implement and easy to use give a shot and leave your thoughts.


To get started with Laravel SweetAlert,
use Composer to add the package to your project's dependencies:

composer require realrashid/sweet-alert


  • alert('Title','Lorem Lorem Lorem', 'success');

  • alert()->success('Title','Lorem Lorem Lorem');

  • alert()->info('Title','Lorem Lorem Lorem');

  • alert()->warning('Title','Lorem Lorem Lorem');

  • alert()->question('Title','Lorem Lorem Lorem');

  • alert()->error('Title','Lorem Lorem Lorem');

  • alert()->html('<i>HTML</i> <u>example</u>'," You can use <b>bold text</b>, <a href='//'>links</a> and other HTML tags ",'success');


  • toast('Your Post as been submited!','success','top-right');

You can also configure the package’s ToSweetAlert middleware to handle SweetAlert 2 messages during a middleware handler:

public function someFunction(Request $request)
    return redirect('login')->with('success', 'Login Successfully!');

You should check out the Documentation to see what methods are available.
You can learn more about this package and check out the source code on GitHub at realrashid/sweet-alert

Featured On

Top comments (0)