Send Toast Notifications in Your Livewire Application with Toaster

April 28th, 2023

Send Toast Notifications in Your Livewire Application with Toaster

This Toaster package for Livewire creates beautiful toast notifications for your Laravel Livewire applications. It provides a seamless experience allowing you to send a toast to the UI from a standard controller or a Livewire component. You don't have to worry about session flashing; you dispatch your toast message:

This package provides a Toaster facade that you can use to send toast messages to the UI quickly:

Toaster::success('User created!');

Let's say that you have a controller creating a database record, and afterward, you want to redirect them. You can use this library to send a toast message by chaining it onto a redirect:

public function store(Request $request): RedirectResponse
{
// controller code...
// Send a toast after a redirect 🤩
return Redirect::route('dashboard')
->info('Company created!');
}

Lastly, you can also send toast messages from the front end:

<button @click="Toaster.success('Form submitted!')">
Submit
</button>

You can learn more about this package, get full installation instructions, and view the source code on GitHub.

Filed in:

Paul Redmond

Full stack web developer. Author of Lumen Programming Guide and Docker for PHP Developers.