Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

oakydev's avatar

Handling Notifications with VILT Stack

Hey guys!

I'm working with the VILT stack on several projects and I'm currently running into some issues with notifications. I don't mean persistent notifications, but rather notifications that are used when the user performs an action.

When I flash the notification into the user's current session, there is an issue with redirecting the user to another page. I understand why this happens, but for example, after a user has created a resource, they should be redirected, shouldn't they? I think so, but it is not working properly with the session flash option.

Another option I have tried is real-time notifications via Reverb. The problem I have is that it takes too long for the notification to appear. This could be a problem with the queue taking too long to process the job, or it could be that it takes too long to put the notification into the queue.

Any suggestions or ideas are welcome!

0 likes
2 replies
cookie's avatar

What exactly do you mean with "there is an issue with redirecting" ?? What kind of issue? Did the redirection not work or it works but without notifications in the bag?

Sometimes you can just refresh the page/component when a new resource is created. No need to redirect them anywhere. It depends.

oakydev's avatar

@cookie The redirect works as intended. The notification also gets dispatched.

A controller looks like this for example

public function destroy(Model $model)
{
		// More code...

		Notification::send('Notification Title', 'Notification Text', Notification::SUCCESS);

		return redirect()->route('route');
}

The helper function for sending the notification:

public static function send(string $title, string $message, string $type = self::INFO, int $duration = 7500): void
    {
        if (auth()->check()) {
            auth()->user()->notifyNow(new BroadcastNotification($title, $message, $duration, $type));
            return;
        }
    }

The notification just doesn't show up because of the page switch after I dispatched the notification.

A solution for this would be to notify the user and put the notification in the queue of the queue but the process of the notification being placed into the queue and processed just takes too long. (Currently I use a laravel/reverb for the websocket connection and dispatch the notification through the websocket server)

Please or to participate in this conversation.