Skip to main content
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 configuration

Publish the configuration file to customize backend defaults:
This creates a config/inertia-toast.php file in your Laravel application.

Configuration options

duration

Type: int
Default: 5000
The default duration in milliseconds before a toast auto-dismisses. This value is sent to the frontend and can be overridden per-toast.
You can override this for individual toasts:

position

Type: string
Default: 'top-right'
Where toasts appear on screen. Available options:
  • top-right
  • top-left
  • top-center
  • bottom-right
  • bottom-left
  • bottom-center
The position can also be configured on the frontend when registering the plugin or provider.

max_visible

Type: int
Default: 5
The maximum number of toasts visible at once. When this limit is exceeded, the oldest toasts are automatically removed first.

prop_key

Type: string
Default: 'toasts'
The key used when flashing toast data via Inertia::flash(). This is the property name that will be available in your Inertia page props.
If you change the prop_key, you must also update your frontend configuration to match. Otherwise, toasts won’t be displayed.

Frontend configuration

You can configure frontend toast behavior when registering the Vue plugin or React provider.

Vue 3

Pass options when installing the plugin:

Options

All options are optional and will use defaults if not provided:

React

Pass configuration to the <ToastProvider> component:

Config prop

The config prop accepts a partial configuration object:

Configuration precedence

Configuration values follow this precedence order (highest to lowest):
  1. Per-toast options - Options passed when creating a specific toast
  2. Frontend configuration - Options passed to plugin/provider
  3. Backend configuration - Values in config/inertia-toast.php
  4. Package defaults - Built-in default values

Example

Position examples

Here’s how different position values affect toast placement:

Duration guidelines

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
For important messages that users should read carefully, consider using a longer duration.

Max visible recommendations

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
Setting maxVisible too high can overwhelm users. Consider queuing operations or consolidating related toasts into a single message.

Custom prop key

If you need to use a different Inertia flash key (for example, to avoid conflicts with existing code):

Backend

Vue

React

The propKey value must match between backend and frontend, otherwise toasts won’t be displayed.

Environment-specific configuration

You can use environment variables to adjust toast behavior across different environments:
Then in your .env file:

Complete examples