@medusajs/link-modules
Documentation | Website
Building blocks for digital commerce
Link Modules for Medusa: creates and manages the tables that store module links, the relationships between data models of different modules (for example, a product and its sales channels). It contains Medusa's built-in link definitions and also loads the links you define with defineLink. Medusa loads it automatically; apps don't install, register, or call this package directly, and instead manage links with the Link tool (ContainerRegistrationKeys.LINK) and retrieve linked data with Query.
At a glance
| Package | @medusajs/link-modules |
| Type | Infrastructure Module |
| Module key | Modules.LINK ("link_modules") |
| Registered by default | Yes (always loaded by the Medusa application) |
Installation
No installation needed. The package ships with @medusajs/medusa.
Usage
Define a link in your application, then run npx medusa db:migrate to create its table:
import BrandModule from "../modules/brand"
import ProductModule from "@medusajs/medusa/product"
import { defineLink } from "@medusajs/framework/utils"
export default defineLink(
ProductModule.linkable.product,
BrandModule.linkable.brand
)