Marketplace Recipe

This recipe provides the general steps to implement a marketplace in your Medusa application.

Example Guides#

Overview#

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.


Create Custom Module with Data Models#

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.

Create a Module
Learn how to create a module.
Create Data Models
Create data models in the module.

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.

Define a Module Link
Learn how to define a module link.

Allow Vendor Admins to Authenticate#

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.

Create an Actor Type
Learn how to create an actor type and authenticate it.

Create Vendor API Routes#

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.

Create API Routes
Learn how to create an API Route in Medusa.
Protect Routes
Learn how to guard routes to allow authenticated users only.

Split Orders Based on Vendors#

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.

Create a Workflow
Learn how to create a workflow in Medusa.

Customize Storefront#

Medusa provides a Next.js Starter storefront that you can customize for your use case.

You can also create a custom storefront from scratch.

Next.js Storefront
Learn how to install and customize the Next.js storefront.
Storefront Development
Find useful guides for creating a custom storefront.

Customize Admin#

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.

Was this page helpful?
Edit this page