Medusa plugin for Strapi as CMS
A plugin for implementing Strapi as CMS for Medusa
After completing this setup, you'll have:
This plugin requires:
Before starting, make sure you have:
⏱️ Estimated time: 15-30 minutes
🎯 Difficulty: Beginner to Intermediate
📋 You'll need: Medusa app, Strapi app, and basic terminal knowledge
1npm install @devx-commerce/strapi @strapi/client2# or3yarn add @devx-commerce/strapi @strapi/clientAdd the plugin to your :
1const { defineConfig } = require("@medusajs/medusa"); // or "@medusajs/framework/utils"2
3module.exports = defineConfig({4 // ... other config5 plugins: [6 // ... other plugins,7 {8 resolve: "@devx-commerce/strapi",9 options: {10 base_url: process.env.STRAPI_URL,11 api_key: process.env.STRAPI_API_KEY,12 },13 },14 ],15});npx create-strapi-app@latest my-strapi-cms1cd my-strapi-cms2npm run developYou have two options to create the content types:
This method is less error-prone and ensures exact field matching:
Required content types and their locations:
After adding the schema files, restart your Strapi server to apply the changes.
If you prefer to create content types manually through the Strapi admin interface:
After creating Product Variant, go back to the Product content type and add:
⚠️ Critical Notes for Manual Creation:
Required fields summary:
Add these variables to your Medusa file:
1STRAPI_URL=http://localhost:1337/api2STRAPI_API_KEY=your-api-token-hereAfter installation and setup, the plugin will automatically:
Once the plugin is set up, you can use Strapi's admin panel to add rich content to your products and use the Strapi API to fetch this content for your storefront.
Example of fetching product content from Medusa (with Strapi fields):
1// In your storefront using the Medusa JS SDK2import { sdk } from "@medusajs/js-sdk";3
4const medusa = sdk({5 baseUrl: MEDUSA_BASE_URL,6 publishableApiKey: STOREFRONT_PUBLISHABLE_API_KEY,7});8
9async function getProductContent(productId) {10 const { product } = await medusa.store.product.retrieve(productId, {11 fields: "cms_product.*",12 });13 return product;14}15
16// Alternative: Fetch product with Strapi content using query parameters17async function getProductWithStrapiContent(productId) {18 const { product } = await medusa.store.product.retrieve(productId, {19 fields: "+metadata.strapiId,+metadata.strapiSyncedAt",20 });21
22 // If you need to fetch additional Strapi content directly23 if (product.metadata?.strapiId) {24 // Use Strapi's API directly for rich content25 const strapiResponse = await fetch(26 `${STRAPI_BASE_URL}/products/${product.metadata.strapiId}`,27 {28 headers: {29 Authorization: `Bearer ${STRAPI_API_KEY}`,30 },31 },32 );33 const strapiContent = await strapiResponse.json();34 return { ...product, strapiContent: strapiContent.data };35 }36
37 return product;38}1. Content Type Validation Errors If you see errors about missing content types or fields, ensure you've:
2. HTTP 400/404 Errors The plugin now provides detailed error logging. Check your Medusa logs for:
3. Product Variant Naming Ensure your Strapi content type is named (with hyphen), not just .
4. Missing Fields The plugin expects these exact field names: