Install and configure Laravel Inertia Toast for your Laravel + Inertia.js application
Laravel Inertia Toast consists of three packages: a PHP backend package and two frontend adapters (Vue 3 and React). You need to install the PHP package and the adapter for your frontend framework.
The <Toasts /> component can be placed inside <ToastProvider> anywhere in your app. Many developers prefer adding it to the main app setup as shown above.
4
Configure Tailwind CSS
Since the toast components use Tailwind classes internally, you need to add the package to Tailwind’s source detection so the required classes are generated.
Tailwind v4
Tailwind v3
Add the following @source directive to your main CSS file (e.g., resources/css/app.css):
return [ // Default duration (in milliseconds) before a toast auto-dismisses 'duration' => 5000, // Where toasts appear on screen // Options: top-right, top-left, top-center, bottom-right, bottom-left, bottom-center 'position' => 'top-right', // Maximum number of toasts visible at once 'max_visible' => 5, // The key used when flashing toast data via Inertia::flash() 'prop_key' => 'toasts',];
You can override the backend defaults when registering the plugin or provider:
Vue 3
React
Copy
app.use(InertiaToast, { duration: 3000, // Auto-dismiss after 3 seconds position: 'top-center', // Show toasts at top-center maxVisible: 3, // Show max 3 toasts at once propKey: 'toasts', // Inertia flash key (must match backend)})
Copy
<ToastProvider config={{ duration: 3000, // Auto-dismiss after 3 seconds position: 'top-center', // Show toasts at top-center maxVisible: 3, // Show max 3 toasts at once propKey: 'toasts', // Inertia flash key (must match backend) }}> {/* ... */}</ToastProvider>
If you change prop_key in the PHP config, make sure to update propKey in your frontend configuration to match.