Vue toastr notifications example
Our today's topic is how to implement toastr notifications in vue cli app. we will integrate toast notification using vue-toasted npm package.
vue-toasted npm package will provide method to generate toastr notifications like show, success, info, error, and register. you can also set icon with text as you want.
we can easily use with laravel or any php framework, also with VueJS, Laravel, NuxtJS. bellow you can show step by step implementation of toast notification popup in vue js app from scratch.
Step 1: Create Vue App
first we need to create vue cli app using bellow command:
vue create myApp
Step 2: Install vue-toasted Package
Here we need to install vue-toasted npm package that will allow to make http request.
npm install vue-toasted --save
Step 3: Use vue-toasted
We need to use vue-toasted package in main.js file of vue js app.
src/main.js
import Vue from 'vue'
import App from './App.vue'
import Toasted from 'vue-toasted';
Vue.config.productionTip = false
Vue.use(Toasted, {
duration: 1000
})
new Vue({
render: h => h(App),
}).$mount('#app')
Step 4: Update App.vue File
In this step, we need to update app.vue file, because i updated component so.
src/App.vue
<template>
<div id="app">
<Example></Example>
</div>
</template>
<script>
import Example from './components/Example.vue'
export default {
name: 'app',
components: {
Example
}
}
</script>
Step 5: Create Example Component
Here, we will create Example.vue component with following code.
src/components/Example.vue
<template>
<div class="container">
<div class="large-12 medium-12 small-12 cell">
<h1 style="font-family:ubuntu">Vue toastr notifications example - ItSolutionStuff.com</h1>
<button v-on:click="submitForm()">Trigger Notification</button>
</div>
</div>
</template>
<script>
export default {
data(){
return {
file: ''
}
},
methods: {
submitForm(){
this.$toasted.show('Hello, I am from ItSolutionStuff.com')
}
}
}
</script>
Now you can run vue app by using following command:
npm run serve
I hope it can help you...

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, Laravel, Angular, Vue, Node, Javascript, JQuery, Codeigniter and Bootstrap from the early stage. I believe in Hardworking and Consistency.
We are Recommending you
- How to create component in vue js cli?
- Laravel Vue Router Example From Scratch
- Laravel Vue JS File Upload Using vue-dropzone Example
- Laravel Vue JS Image Upload Example with Demo
- Laravel Vue JS Axios Post Request Example and Demo
- Laravel Vue JS Infinite Scroll Example with Demo
- Laravel Vue JS Pagination Example with Demo