Laravel 9 Livewire Sweetalert Example

This post is originally published at websolutionstuff.com — 3 min read

In this article, we will see the laravel 9 livewire sweet alert example. Here we will learn how to use sweetalert in laravel 9 with livewire.

sweetalert2 is used to create different types of custom alert messages. You can create custom popups like success messages, error messages, warning modals, confirm modals, custom notifications, etc.

Javascript provides a simple alert box in your browser but if you want to display a custom popup then a sweet alert is a very effective library that allows us to create all kinds of alert messages.

The sweet alert is a responsive, beautiful, customizable, and zero-dependent javascript plugin.

So, let’s see sweetalert in laravel 7, laravel 8, and laravel 9 and how to use sweetalert2 in laravel 9 using livewire.

Step 1: Install Laravel 9

In this step, we will install laravel 9 using the following command.

Read Also: Laravel 9 Livewire CRUD Operation

Step 2: Install Livewire

In this step, we will install laravel livewire using the following composer command.

Step 3: Create Component

Now, we will create a livewire notification component for sweet alert notifications.

app/Http/Livewire/sweetAlertNotification.php

resources/views/livewire/sweet-alert-notification.blade.php

Read Also: Laravel 9 Ajax File Upload With Progress Bar

Step 4: Create Route

In this step, we will add routes to the web.php file.

routes/web.php

Step 5: Create View File

In this step, we will create a blade file and include @livewireStyles, and @livewireScripts.

resources/views/layouts/app.blade.php

If this post was helpful, please click the clap 👏 button below.

--

--

I am Laravel and PHP Developer. I have also Good Knowledge of JavaScript, jQuery, Bootstrap and REST API. Visit Website: http://websolutionstuff.com/

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Websolutionstuff

I am Laravel and PHP Developer. I have also Good Knowledge of JavaScript, jQuery, Bootstrap and REST API. Visit Website: http://websolutionstuff.com/