Plugin Architecture
Medusa v2 Plugin System
Medusa v2 plugins are Node packages that export modules, API routes, workflows, and subscribers. Plugins are registered in medusa-config.ts under the plugins array.
Vespertene Plugin Strategy
The invite system and download delivery are reusable across future Vespertene client stores. Extract them as plugins after their respective sprints are stable, even while they live in the monorepo.
| Plugin | Package name | Extracts when |
|---|---|---|
| Invite system | @vespertene/medusa-plugin-invites | After Sprint 5 is stable |
| Digital downloads | @vespertene/medusa-plugin-downloads | After Sprint 4 is stable |
| Promo codes (extended) | @vespertene/medusa-plugin-promos | Phase 2 |
Workflow Hooks for Extensibility
Every custom workflow should expose hooks at meaningful points so future plugins can inject logic without forking the workflow.
// expose a hook after download links are created
export const createDownloadLinksWorkflow = createWorkflow(
"create-download-links",
(input) => {
const links = createLinksStep(input)
createDownloadLinksWorkflow.hooks.linksCreated({ links })
return new WorkflowResponse(links)
}
)