Skip to main content
You can trigger toast notifications from your Laravel controllers, routes, or any backend code using either the Toast facade or the toast() helper function.

Using the facade

The Toast facade provides static methods for each toast type:
use InertiaToast\Facades\Toast;

Toast::success('Profile updated!');
Toast::error('Something went wrong.');
Toast::info('Check your email for a confirmation link.');
Toast::warning('Your subscription is about to expire.');

return redirect()->route('dashboard');

Method signatures

Each toast method accepts the following parameters:
Toast::success(string $message, ?string $title = null, ?int $duration = null): Toaster
Toast::error(string $message, ?string $title = null, ?int $duration = null): Toaster
Toast::info(string $message, ?string $title = null, ?int $duration = null): Toaster
Toast::warning(string $message, ?string $title = null, ?int $duration = null): Toaster

Using the helper

The toast() helper provides two usage patterns:

Fluent builder pattern

When called with a message, it returns a PendingToast instance that allows you to chain configuration methods:
toast('Profile updated!')->success();
toast('Something went wrong.')->error();
toast('Slow message.')->duration(10000)->warning();

Direct toaster access

When called without arguments, it returns the Toaster instance for direct method calls:
toast()->success('Quick shorthand');
toast()->error('Operation failed');

Toast types

Laravel Inertia Toast supports four toast types:
Use for successful operations:
Toast::success('Profile updated successfully!');
toast('Changes saved!')->success();

Adding a title

You can add an optional title to provide context for your toast messages.

With the facade

Use named arguments to specify the title:
Toast::success('Profile has been updated.', title: 'Success');
Toast::error('Unable to connect to database.', title: 'Connection Error');

With the helper

Chain the title() method:
toast('Item has been removed.')->title('Deleted')->error();
toast('Operation completed successfully.')->title('Done')->success();

Custom duration

By default, toasts auto-dismiss after the duration specified in your config (5000ms). You can override this per toast.
Duration is specified in milliseconds. For example, 3000 = 3 seconds.

With the facade

Toast::success('Saved!', duration: 3000); // 3 seconds
Toast::warning('Session expiring soon.', duration: 10000); // 10 seconds

With the helper

Chain the duration() method:
toast('Done!')->duration(3000)->success();
toast('Important message')->duration(10000)->info();

Combining title and duration

You can combine both title and duration options:

With the facade

Toast::warning(
    'Your session is about to expire.',
    title: 'Warning',
    duration: 10000
);

Toast::success(
    'Report generated successfully.',
    title: 'Export Complete',
    duration: 8000
);

With the helper

toast('Your session is about to expire.')
    ->title('Warning')
    ->duration(10000)
    ->warning();

toast('Report generated successfully.')
    ->title('Export Complete')
    ->duration(8000)
    ->success();

Multiple toasts

You can queue multiple toasts in a single request. They will be displayed according to your max_visible configuration:
public function update(Request $request)
{
    // Process multiple operations
    $this->updateProfile($request->user());
    $this->syncPreferences($request->user());
    $this->notifyAdmins($request->user());

    Toast::success('Profile updated.');
    Toast::success('Preferences synced.');
    Toast::info('Admins have been notified.');

    return redirect()->route('dashboard');
}

Working with redirects

Toasts work seamlessly with redirects because they’re flashed to the session via Inertia:
public function store(Request $request)
{
    $post = Post::create($request->validated());

    toast('Post published successfully!')->success();

    return redirect()->route('posts.show', $post);
}
Toasts persist across redirects, so you can trigger them before returning a redirect response.

Common patterns

Here are some common usage patterns:
public function store(Request $request)
{
    $validated = $request->validate([
        'email' => 'required|email',
        'password' => 'required|min:8',
    ]);

    User::create($validated);

    Toast::success('Account created successfully!', title: 'Welcome');

    return redirect()->route('dashboard');
}

API reference

PendingToast methods

The PendingToast class (returned by toast('message')) provides these chainable methods:
  • title(string $title): static - Set the toast title
  • duration(int $milliseconds): static - Set custom duration in milliseconds
  • success(): Toaster - Commit as a success toast
  • error(): Toaster - Commit as an error toast
  • info(): Toaster - Commit as an info toast
  • warning(): Toaster - Commit as a warning toast

Toaster methods

The Toaster class (accessed via Toast facade or toast() without arguments) provides:
  • success(string $message, ?string $title = null, ?int $duration = null): Toaster
  • error(string $message, ?string $title = null, ?int $duration = null): Toaster
  • info(string $message, ?string $title = null, ?int $duration = null): Toaster
  • warning(string $message, ?string $title = null, ?int $duration = null): Toaster
  • add(string $message, ToastLevel $level, ?string $title = null, ?int $duration = null): Toaster
  • hasPending(): bool - Check if there are pending toasts
  • getPropKey(): string - Get the Inertia flash key