Plugins
In this chapter, you'll learn what a plugin is in MedusaGo.
What is a Plugin?#
A plugin is a Go package of reusable MedusaGo customizations that you can use in any MedusaGo application. The supported customizations are Modules, API Routes, Workflows, Workflow Hooks, Links, Subscribers, and Scheduled Jobs.
Plugins allow you to reuse your customizations across multiple projects or share them with the community. Since a plugin is a Go package, you publish it as a Go module, and an application adds it to its dependencies like any other Go package.
A plugin registers a definition with the framework, which describes the customizations it contains. An application then enables the plugin by importing its package and adding it to the Plugins of its configuration, in medusa-config.go. MedusaGo adds the plugin's modules, links, API routes, middlewares, subscribers, and hooks to the application.
Plugin vs Module#
A module is an isolated package related to a single domain or functionality, such as product reviews or integrating a Content Management System. A module can't access any resources in the MedusaGo application that are outside its codebase.
A plugin, on the other hand, can contain multiple MedusaGo customizations, including modules. Your plugin can define a module, then build flows around it.
For example, in a plugin, you can define a module that integrates a third-party service, then add a workflow that uses the module when a certain event occurs to sync data to that service.
- You want to reuse your MedusaGo customizations across multiple projects.
- You want to share your MedusaGo customizations with the community.
- You want to build a custom feature related to a single domain or integrate a third-party service. Instead, use a module. You can wrap that module in a plugin if it's used in other customizations, such as if it has a module link or it's used in a workflow.
How to Create a Plugin?#
The next chapter explains how you can create, test, and publish a plugin.