on GitHub" data-tooltip-id=":R1blcldb:">v2.5.1·Edited Oct 3·
This recipe provides the general steps to implement a marketplace in your Medusa application.
A marketplace is an online commerce store that allows different vendors to sell their products within the same commerce system. Customers can purchase products from any of these vendors, and vendors can manage their orders separately.
In Medusa, you can create a Marketplace Module that implements custom data models, such as vendors or sellers, and link those data models to existing ones such as products and orders. You also expose custom features using API routes, and implement complex flows using workflows.
In a marketplace, a business or a vendor has a user, and they can use that user to authenticate and manage the vendor's data.
You can create a marketplace module that implements data models for vendors, their admins, anything else that fits your use case.
Since a vendor has products, orders, and other models based on your use case, define module links between your module's data models and the commerce module's data models.
For example, if you defined a vendor data model in a marketplace module, you can define a module link between the vendor and the Product Module's product data model.
If your marketplace module implements admins for sellers or vendors, you can create an actor type for it.
Then, you guard custom API routes to only allow authenticated vendor admins.
If you provide vendor or sellers with custom features, or a different way of managing products and orders, create API routes only accessible by vendors exposing your custom features.
If your use case allows a customer's orders to have items from different vendors, you can override the Complete Cart API route to change how the order should be created.
If your flow requires different steps, such as creating a parent order then creating a child order, create a workflow and execute it from the API route.
Medusa provides a Next.js Starter storefront that you can customize for your use case.
You can also create a custom storefront from scratch.
The Medusa Admin is extendable, allowing you to add widgets to existing pages or create new pages.
If your use case requires bigger customizations to the admin, such as showing different products and orders based on the logged-in vendor, use the admin API routes to build a custom admin.