Laravel How to Add Toastr Notifications

Hello Artisans, today I'll talk about implementing Toastr notifications in our Laravel application. Toastr is JavaScript library which display the message in the form of notification. It can be success, warning, info or error. It is necessary when a user performs an action and we've to notify that user. So, let's see how we can user Toastr notifications in our application.

Note: Tested on Laravel 9.2.

Table of Contents

  1. Install brian2694/laravel-toastr
  2. Add CSS and JS to html
  3. Create and Setup Controller
  4. Define Route
  5. Output

Install brian2694/laravel-toastr

Firstly we need to install the brian2694/laravel-toastr package. Run the below command in your terminal to install :

composer require brian2694/laravel-toastr

Add CSS and JS to html

Now we will modify the Laravel default welcome.blade.php. So, put the below code in yours.

<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">

        <title>Laravel Toastr Notification</title>

        <link rel="stylesheet" href="">
    <body class="antialiased">
        <script src=""></script>
        <script src=""></script>
        {!! Toastr::message() !!}

Create and Setup Controller

First we'll create a controller where we can use our logic to show user a toastr notification. Fire the below command in your terminal to create a controller.

php artisan make:controller ToastrNotificationController

Now put the below code in ToastrNotificationController.php.


namespace App\Http\Controllers;

use Brian2694\Toastr\Facades\Toastr;

class ToastrNotificationController extends Controller
    public function toastrNotification()
        //put your logic here

        Toastr::success('You Have Successfully Implement Toastr Notification :)', 'Success!!');
        return view('welcome');

Define Route

Now Replace your web.php file with the below codes.


use Illuminate\Support\Facades\Route;



Now if you go to you'll see the below notification in the top right most corner.

Toastr Notification in Laravel 9

That's it for today. Hope you'll enjoy this tutorial. You can also download this tutorial from GitHub. Thanks for reading. ๐Ÿ™‚