Back to Medusa

Medusa

www/apps/book/public/homepage.md

2.14.210.7 KB
Original Source

Medusa

Medusa is a digital commerce platform with a built-in Framework for customization. When you install Medusa, you get a fully fledged commerce platform with all the features you need to get off the ground. However, unlike other platforms, Medusa is built with customization in mind. You don't need to build hacky workarounds that are difficult to maintain and scale. Your efforts go into building features that bring your business's vision to life.

For the complete documentation index, see llms.txt

Learn how to build Medusa projects. Explore our guides.

AI Assistant

Hello! I'm Bloom, your go-to ecommerce assistant. How can I help you?

Ask anything about Medusa...

FAQ

  • What is Medusa?
  • How can I build with Medusa and AI agents?
  • How can I extend the product data model?
  • How to create an admin user?
  • How do I deploy Medusa to production?

Recipes

  • How do I build a marketplace?
  • How do I build digital products?
  • How do I build subscription-based purchases?
  • What other recipes are available?

Customize Medusa Application

Admin Development

Storefront Development

Medusa Cloud

Agentic Development

Framework

A digital commerce platform with a built-in framework for customizations. Unlike other platforms, the Medusa Framework allows you to easily customize and extend the behavior of your commerce platform to always fit your business needs.

Create API Route

Expose custom features with REST API routes, then consume them from your client applications.

ts
export async function GET(
  req: MedusaRequest,
  res: MedusaResponse
) {
  const query = req.scope.resolve("query")

  const { data } = await query.graph({
    entity: "company",
    fields: ["id", "name"],
    filters: { name: "ACME" },
  })

  res.json({
    companies: data
  })
}

Build Workflows

Build flows as a series of steps, with retry mechanisms and tracking of each steps' status.

ts
const handleDeliveryWorkflow = createWorkflow(
  "handle-delivery",
  function (input: WorkflowInput) {
    notifyRestaurantStep(input.delivery_id)

    const order = createOrderStep(input.delivery_id)

    createFulfillmentStep(order)

    awaitDeliveryStep()

    return new WorkflowResponse("Delivery completed")
  }
)

Add a Data Model

Create data models that represent tables in the database using Medusa's Data Model Language.

ts
const DigitalProduct = model.define("digital_product",
  {
    id: model.id().primaryKey(),
    name: model.text(),
    medias: model.hasMany(() => DigitalProductMedia, {
      mappedBy: "digitalProduct"
    })
  })
  .cascades({
    delete: ["medias"]
  })
  • DML: Learn more about data models.

Build a Custom Module

Build custom modules with commerce or architectural features and use them in API routes or workflows.

ts
class DigitalProductService extends MedusaService({
  DigitalProduct,
}) {
  async authorizeLicense() {
    console.log("License authorized!")
  }
}

export async function POST(
  req: MedusaRequest,
  res: MedusaResponse
) {
  const moduleService = req.scope.resolve(
    "digitalProduct"
  )

  await moduleService.authorizeLicense()

  res.json({ success: true })
}
  • Modules: Learn more about modules.

Add custom properties to Medusa's data models using module links to build custom use cases.

ts
const DigitalProduct = model.define("digital_product", {
  id: model.id().primaryKey(),
  name: model.text(),
})

export default defineLink(
  DigitalProductModule.linkable.digitalProduct,
  ProductModule.linkable.productVariant
)

Subscribe to Events

Handle events emitted by the Medusa application to perform custom actions.

ts
async function orderPlaced({
  container,
}: SubscriberArgs) {
  const moduleService = container.resolve(
    Modules.NOTIFICATION
  )

  await moduleService.createNotifications({
    to: "[email protected]",
    channel: "email",
    template: "order-placed"
  })
}

export const config: SubscriberConfig = {
  event: "order.placed",
}
  • Subscribers: Learn more about events and subscribers.

Customize Admin

Inject widgets into predefined zones in the Medusa Admin, or add new pages.

tsx
const ProductBrandWidget = () => {
  const [brand, setBrand] = useState({
    name: "Acme"
  })

  return (
    <Container>
      <Heading level="h2">Brand</Heading>
      {brand && <span>Name: {brand.name}</span>}
    </Container>
  )
}

export const config = defineWidgetConfig({
  zone: "product.details.before",
})

Integrate Systems

Build workflows around multiple systems to add more powerful features to Medusa.

tsx
const syncBrandsFromSystemWorkflow = createWorkflow(
  "sync-brands-from-system",
  () => {
    const toCreate = retrieveBrandsFromSystemStep()

    const created = createBrandsInMedusaStep({
      brands: toCreate
    })

    return new WorkflowResponse({
      created,
    })
  }
)

Recipes

Medusa's framework supports any business use case. These recipes show you how to build a use case by customizing and extending existing data models and features, or creating new ones.

  • Marketplace: Build a marketplace with multiple vendors.
  • ERP: Integrate an ERP system to manage custom product prices, purchase rules, syncing orders, and more.
  • Bundled Products: Sell products as bundles with Admin and storefront customizations.
  • Subscriptions: Implement a subscription-based commerce store.
  • Restaurant-Delivery: Build a restaurant marketplace inspired by UberEats, with real-time delivery handling.
  • Digital Products: Sell digital products with custom fulfillment.
  • View all recipes: Browse all Medusa recipes.

Commerce Modules

Cart & Purchase

  • Cart: Add to cart, checkout, and totals.
  • Payment: Process any payment type.
  • Customer: Customer and group management.

Merchandising

  • Pricing: Configurable pricing engine.
  • Promotion: Discounts and promotions.
  • Product: Variants, categories, and bulk edits.

Fulfillment

Regions & Channels

User Access

Newsletter

Updates delivered monthly. Get the latest product news and behind the scenes updates. Unsubscribe at any time.

Feedback

Was this page helpful?