0Pricing
Vue Academy · Lesson

Publishing and Typing Vue Plugins

Package structure, TypeScript augmentation of ComponentCustomProperties, npm distribution.

Packaging a Plugin for npm

To share a Vue plugin you publish it as an npm package. The package must declare the right dependencies, ship a proper build, include TypeScript types, and be published correctly. This lesson covers each step.

peerDependencies for Vue

List Vue as a peerDependency, not a regular dependency. This ensures the host app provides Vue, avoiding two copies of Vue in one bundle (which breaks reactivity).

{
  "name": "vue-toast-kit",
  "peerDependencies": {
    "vue": "^3.4.0"
  },
  "devDependencies": {
    "vue": "^3.4.0"
  }
}

All lessons in this course

  1. Plugin Architecture and app.use()
  2. Global Properties and provide/inject in Plugins
  3. Notification and Toast Plugin Example
  4. Publishing and Typing Vue Plugins
← Back to Vue Academy