@kreatifklub/medusa-plugin-directus
v0.3.0
Published
A Medusa plugin for Directus integration
Maintainers
Readme
Enterprise-grade synchronization between Medusa v2 and Directus
CMS.
Developed by kreatifklub.com.
Overview
A production-ready integration layer that synchronizes:
- Products\
- Product Variants\
- Collections\
- Categories
This plugin bridges commerce logic (Medusa) with structured content management (Directus), enabling scalable headless architectures.
What You Get
✔ Automatic commerce-to-CMS synchronization
✔ Structured product data extension
✔ Clean separation of commerce and content
✔ Headless-ready architecture
✔ Enterprise-ready deployment model
Installation
pnpm add @kreatifklub/medusa-plugin-directusAdd to medusa-config.ts:
plugins: [
{
resolve: "@kreatifklub/medusa-plugin-directus",
options: {
url: process.env.DIRECTUS_URL,
token: process.env.DIRECTUS_TOKEN,
},
},
];System Architecture
flowchart LR
A[Medusa Backend] -->|Product / Variant / Collection / Category Events| B[Medusa Plugin]
B -->|Normalized Sync Data| C[Directus CMS]
C -->|Enriched Content + Media| D[Storefront / API Layer]Flow Explanation
- Commerce entities change in Medusa\
- Plugin subscribers capture events\
- Data is synchronized to Directus\
- Directus manages rich content & media\
- Storefront consumes unified commerce + CMS data
Requirements
- Node.js >= 22.22.0\
- Medusa 2.23.0\
- Directus >= 10.x
The Directus products collection must include a string status field that
accepts Medusa's product status values: draft, proposed, published, and
rejected. Medusa is the source of truth; product create, update, and manual
bulk synchronization copy the current status to Directus automatically.
Version 0.3.0 targets Medusa 2.23.0, with React/React DOM 19.3.1,
Medusa UI 4.3.0, and Vite 8.3.8 for the admin extension. Upgrade the host
Medusa application's matching dependencies before installing this release.
The admin extension must be rebuilt with pnpm build.
Dimensions and weight
Create these fields in both the Directus products and variants
collections:
| Field key | Recommended type | Interface | Nullable | Suggested precision / scale |
| --- | --- | --- | --- | --- |
| length | Decimal | Input | Yes | 15 / 4 |
| width | Decimal | Input | Yes | 15 / 4 |
| height | Decimal | Input | Yes | 15 / 4 |
| weight | Decimal | Input | Yes | 15 / 4 |
Leave defaults empty and disable Required. Integer, Big Integer and Float fields are also accepted, but Integer fields cannot preserve fractional measurements. Choose enough precision and scale for your source data.
Products copy their own Medusa dimensions and weight; variants copy their
own values independently. A missing variant measurement is not inherited
from its product. Zero stays zero, and null clears an existing CMS value.
The plugin copies numeric values without unit conversion: use the same
unit convention in Medusa and Directus, and keep units in display labels.
For example, a width of 350 stays 350; a weight of 15.5 stays 15.5.
Technical content fields such as spec_indoor_width_mm and
spec_outdoor_width_mm are not written by the plugin.
Startup validates that all eight measurement fields exist, use a numeric
type and allow NULL. The Directus token needs permission to inspect the
schema and read/create/update/delete the synchronized collections and
the products_categories junction. Each synchronized collection should
have a unique constraint on medusa_id.
Synchronization behavior and repair
Medusa is the source of truth. Product and variant create/update events
refresh the parent product and its variants. Collections, types and
categories are ensured before the product is linked; variants wait for
their parent. Manual sync processes collections, types, categories and
then products in ordered batches of 50. Repeating a sync updates existing
records by medusa_id and preserves fields managed only in Directus.
Unchanged category junction rows are retained.
The admin Sync Content Models action queues a background job. HTTP
202 means accepted, not completed. Watch the Medusa worker logs for
Directus synchronization completed successfully or an error. A failed
sync preserves successful CMS writes so a retry can reconcile them;
it does not delete existing enriched content as a rollback.
After deploying this fix, run Sync Content Models once to repair previously incorrect product and variant widths from the current Medusa values. Restart the backend/workers with the rebuilt plugin first.
The variants.inventory_quantity snapshot is calculated using Medusa's
total availability across stock locations, including reservations and
kit required quantities. It refreshes on product/variant or manual sync;
inventory-only and reservation-only events do not trigger this plugin.
Use Medusa for live, sales-channel-specific availability. The product
price field is a simple snapshot of the first price on the first-ranked
variant; it is not a currency/region-aware calculated selling price.
Delete events remove corresponding CMS records. Manual sync upserts current Medusa entities; it does not prune CMS records left behind by missed delete events. Configure Directus cascade rules for product variants and junction rows if deleting their parent record.
Validation
pnpm install --frozen-lockfile
pnpm test
pnpm typecheck
pnpm buildTests include the supplied width/weight examples, null/zero/fractional measurements, updates, pagination, relationship ordering, failure safety, schema checks and real Medusa workflow execution against a simulated Directus API. A deployed Medusa/Directus installation is still needed to verify permissions, schema and actual catalog data end to end.
License
Proprietary Software
© 2026 kreatifklub.com
All rights reserved.
