|
1
|
# Medusa |
|
2
|
|
|
3
|
> 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. |
|
4
|
|
|
5
|
> For the complete documentation index, see [llms.txt](/llms.txt) |
|
6
|
|
|
7
|
Learn how to build Medusa projects. Explore our guides. |
|
8
|
|
|
9
|
## AI Assistant |
|
10
|
|
|
11
|
Hello! I'm Bloom, your go-to ecommerce assistant. How can I help you? |
|
12
|
|
|
13
|
Ask anything about Medusa... |
|
14
|
|
|
15
|
### FAQ |
|
16
|
|
|
17
|
- What is Medusa? |
|
18
|
- How can I build with Medusa and AI agents? |
|
19
|
- How can I extend the product data model? |
|
20
|
- How to create an admin user? |
|
21
|
- How do I deploy Medusa to production? |
|
22
|
|
|
23
|
### Recipes |
|
24
|
|
|
25
|
- How do I build a marketplace? |
|
26
|
- How do I build digital products? |
|
27
|
- How do I build subscription-based purchases? |
|
28
|
- What other recipes are available? |
|
29
|
|
|
30
|
## Customize Medusa Application |
|
31
|
|
|
32
|
- [Install Medusa](https://docs.medusajs.com/learn/installation): Install a digital commerce application with Medusa. |
|
33
|
- [Deploy to Cloud](https://docs.medusajs.com/cloud/sign-up): Deploy Medusa to Medusa Cloud. |
|
34
|
- [Browse integrations](https://docs.medusajs.com/resources/integrations): Integrate third-party services with Medusa. |
|
35
|
|
|
36
|
## Admin Development |
|
37
|
|
|
38
|
- [Build a UI widget](https://docs.medusajs.com/learn/fundamentals/admin/widgets): Create custom widgets for the admin dashboard. |
|
39
|
- [Add a UI route](https://docs.medusajs.com/learn/fundamentals/admin/ui-routes): Create custom UI routes in the admin dashboard. |
|
40
|
- [Browse the UI library](https://docs.medusajs.com/ui): A React library to build applications using Medusa's design system. |
|
41
|
|
|
42
|
## Storefront Development |
|
43
|
|
|
44
|
- [Explore storefront starter](https://docs.medusajs.com/resources/nextjs-starter): Next.js storefront starter template. |
|
45
|
- [Build custom storefront](https://docs.medusajs.com/resources/storefront-development): Build storefronts with Medusa. |
|
46
|
- [Use agent skills](https://docs.medusajs.com/learn/introduction/build-with-llms-ai#ecommerce-storefront-best-practices): Best practices for storefront development with AI agents. |
|
47
|
|
|
48
|
## Medusa Cloud |
|
49
|
|
|
50
|
- [Deploy from GitHub](https://docs.medusajs.com/cloud/projects): Deploy Medusa projects from GitHub. |
|
51
|
- [Preview environments](https://docs.medusajs.com/cloud/environments/preview): Use preview environments in Medusa Cloud. |
|
52
|
- [Medusa Emails](https://docs.medusajs.com/cloud/emails): Manage emails in Medusa Cloud. |
|
53
|
|
|
54
|
## Agentic Development |
|
55
|
|
|
56
|
- [Build with Bloom](https://bloom.chat): Build Medusa projects with Bloom, an AI coding assistant. |
|
57
|
- [Agent Skills](https://docs.medusajs.com/learn/introduction/build-with-llms-ai): Learn how to build with AI assistants and LLMs. |
|
58
|
- [Medusa Docs MCP](https://docs.medusajs.com/learn/introduction/build-with-llms-ai#mcp-remote-server): Use the Medusa Docs MCP server. |
|
59
|
|
|
60
|
## Framework |
|
61
|
|
|
62
|
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. |
|
63
|
|
|
64
|
- [Learn more about the Framework](https://docs.medusajs.com/learn/fundamentals/framework): Overview of Medusa's Framework and concepts. |
|
65
|
|
|
66
|
### Create API Route |
|
67
|
|
|
68
|
Expose custom features with REST API routes, then consume them from your client applications. |
|
69
|
|
|
70
|
```ts |
|
71
|
export async function GET( |
|
72
|
req: MedusaRequest, |
|
73
|
res: MedusaResponse |
|
74
|
) { |
|
75
|
const query = req.scope.resolve("query") |
|
76
|
|
|
77
|
const { data } = await query.graph({ |
|
78
|
entity: "company", |
|
79
|
fields: ["id", "name"], |
|
80
|
filters: { name: "ACME" }, |
|
81
|
}) |
|
82
|
|
|
83
|
res.json({ |
|
84
|
companies: data |
|
85
|
}) |
|
86
|
} |
|
87
|
``` |
|
88
|
|
|
89
|
- [API Routes](https://docs.medusajs.com/learn/fundamentals/api-routes): Learn more about API routes. |
|
90
|
|
|
91
|
### Build Workflows |
|
92
|
|
|
93
|
Build flows as a series of steps, with retry mechanisms and tracking of each steps' status. |
|
94
|
|
|
95
|
```ts |
|
96
|
const handleDeliveryWorkflow = createWorkflow( |
|
97
|
"handle-delivery", |
|
98
|
function (input: WorkflowInput) { |
|
99
|
notifyRestaurantStep(input.delivery_id) |
|
100
|
|
|
101
|
const order = createOrderStep(input.delivery_id) |
|
102
|
|
|
103
|
createFulfillmentStep(order) |
|
104
|
|
|
105
|
awaitDeliveryStep() |
|
106
|
|
|
107
|
return new WorkflowResponse("Delivery completed") |
|
108
|
} |
|
109
|
) |
|
110
|
``` |
|
111
|
|
|
112
|
- [Workflows](https://docs.medusajs.com/learn/fundamentals/workflows): Learn more about workflows. |
|
113
|
|
|
114
|
### Add a Data Model |
|
115
|
|
|
116
|
Create data models that represent tables in the database using Medusa's Data Model Language. |
|
117
|
|
|
118
|
```ts |
|
119
|
const DigitalProduct = model.define("digital_product", |
|
120
|
{ |
|
121
|
id: model.id().primaryKey(), |
|
122
|
name: model.text(), |
|
123
|
medias: model.hasMany(() => DigitalProductMedia, { |
|
124
|
mappedBy: "digitalProduct" |
|
125
|
}) |
|
126
|
}) |
|
127
|
.cascades({ |
|
128
|
delete: ["medias"] |
|
129
|
}) |
|
130
|
``` |
|
131
|
|
|
132
|
- [DML](https://docs.medusajs.com/learn/fundamentals/modules#1-create-data-model): Learn more about data models. |
|
133
|
|
|
134
|
### Build a Custom Module |
|
135
|
|
|
136
|
Build custom modules with commerce or architectural features and use them in API routes or workflows. |
|
137
|
|
|
138
|
```ts |
|
139
|
class DigitalProductService extends MedusaService({ |
|
140
|
DigitalProduct, |
|
141
|
}) { |
|
142
|
async authorizeLicense() { |
|
143
|
console.log("License authorized!") |
|
144
|
} |
|
145
|
} |
|
146
|
|
|
147
|
export async function POST( |
|
148
|
req: MedusaRequest, |
|
149
|
res: MedusaResponse |
|
150
|
) { |
|
151
|
const moduleService = req.scope.resolve( |
|
152
|
"digitalProduct" |
|
153
|
) |
|
154
|
|
|
155
|
await moduleService.authorizeLicense() |
|
156
|
|
|
157
|
res.json({ success: true }) |
|
158
|
} |
|
159
|
``` |
|
160
|
|
|
161
|
- [Modules](https://docs.medusajs.com/learn/fundamentals/modules): Learn more about modules. |
|
162
|
|
|
163
|
### Link Data Models |
|
164
|
|
|
165
|
Add custom properties to Medusa's data models using module links to build custom use cases. |
|
166
|
|
|
167
|
```ts |
|
168
|
const DigitalProduct = model.define("digital_product", { |
|
169
|
id: model.id().primaryKey(), |
|
170
|
name: model.text(), |
|
171
|
}) |
|
172
|
|
|
173
|
export default defineLink( |
|
174
|
DigitalProductModule.linkable.digitalProduct, |
|
175
|
ProductModule.linkable.productVariant |
|
176
|
) |
|
177
|
``` |
|
178
|
|
|
179
|
- [Module Links](https://docs.medusajs.com/learn/fundamentals/module-links): Learn more about module links. |
|
180
|
|
|
181
|
### Subscribe to Events |
|
182
|
|
|
183
|
Handle events emitted by the Medusa application to perform custom actions. |
|
184
|
|
|
185
|
```ts |
|
186
|
async function orderPlaced({ |
|
187
|
container, |
|
188
|
}: SubscriberArgs) { |
|
189
|
const moduleService = container.resolve( |
|
190
|
Modules.NOTIFICATION |
|
191
|
) |
|
192
|
|
|
193
|
await moduleService.createNotifications({ |
|
194
|
to: "customer@gmail.com", |
|
195
|
channel: "email", |
|
196
|
template: "order-placed" |
|
197
|
}) |
|
198
|
} |
|
199
|
|
|
200
|
export const config: SubscriberConfig = { |
|
201
|
event: "order.placed", |
|
202
|
} |
|
203
|
``` |
|
204
|
|
|
205
|
- [Subscribers](https://docs.medusajs.com/learn/fundamentals/events-and-subscribers): Learn more about events and subscribers. |
|
206
|
|
|
207
|
### Customize Admin |
|
208
|
|
|
209
|
Inject widgets into predefined zones in the Medusa Admin, or add new pages. |
|
210
|
|
|
211
|
```tsx |
|
212
|
const ProductBrandWidget = () => { |
|
213
|
const [brand, setBrand] = useState({ |
|
214
|
name: "Acme" |
|
215
|
}) |
|
216
|
|
|
217
|
return ( |
|
218
|
<Container> |
|
219
|
<Heading level="h2">Brand</Heading> |
|
220
|
{brand && <span>Name: {brand.name}</span>} |
|
221
|
</Container> |
|
222
|
) |
|
223
|
} |
|
224
|
|
|
225
|
export const config = defineWidgetConfig({ |
|
226
|
zone: "product.details.before", |
|
227
|
}) |
|
228
|
``` |
|
229
|
|
|
230
|
- [Admin Widgets](https://docs.medusajs.com/learn/fundamentals/admin/widgets): Learn more about admin widgets. |
|
231
|
|
|
232
|
### Integrate Systems |
|
233
|
|
|
234
|
Build workflows around multiple systems to add more powerful features to Medusa. |
|
235
|
|
|
236
|
```tsx |
|
237
|
const syncBrandsFromSystemWorkflow = createWorkflow( |
|
238
|
"sync-brands-from-system", |
|
239
|
() => { |
|
240
|
const toCreate = retrieveBrandsFromSystemStep() |
|
241
|
|
|
242
|
const created = createBrandsInMedusaStep({ |
|
243
|
brands: toCreate |
|
244
|
}) |
|
245
|
|
|
246
|
return new WorkflowResponse({ |
|
247
|
created, |
|
248
|
}) |
|
249
|
} |
|
250
|
) |
|
251
|
``` |
|
252
|
|
|
253
|
- [Integrate Systems](https://docs.medusajs.com/learn/customization/integrate-systems): Learn more about integrating systems. |
|
254
|
|
|
255
|
## Recipes |
|
256
|
|
|
257
|
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. |
|
258
|
|
|
259
|
- [Marketplace](https://docs.medusajs.com/resources/recipes/marketplace/examples/vendors): Build a marketplace with multiple vendors. |
|
260
|
- [ERP](https://docs.medusajs.com/resources/recipes/erp): Integrate an ERP system to manage custom product prices, purchase rules, syncing orders, and more. |
|
261
|
- [Bundled Products](https://docs.medusajs.com/resources/recipes/bundled-products/examples/standard): Sell products as bundles with Admin and storefront customizations. |
|
262
|
- [Subscriptions](https://docs.medusajs.com/resources/recipes/subscriptions/examples/standard): Implement a subscription-based commerce store. |
|
263
|
- [Restaurant-Delivery](https://docs.medusajs.com/resources/recipes/marketplace/examples/restaurant-delivery): Build a restaurant marketplace inspired by UberEats, with real-time delivery handling. |
|
264
|
- [Digital Products](https://docs.medusajs.com/resources/recipes/digital-products/examples/standard): Sell digital products with custom fulfillment. |
|
265
|
- [View all recipes](https://docs.medusajs.com/resources/recipes): Browse all Medusa recipes. |
|
266
|
|
|
267
|
## Commerce Modules |
|
268
|
|
|
269
|
### Cart & Purchase |
|
270
|
|
|
271
|
- [Cart](https://docs.medusajs.com/resources/commerce-modules/cart): Add to cart, checkout, and totals. |
|
272
|
- [Payment](https://docs.medusajs.com/resources/commerce-modules/payment): Process any payment type. |
|
273
|
- [Customer](https://docs.medusajs.com/resources/commerce-modules/customer): Customer and group management. |
|
274
|
|
|
275
|
### Merchandising |
|
276
|
|
|
277
|
- [Pricing](https://docs.medusajs.com/resources/commerce-modules/pricing): Configurable pricing engine. |
|
278
|
- [Promotion](https://docs.medusajs.com/resources/commerce-modules/promotion): Discounts and promotions. |
|
279
|
- [Product](https://docs.medusajs.com/resources/commerce-modules/product): Variants, categories, and bulk edits. |
|
280
|
|
|
281
|
### Fulfillment |
|
282
|
|
|
283
|
- [Order](https://docs.medusajs.com/resources/commerce-modules/order): Omnichannel order management. |
|
284
|
- [Inventory](https://docs.medusajs.com/resources/commerce-modules/inventory): Multi-warehouse and reservations. |
|
285
|
- [Fulfillment](https://docs.medusajs.com/resources/commerce-modules/fulfillment): Order fulfillment and shipping. |
|
286
|
- [Stock Location](https://docs.medusajs.com/resources/commerce-modules/stock-location): Locations of stock-kept items. |
|
287
|
|
|
288
|
### Regions & Channels |
|
289
|
|
|
290
|
- [Region](https://docs.medusajs.com/resources/commerce-modules/region): Cross-border commerce. |
|
291
|
- [Sales Channel](https://docs.medusajs.com/resources/commerce-modules/sales-channel): Omnichannel sales. |
|
292
|
- [Tax](https://docs.medusajs.com/resources/commerce-modules/tax): Granular tax control. |
|
293
|
- [Currency](https://docs.medusajs.com/resources/commerce-modules/currency): Multi-currency support. |
|
294
|
|
|
295
|
### User Access |
|
296
|
|
|
297
|
- [API Keys](https://docs.medusajs.com/resources/commerce-modules/api-key): Store and admin access. |
|
298
|
- [User Module](https://docs.medusajs.com/resources/commerce-modules/user): Admin user management. |
|
299
|
- [Auth](https://docs.medusajs.com/resources/commerce-modules/auth): Integrate authentication methods. |
|
300
|
|
|
301
|
## Newsletter |
|
302
|
|
|
303
|
Updates delivered monthly. Get the latest product news and behind the scenes updates. Unsubscribe at any time. |
|
304
|
|
|
305
|
## Feedback |
|
306
|
|
|
307
|
Was this page helpful? |