News

Laravel Starter Kits Now Include Toast Notifications

Published

All four official Laravel starter kits now include toast notifications out of the box. The update replaces the previous inline action messages with a consistent notification pattern across every stack. The feature was contributed by @WendellAdriel.

How It Works

Inertia Stacks (React, Vue, Svelte)

The Inertia-based kits use a new Inertia::flash() call on the server side to pass toast data to the frontend:

Inertia::flash('toast', ['type' => 'success', 'message' => __('Profile updated.')]);
 
return to_route('profile.edit');

On the frontend, a useFlashToast hook listens for Inertia's flash event and triggers a Sonner toast. Here's the React implementation:

import { router } from '@inertiajs/react';
import { useEffect } from 'react';
import { toast } from 'sonner';
import type { FlashToast } from '@/types/ui';
 
export function useFlashToast(): void {
useEffect(() => {
return router.on('flash', (event) => {
const flash = (event as CustomEvent).detail?.flash;
const data = flash?.toast as FlashToast | undefined;
 
if (!data) {
return;
}
 
toast[data.type](data.message);
});
}, []);
}

The FlashToast type supports four variants — success, info, warning, and error — giving you control over how notifications appear:

export type FlashToast = {
type: 'success' | 'info' | 'warning' | 'error';
message: string;
};

A <Toaster /> component wraps Sonner and is mounted at the app level, so toasts work on any page without additional setup.

Livewire Stack

The Livewire kit uses Flux's built-in toast component. Instead of dispatching browser events and relying on inline <x-action-message> components, you call Flux::toast() directly:

use Flux\Flux;
 
Flux::toast(variant: 'success', text: __('Profile updated.'));

Each layout file includes a persisted toast group so notifications survive Livewire re-renders:

@persist('toast')
<flux:toast.group>
<flux:toast />
</flux:toast.group>
@endpersist

This replaces the previous <x-action-message> component, which displayed a temporary "Saved." message inline next to the save button.

What Changed

The toast notifications are wired up for profile updates, password changes, and email verification across all four kits. The settings controllers now flash toast data instead of relying on session status messages or Livewire event dispatches.

To add toasts to your own actions, use Inertia::flash() for the Inertia stacks or Flux::toast() for Livewire — the frontend plumbing is already in place.

Each Inertia stack uses a framework-specific Sonner port — sonner for React, vue-sonner for Vue, and svelte-sonner for Svelte — while the Livewire kit uses Flux toast components.

References

Paul Redmond photo

Staff writer at Laravel News. Full stack web developer and author.

Sponsored

masteringlaravel logo
Laravel Code Review

Get expert guidance in a few days with a Laravel code review

Visit Laravel Code Review

The latest

View all →
Laravel Truss: Live Interactive Database ER Diagrams image

Laravel Truss: Live Interactive Database ER Diagrams

Read article
Laravel artisan dev: Run Server, Queue, Logs, and Vite image

Laravel artisan dev: Run Server, Queue, Logs, and Vite

Read article
Validate and Convert HEIC Images in Laravel image

Validate and Convert HEIC Images in Laravel

Read article
Saga Lara Flow: Durable Workflows and Compensating Transactions on Laravel Queues image

Saga Lara Flow: Durable Workflows and Compensating Transactions on Laravel Queues

Read article
Reject Unexpected Array Keys with Laravel Validation image

Reject Unexpected Array Keys with Laravel Validation

Read article
Major performance improvements & security patches for Filament v4.12 and v5.7! image

Major performance improvements & security patches for Filament v4.12 and v5.7!

Read article