Alphabite's Medusa Storyblok Plugin
A powerful plugin that seamlessly syncs your Medusa products with Storyblok, enabling headless content management for your e-commerce product catalog.
💬 Need Help? Join our Discord community for support, questions, and discussions!
yarn add @alphabite/medusa-storyblok
In your or , add the plugin to the array:
import { AlphabiteStoryblokPluginOptions } from "@alphabite/medusa-storyblok";plugins: {[// ... other plugins{resolve: "@alphabite/medusa-storyblok",options: {accessToken: process.env.STORYBLOK_ACCESS_TOKEN,region: process.env.STORYBLOK_REGION, // "eu" or "us"personalAccessToken: process.env.STORYBLOK_PAT,spaceId: process.env.STORYBLOK_SPACE_ID,productsParentFolderId: process.env.STORYBLOK_PRODUCTS_PARENT_FOLDER_ID,productsParentFolderName: "products",deleteProductOnSbProductStoryDelete: false,webhookSecret: process.env.STORYBLOK_WEBHOOK_SECRET,imageOptimization: {quality: 80,width: 800,},} satisfies AlphabiteStoryblokPluginOptions,},];}
Add the following environment variables to your file:
# Storyblok Access Token (Content Delivery API - read-only)STORYBLOK_ACCESS_TOKEN=your_access_token# Storyblok Personal Access Token (Management API - write access)STORYBLOK_PAT=your_personal_access_token# Storyblok Space IDSTORYBLOK_SPACE_ID=your_space_id# Storyblok Region (eu or us)STORYBLOK_REGION=eu# Parent Folder ID where product stories will be createdSTORYBLOK_PRODUCTS_PARENT_FOLDER_ID=your_folder_id# Optional: Webhook secret for validating Storyblok webhooksSTORYBLOK_WEBHOOK_SECRET=your_webhook_secret
| Option | Type | Required | Default | Description |
|---|---|---|---|---|
| ✅ | - | Storyblok Access Token for Content Delivery API (read-only) | ||
| ✅ | - | Personal Access Token for Management API (write access) | ||
| ✅ | - | Your Storyblok Space ID | ||
| ✅ | - | Storyblok region of your space | ||
| ✅ | - | Folder ID where product stories will be created | ||
| ✅ | - | Folder name (usually "products") | ||
| ❌ | Version of stories to fetch | |||
| ❌ | - | Secret for validating Storyblok webhooks | ||
| ❌ | Delete Medusa product when Storyblok story is deleted | |||
| ❌ | - | Image optimization settings | ||
| ❌ | Target image width in pixels | |||
| ❌ | Image quality (1-100) | |||
| ❌ | - | Custom function to transform image URLs |
Access Token ():
Personal Access Token ():
Important: Make sure you are working with the correct , since the PAT grants write access to all of your Storyblok spaces.
Create a blok named with the following fields:
| Field Name | Type | Required | Description |
|---|---|---|---|
| Asset (Image) | ✅ | The image asset | |
| Boolean | ✅ | Whether this image is the thumbnail |
Create a blok named with the following fields:
| Field Name | Type | Required | Description |
|---|---|---|---|
| Text | ✅ | Variant title/name | |
| Text | ✅ | Medusa variant ID (for syncing) | |
| Blocks | ❌ | Gallery of images (accepts blok) |
Create a content type named with the following fields:
| Field Name | Type | Required | Description |
|---|---|---|---|
| Text | ✅ | Medusa product ID (for syncing) | |
| Text | ✅ | Product title/name | |
| Blocks | ❌ | Product image gallery (accepts blok) | |
| Blocks | ❌ | Product variants (accepts blok) |
Note: You can add any additional fields you need for your content management (description, SEO fields, custom attributes, etc.)
To enable bi-directional sync (Storyblok → Medusa), set up webhooks:
Note: The webhook secret is passed as a query parameter in the URL
The plugin provides a comprehensive admin UI for managing product synchronization with Storyblok.
On each product detail page in Medusa Admin, you'll see a Storyblok widget with:
When Product is Synced:
When Product is Not Synced:
Access via Medusa Admin sidebar → "Storyblok"
This dedicated page shows all your Medusa products with their sync status:
Features:
Status Indicators:
When a product is created in Medusa:
When a product is updated in Medusa:
Important: Once a product is synced to Storyblok, content management should happen in Storyblok. Updates will sync back to Medusa via webhooks.
When a product is deleted in Medusa:
When a variant is created in Medusa:
Important: When a new product is created, the plugin will automatically also create its default variant (or the multiple variants you have added during creation), and it will upload the images added to the product or variants during creation
When a variant is deleted in Medusa:
When a product story is published in Storyblok:
This enables your storefront to use Storyblok's CDN for images without additional fetches.
The plugin intelligently handles image uploads:
Each product gets its own asset folder:
Images served from Storyblok are automatically optimized:
Contributions are welcome! Please open an issue or submit a pull request.
MIT
For issues and questions:
Developed with ❤️ by Alphabite