nawasara/toaster
Lightweight Alpine-powered toast notifications for Laravel and Livewire. Add one component to your layout and trigger success/error/warning/info toasts from JavaScript, Livewire, or session flash. Configurable position, optional progress bar, dark-mode aware.
HasToaster trait and HasBrowserToast concern integrate natively with Livewire’s event system, enabling real-time toasts without page reloads—a key advantage for interactive applications.HasBrowserToast feature requires the nawasara/ui package, adding complexity for basic use cases.window.Laravel.toast, which could conflict with existing flash handlers (e.g., Laravel’s default status flash). Middleware may be needed to normalize flash keys.HasBrowserToast been tested with Livewire 3, and is nawasara/ui required for real-time toasts?session()->flash('status', ...)) coexist with the package’s toast flash key? Will middleware be needed to migrate legacy flashes?laravel-notification-directives).<x-nawasara-toaster::script /> and <x-nawasara-toaster::toaster />) to a single layout (e.g., app.blade.php).window.Toast.success('Test').session()->flash('toast', [...]).HasToaster for post-redirect toasts and evaluate HasBrowserToast for real-time needs.window.Toast calls.toast format, using middleware to normalize legacy flashes.HasToaster for simplicity, then adopting HasBrowserToast for real-time feedback if needed.HasToaster works with Livewire 2.x/3.x, but HasBrowserToast may require nawasara/ui for Livewire 3.x. Verify compatibility with the project’s Livewire version.status). Implement middleware to redirect non-toast flashes or merge them into the toast format:
// app/Http/Middleware/NormalizeFlashMessages.php
public function handle($request, Closure $next) {
if ($request->session()->has('status')) {
$request->session()->flash('toast', [
'type' => 'info',
'message' => $request->session()->get('status'),
]);
$request->session()->forget('status');
}
return $next($request);
}
dark: classes). Test in both light and dark themes.toast format.HasToaster for post-redirect toasts in Livewire components.HasBrowserToast for real-time toasts, installing nawasara/ui if needed.position, duration) via a global script or middleware.center).HasBrowserToast featureHow can I help you explore Laravel packages today?