Vue Js Sweetalert Modal Notification Example

By Hardik Savani | May 2, 2019 | Category : Vue.JS

In this tutorial, i will give you simple example of vue js sweet alert notification using sweetalert2 vue npm plugin. you can use sweet alert component notification in php laravel vue too.

You need to just follow few step to add sweetalert notification. you can also use confirm modal box with vue.

vue-sweetalert2 npm package will provide method to generate of sweet alert notifications like show, success, info, error, and register. you can also set icon with text as you want.

Step 1: Create Vue App

first we need to create vue cli app using bellow command:

vue create myApp

Step 2: Install vue-sweetalert2 Package

Here we need to install vue-sweetalert2 npm package that will allow to make http request.

npm install -S vue-sweetalert2

Step 3: Use vue-sweetalert2

We need to use vue-sweetalert2 package in main.js file of vue js app.


import Vue from 'vue'

import App from './App.vue'

import VueSweetalert2 from 'vue-sweetalert2';

Vue.config.productionTip = false


new Vue({

render: h => h(App),


Step 4: Updated HelloWorld Component

Here, we will create HelloWorld.vue component with following code.



<div class="container">

<div class="large-12 medium-12 small-12 cell">

<h1 style="font-family:ubuntu">Vue toastr notifications example -</h1>

<button v-on:click="showAlert">Hello world</button>

<button v-on:click="showAlertConfirm">Confirm Me</button>





export default {

methods: {


this.$swal('Hello Vue world!!!');




title: 'Are you sure?',

text: "You won't be able to revert this!",

type: 'warning',

showCancelButton: true,

confirmButtonColor: '#3085d6',

cancelButtonColor: '#d33',

confirmButtonText: 'Yes, delete it!'

}).then((result) => {

if (result.value) {



'Your file has been deleted.',









Now you can run vue app by using following command:

npm run serve

I hope it can help you...

Hardik Savani
My name is Hardik Savani. I'm a full-stack developer, entrepreneur and owner of Aatman Infotech. I live in India and I love to write tutorials and tips that can help to other artisan. I am a big fan of PHP, Javascript, JQuery, Laravel, Codeigniter, VueJS, AngularJS and Bootstrap from the early stage.
Follow Me: Github Twitter
***Do you want me hire for your Project Work? Then Contact US.

We are Recommending you: