A step-by-step guide to porting an existing Mercur 1.x project to 2.x, the latest release.Mercur 2.0 replaces the monolithic plugin architecture (
@mercurjs/b2c-core) with a block-based model (@mercurjs/core plus registry blocks). This guide is about porting your existing 1.x code to a 2.x project. For setting up a fresh project instead, see Installation, which already uses the latest names.
Before you start
Most users do not need to migrate much. Core and the official registry blocks cover most standard marketplace functionality, and the admin and vendor panels ship 34+ pages out of the box. You only need to port your own custom modules, workflows, routes, and any domain-specific dashboard pages that core does not already provide. Here is what replaced what between 1.x and 2.x:
The MedusaJS v2 foundation (modules, workflows, links, subscribers, API routes), the data model patterns (MikroORM, service layer), and your environment variables (
DATABASE_URL, CORS, secrets) are all unchanged.
Using a version older than 1.4.0? Your admin panel code lives inside the backend repo, not a separate app. When scanning for custom admin code to port, look there instead of
apps/admin/. Everything else in this guide applies identically.Step 1: Start from a fresh 2.x project
Set up a working 2.x project first (see Installation), then port your 1.x code into it. Do not upgrade the old project in place.Step 2: Map your packages
Replace 1.x packages with their 2.x equivalents:
Several features that were separate packages in 1.x are now installed as registry blocks. Install these instead of porting their 1.x package code:
reviews, requests, wishlist, team-management, algolia, vendor-notifications, vendor-chat, product-import-export.
The seller, payout, and commission modules are built into core, so there is nothing to port for those.
Step 3: Map your directories
Step 4: Port custom backend code
Copy each kind of custom code intopackages/api/src/ and update imports from @mercurjs/b2c-core to @mercurjs/core.
-
Modules: copy to
packages/api/src/modules/and register them inmedusa-config.ts. -
Workflows: copy to
packages/api/src/workflows/<entity>/. Do not create barrelindex.tsfiles, as they conflict with block installation. -
API routes: copy to
packages/api/src/api/. Type both generics so codegen can read them, then runbunx @mercurjs/cli@latest codegen. -
Links and subscribers: copy to
packages/api/src/links/andsrc/subscribers/. Do not duplicate links that core already provides (seller to product, seller to order, and so on). -
Custom providers: copy to
packages/api/src/providers/, then make two required changes:
Step 5: Port custom dashboard code
Only needed if you have custom pages that core admin and vendor do not cover. Update imports and move pages fromsrc/routes/ to src/pages/ with a export default.
Step 6: Rename Order Set to Order Group
The 1.xOrderSet entity is renamed to OrderGroup in 2.x. This is a breaking change that affects database tables, API endpoints, workflow names, event names, and types.
Two fields were removed from the group:
payment_collection_id: payment collections are now linked at the individual order level. Query the linked orders to get the payment collection.sales_channel_id: the sales channel is stored on each individual order.
seller_count (distinct sellers across linked orders) and total (sum of order totals).
To migrate:
- Update imports:
OrderSetDTOtoOrderGroupDTO(from@mercurjs/types). - Update API calls:
/order-setsto/order-groups. - Update workflow references:
getFormattedOrderSetListWorkflowtogetOrderGroupsListWorkflow. - Update event listeners:
OrderSetWorkflowEventstoOrderGroupWorkflowEvents. - If you read
payment_collection_idorsales_channel_idfrom the order set, read them from the individual orders instead (via theorder_group_orderlink).
Step 7: Upgrade to the latest release
After 2.0, the Medusa plugin was renamed from@mercurjs/core-plugin to @mercurjs/core. The package contents are the same. If you started from a current 2.x install, you are already on the new name and can skip this step.
Swap the dependency
Replace the name in config and source
Inpackages/api/medusa-config.ts and anywhere under packages/api/src/**, replace every occurrence of @mercurjs/core-plugin with @mercurjs/core. A repo-wide find-and-replace is safe. This applies to resolve values and imports alike:
@mercurjs/core-plugin/modules/<module>, /workflows, /links, and /api. Installed registry blocks live under packages/api/src/, so the same find-and-replace covers them.
Reinstall, migrate, and rebuild
@mercurjs/core-plugin, you missed an import: re-run the find-and-replace.
Known limitations
These areas do not currently have full 1.x parity and require manual migration for now:TaxCode: no 2.x equivalent today. Port the old logic manually if your project depends on it.SecondaryCategory: no 2.x equivalent, and none is planned. Port the old logic manually if your project depends on it.
Next steps
Installation
Set up a fresh 2.x project to port your code into.
Order Group
The full 2.x data model that replaced Order Set.