Configure toast behavior and appearance for both backend and frontend
Laravel Inertia Toast can be configured on both the backend (PHP) and frontend (Vue/React) to customize the default behavior of your toast notifications.
// Backend config: duration = 5000// Frontend config: duration = 8000// This toast will show for 8 seconds (frontend config)Toast::success('Default duration');// This toast will show for 3 seconds (per-toast override)Toast::success('Custom duration', duration: 3000);
Recommended duration values based on message length:
Short messages (1-20 chars): 3000-4000ms
Medium messages (21-50 chars): 5000-6000ms (default)
Long messages (51+ chars): 8000-10000ms
Critical warnings: 10000-15000ms
Copy
// Short success messageToast::success('Saved!', duration: 3000);// Medium info messageToast::info('Your profile has been updated successfully.');// Long warning messageToast::warning( 'Your subscription will expire in 3 days. Please update your payment method to continue using our service.', duration: 10000);
For important messages that users should read carefully, consider using a longer duration.
The optimal number of simultaneous toasts depends on your use case:
Most applications: 3-5 toasts (default: 5)
Bulk operations: 8-10 toasts
Minimal UI: 1-2 toasts
Copy
// For a clean, minimal interfaceapp.use(InertiaToast, { maxVisible: 2})// For bulk operations with many notificationsapp.use(InertiaToast, { maxVisible: 10})
Setting maxVisible too high can overwhelm users. Consider queuing operations or consolidating related toasts into a single message.
<?php// config/inertia-toast.phpreturn [ // Show toasts for 6 seconds 'duration' => 6000, // Position in bottom right 'position' => 'bottom-right', // Show max 3 toasts at once 'max_visible' => 3, // Use custom flash key 'prop_key' => 'notifications',];