TheDocumentation Index
Fetch the complete documentation index at: https://veekthoven-laravel-inertia-toast-24-61.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
toast() helper function provides a convenient fluent interface for creating toast notifications. It returns a PendingToast builder when called with a message, or the Toaster instance when called without arguments.
Function signature
The message for the toast notification. If provided, returns a
PendingToast builder. If omitted, returns the Toaster instance.PendingToastwhen a message is providedToasterwhen called without arguments
Usage patterns
Fluent builder pattern
The recommended way to use the helper is with the fluent builder pattern:With title and duration
Access Toaster instance
PendingToast builder methods
Whentoast() is called with a message, it returns a PendingToast instance with the following fluent methods:
title()
Set a title for the toast notification.The title to display above the toast message.
PendingToast instance for method chaining
Example:
duration()
Set how long the toast should be displayed.The duration in milliseconds to display the toast notification.
PendingToast instance for method chaining
Example:
success()
Commit the toast as a success notification.Toaster instance
Example:
error()
Commit the toast as an error notification.Toaster instance
Example:
info()
Commit the toast as an informational notification.Toaster instance
Example:
warning()
Commit the toast as a warning notification.Toaster instance
Example:
Complete examples
Basic usage
Advanced usage
In controllers
In form requests
Comparison with facade
The helper function provides a more readable fluent interface, while the facade offers a more concise API. Both approaches are equally valid and produce the same result.
When to use the helper
Thetoast() helper is ideal when:
- You want a fluent, readable API
- You’re building toast configuration step by step
- You prefer not importing the facade in every file
- You want IDE autocompletion for the builder pattern
Toast facade may be more concise.