Plugin Architecture and app.use()
Plugin object { install(app, options) }, accessing app.component, app.directive, app.provide.
What Is a Vue Plugin
A Vue plugin is reusable code that adds app-level functionality — global components, directives, injected services, or config. Examples: Vue Router, Pinia, i18n libraries.
You register a plugin once with app.use(plugin).
The install Contract
A plugin is either an object with an install(app, options) method, or a function used directly as install. Vue calls it with the app instance and any options you pass.
const myPlugin = {
install(app, options) {
// register things on the app here
console.log('installing with', options)
}
}
export default myPluginAll 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