npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@kreatifklub/medusa-plugin-directus

v0.3.0

Published

A Medusa plugin for Directus integration

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-directus

Add 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

  1. Commerce entities change in Medusa\
  2. Plugin subscribers capture events\
  3. Data is synchronized to Directus\
  4. Directus manages rich content & media\
  5. 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 build

Tests 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.