Back to Projects
Laravel Sooner — Beautiful Toast Notifications

Laravel Sooner — Beautiful Toast Notifications

A premium Laravel wrapper for [Sonner](https://sonner.emilkowal.ski/) — one of the most refined toast notification libraries in the JavaScript ecosystem. Dispatch beautiful, accessible, animated toast messages from any PHP controller, action, or Livewire component using a fluent, zero-configuration API.

AI Summary

Replaces session-flashed messages and dated JavaScript alert libraries with a fluent PHP API backed by Sonner, delivering animated, accessible toast notifications from any Laravel controller, job, or Livewire component without writing any JavaScript.

Overview

Feedback notifications are a fundamental element of web application UX — yet most Laravel applications still rely on session-flashed messages rendered through custom Blade conditionals, or legacy JavaScript alert libraries that look out of place in modern interfaces. Laravel Sooner modernises this entirely by wrapping Sonner, one of the most visually refined toast notification libraries in the JavaScript ecosystem, in a first-class Laravel integration with a native PHP API.

The Problem It Solves

The most common notification patterns in Laravel applications suffer from several overlapping problems:

Session flash messages require custom rendering logic in every layout, produce inconsistent UX across different browsers, and have no animation or dismissal support out of the box.

JavaScript alert libraries like alert(), SweetAlert, or Toastr exist outside the PHP request/response lifecycle, require manual coordination between PHP and JavaScript state, and often carry heavy legacy bundle overhead.

Livewire's built-in notifications are limited to Filament/panel contexts and lack the design quality of purpose-built toast libraries.

Laravel Sooner resolves all of this: dispatch a toast from PHP, it appears beautifully in the browser.

Key Features

  • Fluent PHP APISooner::success('Saved.'), Sooner::error('Something went wrong.'), Sooner::warning('Check your input.')
  • All Sonner types — success, error, warning, info, loading state, and fully custom rich content
  • Session-backed dispatch — works naturally within the standard Laravel request/response cycle
  • Livewire events — dispatch toasts from Livewire component methods using $this->dispatch('sooner.success', 'Message')
  • Zero JavaScript configuration — include the Blade directive and everything works
  • Positioning and duration — configure position (top-right, bottom-center, etc.) and display duration globally or per-toast
  • Rich content support — optionally render toasts with title, description, and action buttons
  • Accessible — Sonner provides ARIA live region support so toasts are read by screen readers

Usage

From a controller:

use AmjadIqbal\LaravelSooner\Facades\Sooner;

public function store(StoreProjectRequest $request)
{
    $project = Project::create($request->validated());
    Sooner::success('Project created successfully!');
    return redirect()->route('projects.index');
}

In your layout:

@soonerToasts

Technology Stack

PHP 8.2+, Laravel 11/12, Sonner (modern JavaScript toast library), Alpine.js (optional reactive integration). The JavaScript footprint is minimal — Sonner is approximately 8KB gzipped.

Practical Use Cases

  • SaaS dashboards where every CRUD operation needs clear, non-intrusive feedback
  • Multi-step form workflows where partial validation messages guide users forward
  • Admin panels built on Blade without Filament's built-in notification system
  • E-commerce applications where add-to-cart, checkout, and order actions need instant confirmation
  • Any Laravel application where polished, animated notifications improve perceived quality

Source & License

Source code, configuration documentation, and Livewire integration guide on GitHub. MIT Licensed.

Need something like this built?

Let's discuss your project requirements.

Get in Touch