Overview
Strapi
Manage product content and assets with auto sync
Medusa Plugin - Strapi
Documentation | Website
A plugin for implementing Strapi as CMS for Medusa
Features
- ๐ Seamless integration between Medusa and Strapi
- ๐ Flexible content management for your e-commerce store
- ๐ผ๏ธ Rich media management for product images and assets
- ๐ Extend product information with custom fields and content
- ๐ฑ Headless architecture for omnichannel commerce
- ๐ Automatic synchronization between Medusa and Strapi
Requirements
This plugin requires:
Installation
- Install the plugin:
123npm install @devx-commerce/strapi @strapi/client# oryarn add @devx-commerce/strapi @strapi/client
- Add the plugin to your Copy to clipboard
medusa-config.js
:
123456789101112131415const { defineConfig } = require("@medusajs/medusa"); // or "@medusajs/framework/utils"module.exports = defineConfig({// ... other configplugins: [// ... other plugins,{resolve: "@devx-commerce/strapi",options: {base_url: process.env.STRAPI_URL,api_key: process.env.STRAPI_API_KEY,},},],});
Setup
Setting up Strapi
- Install Strapi if you haven't already:
1npx create-strapi-app@latest my-strapi-cms
- Start your Strapi server:
12cd my-strapi-cmsnpm run develop
- Create an API token in Strapi:
- Go to Settings > API Tokens
- Create a new full access token
- Copy the token to use in your Medusa configuration
- Create Product and Variant collections in Strapi:
- In your Strapi admin panel, go to Content-Type Builder
- Create a new collection type called Product
- Add a title field (Text type)
- Add a systemId field (Text type, Unique)
- Create another collection type called Variant
- Add a title field (Text type)
- Add a systemId field (Text type, Unique)
- Save and publish your new collection types
- Configure environment variables for your Medusa backend:
12STRAPI_URL=http://localhost:1337STRAPI_API_KEY=your-api-token-here
Synchronizing data
After installation and setup, the plugin will automatically:
- Create and update products, collections & categories in Strapi when they are modified in Medusa
- Sync product, collection & category metadata between Medusa and Strapi
- Allow extending product data with Strapi's content types
Usage
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):
12345678910111213// In your storefrontasync function getProductContent(productId) {const response = await fetch(`${MEDUSA_BASE_URL}/store/products/${productId}?fields=cms_product.*`,{headers: {"x-publishable-api-key": STOREFRONT_PUBLISHABLE_API_KEY,},},);const data = await response.json();return data.data[0];}