Blog

November 4, 2025·Product

Implement Product Rentals in Medusa

Shahed Nasser

Shahed  avatar

Shahed Nasser

Learn how to support product rentals in your Medusa commerce store, with full admin and storefront customizations.

Image modal

Product rentals allow customers to rent products for a specified period. In this tutorial, you’ll learn how to enable product rentals in your Medusa store. This feature is particularly useful for businesses that offer rentals for items such as vehicles, gadgets, and formal wear.

Medusa is a digital commerce platform with a built-in framework for customization. It is an ideal solution for implementing custom commerce applications and unique product cases like product rentals. Medusa allows this by letting developers create custom data models and business logic on top of existing features, as well as to inject custom logic into existing commerce workflows.

Implement Product Rentals in Medusa
Follow this step-by-step guide

Get Started

Create Product Rental Data Models

To manage and store rental-related data, you’ll need to create a Rental Module that defines the data models for rental configurations and customer rentals. The module’s service should handle data management operations for these models.

You can then link your custom data models with Medusa’s existing ones (as defined in Commerce Modules) to extend core features. For example, you can associate a rental configuration with a product, and a rental record with an order.

Image modal

Manage Product Rental Configurations

You can extend the Medusa Admin dashboard to add a rental section for products. From there, admin users can specify whether a product is available for rent and configure options such as minimum and maximum rental durations.

Validate Rental Options

In the Next.js Starter Storefront, you can customize the product page to allow customers to select a rental period.

When a customer chooses a rental period, you can validate in the backend whether that rental period is available for the item. This validation also occurs when a rental product is added to the cart and when the customer places an order.

Image modal

Handle Order Events

Admin users can perform operations on orders, such as canceling them or creating fulfillments for rented items.

You can inject custom validation logic into the workflow that handles order cancellations, preventing admin users from canceling orders when rentals have already been returned.

import { cancelOrderWorkflow } from "@medusajs/medusa/core-flows"
import { MedusaError, ContainerRegistrationKeys } from "@medusajs/framework/utils"
cancelOrderWorkflow.hooks.orderCanceled(
async ({ order }, { container }) => {
const query = container.resolve(ContainerRegistrationKeys.QUERY)
const { data: rentals } = await query.graph({
entity: "rental",
fields: ["id", "status", "variant_id"],
filters: {
order_id: order.id,
},
})
const nonCancelableRentals = rentals.filter(
(rental: any) => !["pending", "active", "cancelled"].includes(rental.status)
)
if (nonCancelableRentals.length > 0) {

Then, you can create a subscriber that automatically and asynchronously cancels rentals when an order is canceled.

export default async function orderCanceledHandler({
event: { data },
container,
}) {
const query = container.resolve("query")
const { data: rentals } = await query.graph({
entity: "rental",
fields: ["id", "status"],
filters: {
order_id: data.id,
status: {
$ne: "cancelled",
}
},
})
for (const rental of rentals) {
await updateRentalWorkflow(container).run({
input: {

Tutorial: Implement Product Rentals in Medusa

By following this tutorial in our documentation, you’ll learn how to:

  • Create a Rental Module with data models for rentals and rental configurations.
  • Enable admin users to manage rental configurations in the Medusa Admin.
  • Allow customers to select rental periods in the storefront.
  • Let admin users manage rentals within orders.
  • Handle order events, such as cancellations.

The tutorial also includes guidance for specific use cases, such as removing shipping requirements or managing inventory.

Share this post

Ready to build your custom commerce setup?