import { Table } from "docs-ui" export const metadata = { title: `${pageNumber} Publish a Plugin`, } # {metadata.title} In this chapter, you’ll learn how to publish a plugin. After you publish your plugin, it will also be available in [Medusa’s Plugins Library](https://medusajs.com/plugins/). ## package.json Checklist Update the following meta information in your plugin’s package.json: - `name`: The name of your plugin. By convention, all plugin names start with `medusa` followed by a descriptive name of what the plugin does. For example, `medusa-payment-stripe`. - `description`: A short description of what the plugin does. - `author`: Your name or your company's name. - `repository`: Details about the repository that holds the source code of the plugin. It's an object that holds the following properties: - `type`: Should be `git`. - `url`: The URL to the repository (for example, the GitHub repository holding the code of your plugin). ### Package Keywords It's required for all Medusa plugins to use the keywords `medusa-plugin`. The following table mentions other keywords that you can use based on your plugin's functionalities. Keyword Description `medusa-plugin-analytics` Analytics functionalities or integrations. `medusa-plugin-cms` CMS functionalities or integrations. `medusa-plugin-notification` Notification functionalities or integrations. `medusa-plugin-payment` Payment functionalities or integrations. `medusa-plugin-search` Search functionalities or integrations. `medusa-plugin-shipping` Shipping functionalities or integrations. `medusa-plugin-storage` File service or storage integrations. `medusa-plugin-source` Migrate or import data into Medusa from another platform. `medusa-plugin-admin` Plugins that include only admin customizations. `medusa-plugin-other` Any other type of plugin.
--- ## Add NPMIgnore File Not all files in your Medusa application are relevant to the published plugin. Add the following `.npmignore` file in the root of the plugin's directory to ignore unnecessary files from the published plugin: ```bash title=".npmignore" # directories .cache .DS_store .github .vscode .yarn build data node_modules src uploads # files .babelrc .env* .gitignore .eslintrc .prettierrc .yarnrc.yml index.js medusa-config.js yarn.lock ``` --- ## Publish Plugin To publish a plugin, you need an [NPM account](https://www.npmjs.com/signup). To publish the plugin: 1. Run the `prepare` command: ```bash npm2yarn npm run prepare ``` 2. Publish the NPM package: ```bash npm publish ``` If you haven’t logged in before with NPM, you’ll be asked to log in first. Your package is then published to NPM. --- ## Install Plugin in Medusa Applications To install your published plugin in a Medusa application, run the following command: ```bash npm2yarn npm install medusa-plugin-custom ``` Where `medusa-plugin-custom` is your plugin’s name. Then, add the plugin to `medusa-config.js`: ```js title="medusa-config.js" const plugins = [ // ... { resolve: `medusa-plugin-custom`, options: { // plugin options... }, }, ] ``` --- ## Update Plugin To publish plugin changes, first, run the following command in the plugin’s directory to change the NPM version: ```bash npm version ``` Where `` indicates the type of version update you’re publishing. For example, `major`. You can see the [full list of types in NPM’s documentation](https://docs.npmjs.com/cli/v8/commands/npm-version). Then, publish the new update: ```bash npm publish ``` You can then update the plugin in the Medusa applications that use it.