www/apps/book/public/homepage.md
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.
Hello! I'm Bloom, your go-to ecommerce assistant. How can I help you?
Ask anything about Medusa...
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.
Expose custom features with REST API routes, then consume them from your client applications.
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 flows as a series of steps, with retry mechanisms and tracking of each steps' status.
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")
}
)
Create data models that represent tables in the database using Medusa's Data Model Language.
const DigitalProduct = model.define("digital_product",
{
id: model.id().primaryKey(),
name: model.text(),
medias: model.hasMany(() => DigitalProductMedia, {
mappedBy: "digitalProduct"
})
})
.cascades({
delete: ["medias"]
})
Build custom modules with commerce or architectural features and use them in API routes or workflows.
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 })
}
Add custom properties to Medusa's data models using module links to build custom use cases.
const DigitalProduct = model.define("digital_product", {
id: model.id().primaryKey(),
name: model.text(),
})
export default defineLink(
DigitalProductModule.linkable.digitalProduct,
ProductModule.linkable.productVariant
)
Handle events emitted by the Medusa application to perform custom actions.
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",
}
Inject widgets into predefined zones in the Medusa Admin, or add new pages.
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",
})
Build workflows around multiple systems to add more powerful features to Medusa.
const syncBrandsFromSystemWorkflow = createWorkflow(
"sync-brands-from-system",
() => {
const toCreate = retrieveBrandsFromSystemStep()
const created = createBrandsInMedusaStep({
brands: toCreate
})
return new WorkflowResponse({
created,
})
}
)
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.
Updates delivered monthly. Get the latest product news and behind the scenes updates. Unsubscribe at any time.
Was this page helpful?