BCMS
Link BCMS content to Medusa products
@thebcms/medusa-plugin
Link BCMS entries to products by slot (e.g. Copy to clipboardrich_description, Copy to clipboardrecommended_blogs), with per-slot template allowlists in admin, and serve resolved content through store API routes.
Requirements
- Medusa Copy to clipboard
^2.19 - Node Copy to clipboard
>=20.19.0 - BCMS API key
Install
1npm install @thebcms/medusa-plugin
Register in Copy to clipboardmedusa-config.ts:
1234567891011121314import { defineConfig, loadEnv } from "@medusajs/framework/utils"loadEnv(process.env.NODE_ENV || "development", process.cwd())module.exports = defineConfig({plugins: [{resolve: "@thebcms/medusa-plugin",options: {apiKey: process.env.BCMS_API_KEY,},},],})
Run migrations:
1npx medusa db:migrate
Options
Option Type Default Description Copy to clipboardapiKey Copy to clipboardstring — BCMS API key (required for BCMS calls). Copy to clipboardcmsOrigin Copy to clipboardstring BCMS default Your BCMS instance URL. Copy to clipboarduseMemCache Copy to clipboardboolean Copy to clipboardtrue Client cache. Set Copy to clipboardfalse for live preview. Copy to clipboarddebug Copy to clipboardboolean Copy to clipboardfalse Verbose BCMS client logs.
Admin
- Settings → BCMS — define slots and which templates each slot may use. No slots exist until you add them. An empty template list on a slot means all templates are allowed.
- Products → BCMS content — link one or more BCMS entries per slot.
Store API
Auth: Medusa publishable API key (via JS SDK).
Method Path Description GET Copy to clipboard/store/bcms/products/:id Product + resolved entries in Copy to clipboardbcms.slots. GET Copy to clipboard/store/bcms/entries/:id?template= Single entry by id. GET Copy to clipboard/store/bcms/pages/:slug?template= Single entry by slug.
Standalone entry/page routes only allow templates configured on at least one slot (or all templates if any slot has an empty allowlist). Linked entries on the product route are always returned.
12345678910111213import Medusa from "@medusajs/js-sdk"const sdk = new Medusa({baseUrl: process.env.NEXT_PUBLIC_MEDUSA_BACKEND_URL!,publishableKey: process.env.NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY!,})const { product, bcms } = await sdk.client.fetch(`/store/bcms/products/${productId}`)const richText = bcms.slots["rich_description"]?.[0]?.entryconst blogs = bcms.slots["recommended_blogs"] ?? []
Query linked entries in custom routes:
12345const { data } = await query.graph({entity: "product",fields: ["id", "title", "bcms_links.*"],filters: { id: productId },})
Types:
12345import type {BcmsModuleOptions,BcmsLinkPayload,BcmsSettingPayload,} from "@thebcms/medusa-plugin/modules/bcms"
Development
123npm installnpx medusa plugin:publish # local yalc registrynpx medusa plugin:develop # watch + rebuild
In a Medusa app:
12npx medusa plugin:add @thebcms/medusa-pluginnpx medusa db:migrate
License
MIT
