Notification and Toast Plugin Example
Building a toaster plugin: reactive queue, install logic, programmatic API via provide/inject.
Goal: A Toast Plugin
We will build a toast notification plugin. It maintains a reactive queue of messages, exposes a notify API, and renders toasts globally. Any component can trigger a toast through inject or a composable.
The Reactive Queue
The core state is a reactive ref holding an array of toast objects. When we push/remove items, every component rendering the queue updates automatically.
import { ref } from 'vue'
const toasts = ref([])
// each toast: { id, message, type }All lessons in this course
- Plugin Architecture and app.use()
- Global Properties and provide/inject in Plugins
- Notification and Toast Plugin Example
- Publishing and Typing Vue Plugins