Most people expect web applications to feel fast and responsive while using the site. They don’t want to keep refreshing the page all the time just to check if something has changed. That’s where in-app notifications come in. They show updates right away while you’re still using the app, which makes everything feel smoother and more alive.
In this article, I’ll walk through how to build a simple real-time notification system using Laravel 11. We’ll use notifications, database, broadcasting, and Reverb to send updates instantly, without making things too complicated.
1. Why real-time in-app notifications matter
Real-time notifications help users to notify them if there is a new important update from the sender instantly. If someone is already using the application, it feels much better to show the new activity right away instead of making them refresh the page again and again and check for it themselves.
This may look like a small feature, but it changes the experience a lot. When users can see a new comment, message, or update immediately, the application feels faster and more helpful. It also feels more alive because the screen responds to what is happening in real time.
There are a few reasons that can say this feature useful:
- Save time: The new information comes to them automatically, no need to refresh the page.
- Keep users informed: important updates are easier to notice. This is helpful for things like messages, approvals, or new activities like friend requests or accept, and so on.
- Make the application feel alive: Even a small live update can make the product feel smoother.
- Helps users act faster: when they see something right away, they can respond right away too.
2. How Laravel notifications work
Laravel has a built-in notification system. This system lets us send notifications in different ways, such as email, database, SMS, Slack, and broadcast. For this topic, the most important channels are the database channel and the broadcast channel.
The database channel saves the notification so the user can still read it later. The broadcast channel sends the notification live to the browser. When we use both together, we get a better result. The user sees the update immediately, and the system also keeps a saved copy in case the page is reloaded or the user comes back later.

You can think about it in a simple way. The database channel keeps the history, and the broadcast channel gives the live update.
3. Database notifications in Laravel
Before thinking about live updates, it is a good idea to store notifications in the database. This gives the application a memory of what happened. If the user closes the page or loses the internet for a moment, the notification is not lost.
Laravel makes this easy. First, we create the notifications table with these commands:
php artisan make:notifications-table
php artisan migrateAfter this, Laravel will have a table where notification data can be stored. This table usually includes things like the notification type, the related user, the data of the message, and the time when the notification was read.
Real-time updates are nice, but saving the notification is what makes the system practical. When the user comes back later, they can still open the notification list and see what they missed. That’s why many real projects start with database notifications first and then add broadcasting after that.
4. Setting up broadcasting with Reverb
Now let us move to the real-time part. Broadcasting is the feature that sends updates from Laravel to the browser as soon as something happens.
In Laravel 11, Reverb is the official tool for this. It works with Laravel broadcasting and helps us send live events in a clean way.
To start, you can install broadcasting support and reverb with these commands:
php artisan install:broadcasting
composer require laravel/reverb
php artisan reverb:installAfter that, you should check the .env file and make sure your reverb settings are there. A simple example may look like this:
BROADCAST_CONNECTION=reverb
REVERB_APP_ID=local-app
REVERB_APP_KEY=local-key
REVERB_APP_SECRET=local-secret
REVERB_HOST=127.0.0.1
REVERB_PORT=8080
REVERB_SCHEME=httpThen start the Reverb server:
php artisan reverb:start
At this point, Laravel is ready to send broadcast events and the browser can start listening for them. A common beginner mistake is forgetting to run the Reverb server. When that happens, the notification may still save in the database, but it will not appear live on the page.
5. Creating a notification class
Now we need a notification class. This class tells Laravel what kind of notification we want to send and through which channels.
You can create it with this command: php artisan make:notification InAppNotification
Here’s a simple example:
// app/Notifications/InAppNotification.php
<?php
namespace App\Notifications;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Messages\BroadcastMessage;
use Illuminate\Notifications\Notification;
class InAppNotification extends Notification
{
use Queueable;
public function __construct( public string $title, public string $message) {}
// This tells Laravel which channels to use.
// In this case, we use a database and broadcast only.
public function via(object $notifiable): array
{
return ['database', 'broadcast'];
}
// This method defines the data that will be stored in the database.
public function toArray(object $notifiable): array
{
return [
'title' => $this->title,
'message' => $this->message,
];
}
// This method defines the data that will be sent live.
public function toBroadcast(object $notifiable): BroadcastMessage
{
return new BroadcastMessage([
'title' => $this->title,
'message' => $this->message,
]);
}
}
This class does two important jobs. First, it saves the notification in the database. Second, it sends the same notification to the browser in real time.
Noted: If you want to send to other channels like email, SMS, or Slack, you can just add to the via() method. e.g., return ['database', 'broadcast', 'email',...];
6. Sending real-time notifications with broadcasting
Once the notification class is ready, sending the notification becomes very simple.
Before sending notifications, make sure your User model uses the Notifiable trait. In many Laravel applications, this is already included by default. This trait gives the model access to the notify() method.
class User extends Authenticatable
{
use Notifiable;
}Let’s imagine a simple example. Maybe an admin approves a request, or a user receives a new update in the system. When that happens, we can send an in-app notification like this:
use App\Notifications\InAppNotification;
$user->notify(
new InAppNotification(
'New Update',
'Your request was approved successfully.'
)
);This small line does a lot of work. Laravel will create the notification, store it in the database, and broadcast it in real time if the notification class is set up correctly.
7. Showing notifications in the user interface
That’s nearly close, once we finish the backend setting up, then we need to display those in the UI.
Laravel Echo listens for broadcast events and helps the frontend react when a new notification arrives.
window.Echo.private(`App.Models.User.${userId}`)
.notification((notification) => {
console.log(notification.message);
});This code listens on the private notification channel for the current user. When a notification arrives, the callback function runs.
Of course, in a real application, we usually want to do more than print the message in the console. We want to show it in the interface.
For example, we can add it to a list on the page:
window.Echo.private(`App.Models.User.${userId}`)
.notification((notification) => {
const list = document.getElementById('notification-list');
const item = document.createElement('li');
item.innerHTML = `<strong>${notification.title}</strong><br>${notification.message}`;
list.prepend(item);
});
And here is a small HTML example:
<h3>Notifications</h3>
<ul id="notification-list"></ul>This is just a simple demo. In the real application, you might need to highlight the notification read/unread so on, for a better user experience.
8. Using Queues for Better Performance
When the project becomes bigger, it is better to send notifications through a queue. A queue allows Laravel to do the work in the background instead of making the user wait.
This improves performance because sending notifications can take time, especially when many users are active at the same time. If everything happens inside one request, the page may feel slower.
Laravel makes this easy. You can update the notification class must also implement ShouldQueue:
<?php
namespace App\Notifications;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\BroadcastMessage;
use Illuminate\Notifications\Notification;
class InAppNotification extends Notification implements ShouldQueue
{
// The rest of your code does
}With this change, Laravel can process the notification in the background. To make it work, the queue worker must be running: php artisan queue:work
In this article, I don’t want to explain too much about how the queue works. This will be in another article later on.
In conclusion
Real-time in-app notification is very useful to make your product feel alive, improve performance, better UX, and smoother.
Laravel 11 and Reverb give us a clean way to build this feature. The process is not too hard when we break it into steps. First, we create and store the notification. Then we broadcast it. After that, the frontend listens for the event and updates the interface.
The best part is that you do not need to build everything at once. You can start with a simple version that stores notifications in the database and shows them in a basic list. Later, you can improve the design, add unread counts, and make the user interface more polished.
Main command, don’t forget to start the server:
php artisan reverb:start
// (optional) if you use Vite
npm run devMain reference for this article: Laravel Notifications Documentation
