Skip to main content
Learn how to integrate Laravel Inertia Toast with Vue 3. This guide covers plugin installation, component setup, and usage of the useToast composable.

Installation

First, install the Vue 3 package:

Setup

1

Register the plugin

You can customize the default behavior by passing configuration options:

Configuration options

2

Add the Toasts component

Place the <Toasts /> component in your root layout file (e.g., Layout.vue):
The <Toasts /> component uses a fixed position, so it doesn’t matter where in your layout you place it.

Using the composable

The useToast composable provides methods to programmatically create toasts from your Vue components.

Basic usage

Available methods

The useToast composable returns an object with the following methods:

success(message, options?)

Displays a success toast.

error(message, options?)

Displays an error toast.

info(message, options?)

Displays an info toast.

warning(message, options?)

Displays a warning toast.

Toast options

You can customize individual toasts using the options parameter:

TypeScript support

The package is written in TypeScript and includes full type definitions:

Advanced usage

Direct store access

For advanced use cases, you can access the toast store directly:
Direct store manipulation is for advanced use cases. It is unnecessary and highly discouraged. Use the useToast composable for most scenarios.

Next steps

Styling

Customize the appearance of your toasts

Laravel setup

Configure Laravel to send toast notifications