@mercurjs/docs 2.2.1 → 2.3.0-canary.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/content/home.mdx +107 -0
- package/content/learn/architecture.mdx +168 -83
- package/content/learn/introduction.mdx +161 -56
- package/content/learn/migration-to-2-0.mdx +187 -0
- package/content/learn/why-mercur.mdx +91 -0
- package/content/platform/attribute/concepts/attribute-types.mdx +59 -0
- package/content/platform/attribute/concepts/global-vs-inline.mdx +50 -0
- package/content/platform/attribute/concepts/variant-axes.mdx +61 -0
- package/content/platform/attribute/guides/attach-attributes-to-a-product.mdx +69 -0
- package/content/platform/attribute/guides/create-a-variant-axis.mdx +83 -0
- package/content/platform/attribute/guides/create-an-attribute.mdx +81 -0
- package/content/platform/attribute/overview.mdx +87 -0
- package/content/platform/attribute/reference/data-models.mdx +56 -0
- package/content/platform/attribute/reference/events.mdx +41 -0
- package/content/platform/attribute/reference/links.mdx +45 -0
- package/content/platform/attribute/reference/service.mdx +49 -0
- package/content/platform/attribute/reference/workflows.mdx +45 -0
- package/content/platform/catalog/concepts/master-products.mdx +54 -0
- package/content/platform/catalog/concepts/product-seller-allowlist.mdx +48 -0
- package/content/platform/catalog/concepts/status-lifecycle.mdx +58 -0
- package/content/platform/catalog/concepts/variants-categories-collections.mdx +49 -0
- package/content/platform/catalog/guides/allowlist-stores.mdx +59 -0
- package/content/platform/catalog/guides/create-a-master-product.mdx +70 -0
- package/content/platform/catalog/guides/publish-or-reject-a-product.mdx +79 -0
- package/content/platform/catalog/overview.mdx +90 -0
- package/content/platform/catalog/reference/data-models.mdx +66 -0
- package/content/platform/catalog/reference/events.mdx +41 -0
- package/content/platform/catalog/reference/links.mdx +44 -0
- package/content/platform/catalog/reference/service.mdx +52 -0
- package/content/platform/catalog/reference/workflows.mdx +40 -0
- package/content/platform/commission/concepts/order-commission-lines.mdx +65 -0
- package/content/platform/commission/concepts/rule-matching.mdx +86 -0
- package/content/platform/commission/concepts/rules-and-rates.mdx +84 -0
- package/content/platform/commission/guides/batch-update-rules.mdx +58 -0
- package/content/platform/commission/guides/create-a-rate.mdx +72 -0
- package/content/platform/commission/guides/refresh-order-commission-lines.mdx +55 -0
- package/content/platform/commission/overview.mdx +86 -0
- package/content/platform/commission/reference/data-models.mdx +75 -0
- package/content/platform/commission/reference/events.mdx +58 -0
- package/content/platform/commission/reference/links.mdx +45 -0
- package/content/platform/commission/reference/service.mdx +51 -0
- package/content/platform/commission/reference/workflows.mdx +40 -0
- package/content/platform/offer/concepts/pricing-and-inventory.mdx +72 -0
- package/content/platform/offer/concepts/shipping.mdx +48 -0
- package/content/platform/offer/concepts/what-is-an-offer.mdx +65 -0
- package/content/platform/offer/guides/bulk-create-offers.mdx +84 -0
- package/content/platform/offer/guides/create-an-offer.mdx +83 -0
- package/content/platform/offer/guides/manage-offer-inventory.mdx +53 -0
- package/content/platform/offer/overview.mdx +84 -0
- package/content/platform/offer/reference/data-models.mdx +56 -0
- package/content/platform/offer/reference/events.mdx +39 -0
- package/content/platform/offer/reference/links.mdx +60 -0
- package/content/platform/offer/reference/service.mdx +53 -0
- package/content/platform/offer/reference/workflows.mdx +38 -0
- package/content/platform/order-group/concepts/computed-totals.mdx +59 -0
- package/content/platform/order-group/concepts/order-splitting.mdx +61 -0
- package/content/platform/order-group/concepts/the-order-group.mdx +64 -0
- package/content/platform/order-group/guides/list-order-groups.mdx +67 -0
- package/content/platform/order-group/guides/retrieve-an-order-group.mdx +63 -0
- package/content/platform/order-group/guides/split-a-cart.mdx +58 -0
- package/content/platform/order-group/overview.mdx +83 -0
- package/content/platform/order-group/reference/data-models.mdx +40 -0
- package/content/platform/order-group/reference/events.mdx +37 -0
- package/content/platform/order-group/reference/links.mdx +45 -0
- package/content/platform/order-group/reference/service.mdx +50 -0
- package/content/platform/order-group/reference/workflows.mdx +39 -0
- package/content/platform/payout/concepts/account-lifecycle.mdx +75 -0
- package/content/platform/payout/concepts/accounts-and-onboarding.mdx +70 -0
- package/content/platform/payout/concepts/payout-pipeline.mdx +99 -0
- package/content/platform/payout/guides/create-a-payout-account.mdx +59 -0
- package/content/platform/payout/guides/process-a-provider-webhook.mdx +74 -0
- package/content/platform/payout/guides/start-provider-onboarding.mdx +50 -0
- package/content/platform/payout/overview.mdx +86 -0
- package/content/platform/payout/reference/data-models.mdx +61 -0
- package/content/platform/payout/reference/events.mdx +48 -0
- package/content/platform/payout/reference/links.mdx +36 -0
- package/content/platform/payout/reference/service.mdx +53 -0
- package/content/platform/payout/reference/workflows.mdx +32 -0
- package/content/platform/product-edit/concepts/change-actions.mdx +66 -0
- package/content/platform/product-edit/concepts/change-pipeline.mdx +69 -0
- package/content/platform/product-edit/concepts/status-and-auto-confirm.mdx +66 -0
- package/content/platform/product-edit/guides/confirm-or-decline-a-change.mdx +76 -0
- package/content/platform/product-edit/guides/edit-a-product.mdx +74 -0
- package/content/platform/product-edit/guides/request-a-revision.mdx +54 -0
- package/content/platform/product-edit/overview.mdx +85 -0
- package/content/platform/product-edit/reference/data-models.mdx +65 -0
- package/content/platform/product-edit/reference/events.mdx +47 -0
- package/content/platform/product-edit/reference/links.mdx +39 -0
- package/content/platform/product-edit/reference/service.mdx +43 -0
- package/content/platform/product-edit/reference/workflows.mdx +49 -0
- package/content/platform/review/concepts/product-vs-seller-reviews.mdx +63 -0
- package/content/platform/review/concepts/ratings-and-moderation.mdx +64 -0
- package/content/platform/review/concepts/the-review-model.mdx +56 -0
- package/content/platform/review/guides/compute-aggregate-ratings.mdx +57 -0
- package/content/platform/review/guides/create-a-review.mdx +55 -0
- package/content/platform/review/guides/moderate-a-review.mdx +58 -0
- package/content/platform/review/guides/respond-to-a-review.mdx +61 -0
- package/content/platform/review/overview.mdx +87 -0
- package/content/platform/review/reference/data-models.mdx +36 -0
- package/content/platform/review/reference/events.mdx +61 -0
- package/content/platform/review/reference/links.mdx +43 -0
- package/content/platform/review/reference/service.mdx +54 -0
- package/content/platform/review/reference/workflows.mdx +31 -0
- package/content/platform/store/concepts/lifecycle.mdx +62 -0
- package/content/platform/store/concepts/store-entity.mdx +53 -0
- package/content/platform/store/concepts/team.mdx +50 -0
- package/content/platform/store/guides/create-a-store.mdx +55 -0
- package/content/platform/store/guides/manage-the-team.mdx +55 -0
- package/content/platform/store/guides/moderate-a-store.mdx +59 -0
- package/content/platform/store/overview.mdx +86 -0
- package/content/platform/store/reference/data-models.mdx +89 -0
- package/content/platform/store/reference/events.mdx +43 -0
- package/content/platform/store/reference/links.mdx +71 -0
- package/content/platform/store/reference/service.mdx +51 -0
- package/content/platform/store/reference/workflows.mdx +35 -0
- package/content/references/api/admin/commission-rates/create-commission-rate.mdx +1 -1
- package/content/references/api/admin/commission-rates/list-commission-rates.mdx +2 -2
- package/content/references/api/admin/commission-rates/update-commission-rate.mdx +1 -1
- package/content/references/api/admin/offers/batch-create-offers.mdx +3 -3
- package/content/references/api/admin/order-groups/list-order-groups.mdx +1 -1
- package/content/references/api/admin/product-attributes/create-attribute-value.mdx +2 -2
- package/content/references/api/admin/product-attributes/create-product-attribute.mdx +1 -1
- package/content/references/api/admin/product-attributes/update-product-attribute.mdx +1 -1
- package/content/references/api/admin/product-changes/confirm-product-change.mdx +1 -1
- package/content/references/api/admin/products/batch-product-attributes.mdx +1 -1
- package/content/references/api/admin/products/create-product.mdx +1 -1
- package/content/references/api/admin/products/preview-product.mdx +1 -1
- package/content/references/api/admin.mdx +4 -5
- package/content/references/api/conventions.mdx +9 -7
- package/content/references/api/store/carts/add-line-item.mdx +1 -1
- package/content/references/api/store/offers/list-offers.mdx +1 -1
- package/content/references/api/store/order-groups/list-order-groups.mdx +1 -1
- package/content/references/api/store.mdx +4 -13
- package/content/references/api/vendor/members/accept-member-invite.mdx +1 -1
- package/content/references/api/vendor/offers/batch-create-offers.mdx +4 -0
- package/content/references/api/vendor/offers/batch-offer-inventory-items.mdx +2 -0
- package/content/references/api/vendor/offers/create-offer.mdx +13 -1
- package/content/references/api/vendor/offers/list-offers.mdx +4 -0
- package/content/references/api/vendor/offers/retrieve-offer.mdx +4 -0
- package/content/references/api/vendor/offers/update-offer.mdx +12 -0
- package/content/references/api/vendor/payout-accounts/create-onboarding.mdx +1 -1
- package/content/references/api/vendor/products/batch-product-attributes.mdx +1 -1
- package/content/references/api/vendor/products/create-product-variant.mdx +1 -1
- package/content/references/api/vendor/products/create-product.mdx +1 -1
- package/content/references/api/vendor/products/delete-product.mdx +1 -1
- package/content/references/api/vendor/products/update-product.mdx +1 -1
- package/content/references/api/vendor/sellers/create-seller.mdx +2 -2
- package/content/references/api/vendor/sellers/list-sellers.mdx +1 -1
- package/content/references/api/vendor.mdx +6 -5
- package/content/references/configuration.mdx +16 -33
- package/content/references/overview.mdx +34 -52
- package/content/references/panel-extensions/create-page.mdx +194 -0
- package/content/references/panel-extensions/custom-fields.mdx +256 -0
- package/content/references/panel-extensions/overview.mdx +102 -0
- package/content/references/panel-extensions/widgets.mdx +212 -0
- package/content/resources/ai/mcp.mdx +2 -2
- package/content/resources/ai/overview.mdx +21 -16
- package/content/resources/ai/skills.mdx +67 -0
- package/content/resources/best-practices/api-routes.mdx +55 -43
- package/content/resources/best-practices/custom-fields.mdx +116 -92
- package/content/resources/best-practices/frontend.mdx +62 -50
- package/content/resources/best-practices/module-links.mdx +48 -34
- package/content/resources/best-practices/modules.mdx +53 -27
- package/content/resources/best-practices/overview.mdx +45 -17
- package/content/resources/best-practices/subscribers-and-jobs.mdx +37 -24
- package/content/resources/best-practices/types.mdx +38 -23
- package/content/resources/best-practices/workflows.mdx +33 -21
- package/content/resources/customization/custom-fields.mdx +15 -15
- package/content/resources/customization/extend-a-workflow.mdx +7 -4
- package/content/resources/customization/extending-panels.mdx +55 -52
- package/content/resources/deployment/medusa-cloud.mdx +21 -20
- package/content/resources/deployment/self-host.mdx +123 -0
- package/content/resources/integrations/overview.mdx +38 -0
- package/content/resources/integrations/stripe-connect.mdx +39 -38
- package/content/resources/tutorials/add-a-block.mdx +25 -18
- package/content/resources/tutorials/add-a-widget.mdx +32 -23
- package/content/resources/tutorials/add-order-detail-button.mdx +33 -20
- package/content/resources/tutorials/attributes-and-variant-axes.mdx +28 -27
- package/content/resources/tutorials/build-a-block.mdx +26 -15
- package/content/resources/tutorials/custom-api-route.mdx +32 -20
- package/content/resources/tutorials/custom-panel-page.mdx +21 -12
- package/content/resources/tutorials/customize-navigation.mdx +30 -23
- package/content/resources/tutorials/extend-forms-and-tables.mdx +36 -28
- package/content/resources/tutorials/extend-onboarding.mdx +38 -35
- package/content/resources/tutorials/master-products-and-offers.mdx +28 -23
- package/content/telemetry.mdx +3 -3
- package/content/user-guide/admin/attributes/how-tos/create-an-attribute.mdx +64 -0
- package/content/user-guide/admin/attributes/how-tos/manage-possible-values.mdx +40 -0
- package/content/user-guide/admin/attributes/overview.mdx +22 -0
- package/content/user-guide/admin/commissions/how-tos/create-a-commission-rule.mdx +63 -0
- package/content/user-guide/admin/commissions/how-tos/edit-the-global-commission.mdx +48 -0
- package/content/user-guide/admin/commissions/how-tos/manage-a-commission-rule.mdx +45 -0
- package/content/user-guide/admin/commissions/overview.mdx +25 -0
- package/content/user-guide/admin/overview.mdx +20 -12
- package/content/user-guide/admin/product-requests/how-tos/review-a-new-product.mdx +58 -0
- package/content/user-guide/admin/product-requests/how-tos/review-a-product-edit.mdx +48 -0
- package/content/user-guide/admin/product-requests/overview.mdx +25 -0
- package/content/user-guide/vendor/offers/how-tos/create-an-offer.mdx +59 -0
- package/content/user-guide/vendor/offers/how-tos/update-prices-and-stock.mdx +40 -0
- package/content/user-guide/vendor/offers/overview.mdx +22 -0
- package/content/user-guide/vendor/onboarding.mdx +79 -0
- package/content/user-guide/vendor/orders/how-tos/fulfill-an-order.mdx +49 -0
- package/content/user-guide/vendor/orders/how-tos/mark-an-order-as-delivered.mdx +33 -0
- package/content/user-guide/vendor/orders/how-tos/process-a-return.mdx +42 -0
- package/content/user-guide/vendor/orders/how-tos/refund-an-order.mdx +38 -0
- package/content/user-guide/vendor/orders/how-tos/ship-an-order.mdx +40 -0
- package/content/user-guide/vendor/orders/overview.mdx +31 -0
- package/content/user-guide/vendor/overview.mdx +23 -12
- package/content/user-guide/vendor/products/how-tos/edit-a-product.mdx +44 -0
- package/content/user-guide/vendor/products/how-tos/submit-a-product.mdx +63 -0
- package/content/user-guide/vendor/products/overview.mdx +22 -0
- package/llms.txt +176 -142
- package/package.json +1 -1
- package/content/learn/concepts.mdx +0 -84
- package/content/learn/installation.mdx +0 -117
- package/content/learn/mirakl-alternative.mdx +0 -86
- package/content/migration/from-1-x-to-2-0.mdx +0 -152
- package/content/migration/from-2-0-to-2-1.mdx +0 -105
- package/content/migration/overview.mdx +0 -58
- package/content/references/api/store/search/search.mdx +0 -136
- package/content/references/modules/commission.mdx +0 -106
- package/content/references/modules/custom-fields.mdx +0 -45
- package/content/references/modules/media.mdx +0 -55
- package/content/references/modules/offer.mdx +0 -64
- package/content/references/modules/payout.mdx +0 -121
- package/content/references/modules/product-attribute.mdx +0 -111
- package/content/references/modules/product-edit.mdx +0 -80
- package/content/references/modules/search.mdx +0 -112
- package/content/references/modules/seller.mdx +0 -175
- package/content/references/panel-extension-api.mdx +0 -337
- package/content/references/workflows/cart/add-seller-shipping-method-to-cart.mdx +0 -48
- package/content/references/workflows/cart/complete-cart-with-split-orders.mdx +0 -36
- package/content/references/workflows/cart/list-seller-shipping-options-for-cart.mdx +0 -39
- package/content/references/workflows/cart/update-cart-seller-promotions.mdx +0 -42
- package/content/references/workflows/commission/batch-commission-rules.mdx +0 -49
- package/content/references/workflows/commission/create-commission-rates.mdx +0 -41
- package/content/references/workflows/commission/delete-commission-rates.mdx +0 -34
- package/content/references/workflows/commission/refresh-order-commission-lines.mdx +0 -30
- package/content/references/workflows/commission/update-commission-rates.mdx +0 -35
- package/content/references/workflows/media/set-category-images.mdx +0 -41
- package/content/references/workflows/media/set-collection-images.mdx +0 -41
- package/content/references/workflows/member/accept-member-invite.mdx +0 -33
- package/content/references/workflows/member/add-seller-member.mdx +0 -30
- package/content/references/workflows/member/create-member-invites.mdx +0 -34
- package/content/references/workflows/member/delete-member-invite.mdx +0 -24
- package/content/references/workflows/member/remove-seller-member.mdx +0 -28
- package/content/references/workflows/member/resend-member-invite.mdx +0 -28
- package/content/references/workflows/member/update-member-role.mdx +0 -28
- package/content/references/workflows/member/update-member.mdx +0 -35
- package/content/references/workflows/offer/batch-offer-inventory-items.mdx +0 -62
- package/content/references/workflows/offer/create-offers.mdx +0 -65
- package/content/references/workflows/offer/delete-offers.mdx +0 -35
- package/content/references/workflows/offer/update-offers.mdx +0 -53
- package/content/references/workflows/order/cancel-order-fulfillment.mdx +0 -34
- package/content/references/workflows/order/confirm-claim-request.mdx +0 -25
- package/content/references/workflows/order/confirm-exchange-request.mdx +0 -25
- package/content/references/workflows/order/confirm-order-edit-request.mdx +0 -25
- package/content/references/workflows/order/confirm-return-receive.mdx +0 -25
- package/content/references/workflows/order/create-order-fulfillment.mdx +0 -45
- package/content/references/workflows/order-group/get-order-group-detail.mdx +0 -29
- package/content/references/workflows/order-group/get-order-groups-list.mdx +0 -38
- package/content/references/workflows/overview.mdx +0 -72
- package/content/references/workflows/payout/create-onboarding.mdx +0 -36
- package/content/references/workflows/payout/create-payout-account.mdx +0 -33
- package/content/references/workflows/payout/create-payout.mdx +0 -30
- package/content/references/workflows/payout/process-payout-for-webhook.mdx +0 -34
- package/content/references/workflows/product/confirm-products.mdx +0 -48
- package/content/references/workflows/product/create-products.mdx +0 -63
- package/content/references/workflows/product/link-sellers-to-product-category.mdx +0 -40
- package/content/references/workflows/product/link-sellers-to-product.mdx +0 -40
- package/content/references/workflows/product/reject-product.mdx +0 -48
- package/content/references/workflows/product/request-product-change.mdx +0 -48
- package/content/references/workflows/product-attribute/add-product-attributes-to-product.mdx +0 -49
- package/content/references/workflows/product-attribute/create-and-link-product-attributes-to-product.mdx +0 -46
- package/content/references/workflows/product-attribute/create-product-attribute-values.mdx +0 -43
- package/content/references/workflows/product-attribute/create-product-attributes.mdx +0 -56
- package/content/references/workflows/product-attribute/delete-product-attribute-values.mdx +0 -30
- package/content/references/workflows/product-attribute/delete-product-attributes.mdx +0 -30
- package/content/references/workflows/product-attribute/remove-product-attributes-from-product.mdx +0 -29
- package/content/references/workflows/product-attribute/update-product-attribute-values.mdx +0 -44
- package/content/references/workflows/product-attribute/update-product-attributes-on-product.mdx +0 -41
- package/content/references/workflows/product-attribute/update-product-attributes.mdx +0 -48
- package/content/references/workflows/product-attribute/upsert-product-attribute-values.mdx +0 -43
- package/content/references/workflows/product-edit/auto-confirm-product-change.mdx +0 -39
- package/content/references/workflows/product-edit/cancel-product-change.mdx +0 -49
- package/content/references/workflows/product-edit/confirm-product-change.mdx +0 -57
- package/content/references/workflows/product-edit/create-product-change.mdx +0 -72
- package/content/references/workflows/product-edit/reject-product-change.mdx +0 -54
- package/content/references/workflows/product-edit/stage-product-change.mdx +0 -75
- package/content/references/workflows/seller/approve-seller.mdx +0 -36
- package/content/references/workflows/seller/create-seller-account.mdx +0 -59
- package/content/references/workflows/seller/create-seller-defaults.mdx +0 -22
- package/content/references/workflows/seller/create-sellers.mdx +0 -65
- package/content/references/workflows/seller/delete-seller-professional-details.mdx +0 -37
- package/content/references/workflows/seller/delete-sellers.mdx +0 -24
- package/content/references/workflows/seller/invite-seller.mdx +0 -28
- package/content/references/workflows/seller/suspend-seller.mdx +0 -37
- package/content/references/workflows/seller/terminate-seller.mdx +0 -37
- package/content/references/workflows/seller/unsuspend-seller.mdx +0 -36
- package/content/references/workflows/seller/unterminate-seller.mdx +0 -36
- package/content/references/workflows/seller/update-seller-address.mdx +0 -55
- package/content/references/workflows/seller/update-seller-payment-details.mdx +0 -52
- package/content/references/workflows/seller/update-seller-professional-details.mdx +0 -48
- package/content/references/workflows/seller/update-sellers.mdx +0 -57
- package/content/resources/ai/llms.mdx +0 -74
- package/content/resources/integrations/notifications.mdx +0 -39
- package/content/resources/integrations/search.mdx +0 -122
- package/content/resources/tutorials/configure-commissions.mdx +0 -127
- package/content/resources/tutorials/first-marketplace.mdx +0 -45
- package/content/resources/tutorials/handle-product-requests.mdx +0 -80
- package/content/resources/tutorials/import-export-products.mdx +0 -96
- package/content/resources/tutorials/seller-payouts-stripe.mdx +0 -89
- package/content/resources/tutorials/store-setup-checklist.mdx +0 -214
- package/content/tools/api-client.mdx +0 -155
- package/content/tools/cli.mdx +0 -196
- package/content/tools/dashboard-sdk.mdx +0 -35
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Self-host Mercur"
|
|
3
|
+
sidebarTitle: "Self-host"
|
|
4
|
+
description: "Deploy a Mercur marketplace to your own infrastructure: the API, the panels, and the databases behind them."
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
This guide covers the general steps to self-host a Mercur marketplace. Mercur is a
|
|
8
|
+
Medusa plugin, so deployment follows Medusa's model, with one addition: the Vendor
|
|
9
|
+
panel is a separate app. Apply these steps to the hosting provider of your choice.
|
|
10
|
+
|
|
11
|
+
## What you'll deploy
|
|
12
|
+
|
|
13
|
+
A Mercur marketplace has several parts.
|
|
14
|
+
|
|
15
|
+
- **PostgreSQL:** the primary database.
|
|
16
|
+
- **Redis:** session storage, the event bus, the workflow engine, and caching.
|
|
17
|
+
- **Mercur API:** a Medusa server running the Mercur plugin. You deploy it twice, one instance in server mode and one in worker mode.
|
|
18
|
+
- **Admin panel:** served by the API server.
|
|
19
|
+
- **Vendor panel:** a separate static app that talks to the Vendor API.
|
|
20
|
+
- **Storefront (optional):** your own frontend on the Store API.
|
|
21
|
+
|
|
22
|
+
Server mode handles API requests and serves the Admin panel. Worker mode runs
|
|
23
|
+
background work such as scheduled jobs and subscribers. Choose a host with at
|
|
24
|
+
least 2GB of RAM per instance.
|
|
25
|
+
|
|
26
|
+
## 1. Configure the API for production
|
|
27
|
+
|
|
28
|
+
Set three values in `medusa-config.ts` so the same build can run as either a
|
|
29
|
+
server or a worker.
|
|
30
|
+
|
|
31
|
+
```ts medusa-config.ts
|
|
32
|
+
module.exports = defineConfig({
|
|
33
|
+
projectConfig: {
|
|
34
|
+
// ...
|
|
35
|
+
redisUrl: process.env.REDIS_URL,
|
|
36
|
+
workerMode: process.env.MEDUSA_WORKER_MODE as "shared" | "worker" | "server",
|
|
37
|
+
},
|
|
38
|
+
admin: {
|
|
39
|
+
disable: process.env.DISABLE_MEDUSA_ADMIN === "true",
|
|
40
|
+
},
|
|
41
|
+
})
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
The Admin panel is served by the server instance, so you disable it on the worker
|
|
45
|
+
instance. `redisUrl` moves sessions, events, and the workflow engine onto Redis.
|
|
46
|
+
|
|
47
|
+
## 2. Add a predeploy script
|
|
48
|
+
|
|
49
|
+
Run migrations before the app starts in production. Add a `predeploy` script to
|
|
50
|
+
`package.json`.
|
|
51
|
+
|
|
52
|
+
```json package.json
|
|
53
|
+
{
|
|
54
|
+
"scripts": {
|
|
55
|
+
"predeploy": "medusa db:migrate"
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## 3. Use production modules
|
|
61
|
+
|
|
62
|
+
The default project ships modules meant for development, such as the local file
|
|
63
|
+
provider. Swap them for production-ready ones and register them alongside
|
|
64
|
+
`withMercur` in `medusa-config.ts`.
|
|
65
|
+
|
|
66
|
+
- **Redis cache, event bus, and workflow engine:** move caching, events, and workflow state off the local process.
|
|
67
|
+
- **Redis locking provider:** coordinate work safely across instances.
|
|
68
|
+
- **S3 file provider:** store uploads durably.
|
|
69
|
+
- **A notification provider** such as SendGrid or Resend, for transactional email.
|
|
70
|
+
|
|
71
|
+
## 4. Set environment variables
|
|
72
|
+
|
|
73
|
+
Set these on each API instance.
|
|
74
|
+
|
|
75
|
+
| Variable | Description |
|
|
76
|
+
| --- | --- |
|
|
77
|
+
| `DATABASE_URL` | PostgreSQL connection string |
|
|
78
|
+
| `REDIS_URL` | Redis connection string |
|
|
79
|
+
| `JWT_SECRET` | Secret for signing auth tokens |
|
|
80
|
+
| `COOKIE_SECRET` | Secret for signing session cookies |
|
|
81
|
+
| `MEDUSA_WORKER_MODE` | `server` on the server instance, `worker` on the worker instance |
|
|
82
|
+
| `DISABLE_MEDUSA_ADMIN` | `false` on the server, `true` on the worker |
|
|
83
|
+
| `STORE_CORS` / `ADMIN_CORS` / `AUTH_CORS` | Allowed origins for the storefront, panels, and auth |
|
|
84
|
+
|
|
85
|
+
## 5. Deploy the API
|
|
86
|
+
|
|
87
|
+
Deploy the same build as two instances.
|
|
88
|
+
|
|
89
|
+
<Steps>
|
|
90
|
+
<Step title="Build the app">
|
|
91
|
+
Run `bun run build` to compile the server and the Admin panel.
|
|
92
|
+
</Step>
|
|
93
|
+
<Step title="Run migrations">
|
|
94
|
+
The `predeploy` script runs `medusa db:migrate`. Run it once before starting.
|
|
95
|
+
</Step>
|
|
96
|
+
<Step title="Start the server instance">
|
|
97
|
+
Set `MEDUSA_WORKER_MODE=server` and `DISABLE_MEDUSA_ADMIN=false`. This instance serves the API and the Admin panel.
|
|
98
|
+
</Step>
|
|
99
|
+
<Step title="Start the worker instance">
|
|
100
|
+
Set `MEDUSA_WORKER_MODE=worker` and `DISABLE_MEDUSA_ADMIN=true`. This instance runs jobs and subscribers.
|
|
101
|
+
</Step>
|
|
102
|
+
</Steps>
|
|
103
|
+
|
|
104
|
+
## 6. Deploy the Vendor panel
|
|
105
|
+
|
|
106
|
+
The Vendor panel is a separate Vite app. Build it with the API URL configured,
|
|
107
|
+
then host the static output on any static host or CDN.
|
|
108
|
+
|
|
109
|
+
<Note>
|
|
110
|
+
The Admin panel ships with the API server. The Vendor panel deploys on its own,
|
|
111
|
+
the same way a storefront does.
|
|
112
|
+
</Note>
|
|
113
|
+
|
|
114
|
+
## Next steps
|
|
115
|
+
|
|
116
|
+
<CardGroup cols={2}>
|
|
117
|
+
<Card title="Medusa Cloud" icon="cloud" href="/resources/deployment/medusa-cloud">
|
|
118
|
+
Deploy without managing infrastructure yourself.
|
|
119
|
+
</Card>
|
|
120
|
+
<Card title="Stripe Connect" icon="credit-card" href="/resources/integrations/stripe-connect">
|
|
121
|
+
Wire up payments and payouts for production.
|
|
122
|
+
</Card>
|
|
123
|
+
</CardGroup>
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Integrations"
|
|
3
|
+
sidebarTitle: "Overview"
|
|
4
|
+
description: "Extend Mercur with third-party providers and installable blocks."
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
Mercur integrates with third-party providers to extend your marketplace. Payout
|
|
8
|
+
providers settle seller earnings, and installable blocks add extra capabilities on
|
|
9
|
+
top of the core platform.
|
|
10
|
+
|
|
11
|
+
## Payout providers
|
|
12
|
+
|
|
13
|
+
A payout provider settles seller earnings to their connected accounts. Stripe
|
|
14
|
+
Connect ships out of the box. You can add your own provider against the same
|
|
15
|
+
interface.
|
|
16
|
+
|
|
17
|
+
<CardGroup cols={2}>
|
|
18
|
+
<Card title="Stripe Connect" icon="credit-card" href="/resources/integrations/stripe-connect">
|
|
19
|
+
Configure the Stripe Connect payout provider.
|
|
20
|
+
</Card>
|
|
21
|
+
<Card title="Payout module" icon="wallet" href="/platform/payout/overview">
|
|
22
|
+
Accounts, onboarding, and the transfer pipeline.
|
|
23
|
+
</Card>
|
|
24
|
+
</CardGroup>
|
|
25
|
+
|
|
26
|
+
## Blocks
|
|
27
|
+
|
|
28
|
+
Other integrations ship as installable blocks. You add the block, own its source
|
|
29
|
+
in your project, and update it explicitly.
|
|
30
|
+
|
|
31
|
+
<CardGroup cols={2}>
|
|
32
|
+
<Card title="Add a Block" icon="cubes" href="/resources/tutorials/add-a-block">
|
|
33
|
+
Install a feature block into your project.
|
|
34
|
+
</Card>
|
|
35
|
+
<Card title="Build a Block" icon="hammer" href="/resources/tutorials/build-a-block">
|
|
36
|
+
Package your own feature as a distributable block.
|
|
37
|
+
</Card>
|
|
38
|
+
</CardGroup>
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
---
|
|
2
|
-
title: "Stripe Connect
|
|
3
|
-
|
|
2
|
+
title: "Stripe Connect"
|
|
3
|
+
sidebarTitle: "Stripe Connect"
|
|
4
|
+
description: "Set up Stripe Connect for marketplace payments and seller payouts, from Stripe Dashboard configuration to the full end-to-end payment lifecycle."
|
|
4
5
|
---
|
|
5
6
|
|
|
6
7
|
A Mercur marketplace needs **two** Stripe integrations working together. The first is the standard Medusa payment provider, which charges customers at checkout. The second is the Mercur payout provider, which transfers funds from the platform to sellers after orders are fulfilled.
|
|
7
8
|
|
|
8
|
-
This guide covers both
|
|
9
|
+
This guide covers both. It walks through setting up Stripe, configuring both providers, wiring up webhooks, and understanding how money flows from customer to seller.
|
|
9
10
|
|
|
10
11
|
<Tip>
|
|
11
|
-
This page is the configuration reference. For
|
|
12
|
+
This page is the configuration reference. For how payout accounts, onboarding, and the transfer pipeline work, see the [Payout](/platform/payout/overview) module.
|
|
12
13
|
</Tip>
|
|
13
14
|
|
|
14
15
|
<Info>
|
|
@@ -19,7 +20,7 @@ This guide covers both — setting up Stripe, configuring both providers, wiring
|
|
|
19
20
|
|
|
20
21
|
- A [Stripe account](https://dashboard.stripe.com) with Connect enabled
|
|
21
22
|
- Stripe Secret API key and Publishable API key
|
|
22
|
-
- A running Mercur project ([installation guide](/
|
|
23
|
+
- A running Mercur project ([installation guide](/learn/introduction))
|
|
23
24
|
- Node.js 20+
|
|
24
25
|
|
|
25
26
|
## Architecture overview
|
|
@@ -51,8 +52,8 @@ The two integrations serve different purposes:
|
|
|
51
52
|
<Step title="Find your API keys">
|
|
52
53
|
Go to **Developers → API keys**. You'll need:
|
|
53
54
|
|
|
54
|
-
- **Secret key
|
|
55
|
-
- **Publishable key
|
|
55
|
+
- **Secret key:** starts with `sk_test_` (test mode) or `sk_live_` (production)
|
|
56
|
+
- **Publishable key:** starts with `pk_test_` or `pk_live_`
|
|
56
57
|
</Step>
|
|
57
58
|
<Step title="Set environment variables">
|
|
58
59
|
Add the following to your `.env` file:
|
|
@@ -147,8 +148,8 @@ module.exports = defineConfig({
|
|
|
147
148
|
|
|
148
149
|
| Option | Type | Default | Description |
|
|
149
150
|
|--------|------|---------|-------------|
|
|
150
|
-
| `apiKey` | `string` |
|
|
151
|
-
| `webhookSecret` | `string` |
|
|
151
|
+
| `apiKey` | `string` | - | Stripe secret API key |
|
|
152
|
+
| `webhookSecret` | `string` | - | Signing secret for the payout webhook endpoint |
|
|
152
153
|
| `accountValidation` | `object` | See below | Controls when a connected account is considered `ACTIVE` |
|
|
153
154
|
|
|
154
155
|
### Account validation options
|
|
@@ -172,12 +173,12 @@ The payout module itself accepts timing options that control the capture and pay
|
|
|
172
173
|
| `disabled` | `boolean` | `false` | Disable automatic capture checks and daily payout jobs |
|
|
173
174
|
| `authorizationWindowMs` | `number` | `604800000` (7 days) | How long a payment authorization remains valid |
|
|
174
175
|
| `sellerActionWindowMs` | `number` | `259200000` (72 hours) | How long sellers have to accept/fulfill before cancellation |
|
|
175
|
-
| `captureSafetyBufferMs` | `number` | `86400000` (24 hours) | Safety margin before authorization expiry
|
|
176
|
+
| `captureSafetyBufferMs` | `number` | `86400000` (24 hours) | Safety margin before authorization expiry. Capture happens before `authorization expiry - buffer` |
|
|
176
177
|
| `requiredFulfillmentStatus` | `string` | `"fulfilled"` | Minimum fulfillment status before an order is eligible for capture |
|
|
177
178
|
|
|
178
179
|
## Set up webhooks
|
|
179
180
|
|
|
180
|
-
You need **two separate webhook endpoints** in Stripe
|
|
181
|
+
You need **two separate webhook endpoints** in Stripe: one for payment events, one for payout events.
|
|
181
182
|
|
|
182
183
|
<Warning>
|
|
183
184
|
These are two distinct webhook endpoints, each with its own signing secret. Do not combine them into a single endpoint.
|
|
@@ -216,19 +217,19 @@ Here's a concrete example. A customer buys items from two sellers:
|
|
|
216
217
|
- **Shipping**: €10
|
|
217
218
|
- **Cart total**: €80
|
|
218
219
|
|
|
219
|
-
### Step 1
|
|
220
|
+
### Step 1: Authorize payment
|
|
220
221
|
|
|
221
|
-
At checkout, a single `PaymentIntent` is created for €80 with `capture_method: "manual"`. The customer authenticates once (SCA-compliant). No money moves yet
|
|
222
|
+
At checkout, a single `PaymentIntent` is created for €80 with `capture_method: "manual"`. The customer authenticates once (SCA-compliant). No money moves yet. The funds are held on the customer's card.
|
|
222
223
|
|
|
223
|
-
### Step 2
|
|
224
|
+
### Step 2: Split orders
|
|
224
225
|
|
|
225
|
-
Mercur's `completeCartWithSplitOrdersWorkflow` groups items by seller and creates separate orders
|
|
226
|
+
Mercur's `completeCartWithSplitOrdersWorkflow` groups items by seller and creates separate orders: one for Seller A (€40) and one for Seller B (€30), plus shipping allocation.
|
|
226
227
|
|
|
227
|
-
### Step 3
|
|
228
|
+
### Step 3: Seller acceptance and fulfillment
|
|
228
229
|
|
|
229
230
|
Each seller reviews and fulfills their order through the Vendor Portal. The payout module's `sellerActionWindowMs` (default: 72 hours) defines how long sellers have to act.
|
|
230
231
|
|
|
231
|
-
### Step 4
|
|
232
|
+
### Step 4: Capture payment
|
|
232
233
|
|
|
233
234
|
Once orders meet the `requiredFulfillmentStatus` (default: `"fulfilled"`), the platform captures the authorized payment. The capture-check job runs automatically and respects the `captureSafetyBufferMs` to ensure capture happens before authorization expiry.
|
|
234
235
|
|
|
@@ -236,7 +237,7 @@ Once orders meet the `requiredFulfillmentStatus` (default: `"fulfilled"`), the p
|
|
|
236
237
|
Card authorizations typically expire after **7 days**. The default configuration gives sellers 72 hours to fulfill, with a 24-hour safety buffer before capture. If your business requires longer seller action windows, consider whether the 7-day authorization window is sufficient.
|
|
237
238
|
</Warning>
|
|
238
239
|
|
|
239
|
-
### Step 5
|
|
240
|
+
### Step 5: Commission calculation and transfers
|
|
240
241
|
|
|
241
242
|
After capture, Mercur calculates commission for each order and creates Stripe Transfers for the net amounts:
|
|
242
243
|
|
|
@@ -247,7 +248,7 @@ Seller B net = €30 - commission
|
|
|
247
248
|
|
|
248
249
|
Each transfer is linked to the original charge via `source_transaction` and grouped by `transfer_group` (the order ID).
|
|
249
250
|
|
|
250
|
-
### Step 6
|
|
251
|
+
### Step 6: Bank payouts
|
|
251
252
|
|
|
252
253
|
Stripe automatically pays out connected account balances to sellers' bank accounts on the configured payout schedule. Mercur tracks payout status changes via the `account.updated` webhook.
|
|
253
254
|
|
|
@@ -263,16 +264,16 @@ PENDING → (Stripe onboarding) → ACTIVE
|
|
|
263
264
|
REJECTED (permanent)
|
|
264
265
|
```
|
|
265
266
|
|
|
266
|
-
1. **Account creation
|
|
267
|
+
1. **Account creation.** Mercur calls `stripe.accounts.create({ type: "express" })`, creating a Stripe Express connected account. The payout account starts in `PENDING` status.
|
|
267
268
|
|
|
268
|
-
2. **Onboarding link
|
|
269
|
+
2. **Onboarding link.** The seller receives a Stripe-hosted onboarding URL via `stripe.accountLinks.create()`. They complete identity verification, bank account setup, and any required compliance steps directly on Stripe.
|
|
269
270
|
|
|
270
|
-
3. **Webhook activation
|
|
271
|
+
3. **Webhook activation.** When the seller completes onboarding, Stripe sends an `account.updated` webhook. The provider evaluates the account against the `accountValidation` options and transitions the status:
|
|
271
272
|
- All validation checks pass → `ACTIVE`
|
|
272
273
|
- Missing requirements or disabled reason → `RESTRICTED`
|
|
273
274
|
- Disabled reason starts with `rejected.` → `REJECTED`
|
|
274
275
|
|
|
275
|
-
4. **Ongoing monitoring
|
|
276
|
+
4. **Ongoing monitoring.** Stripe may send additional `account.updated` events if requirements change. The provider re-evaluates and updates the status accordingly.
|
|
276
277
|
|
|
277
278
|
For more details on payout accounts, balances, and transactions, see [Payout](/rc/learn/payouts).
|
|
278
279
|
|
|
@@ -284,7 +285,7 @@ Stripe uses two distinct concepts for moving money, and it's important to unders
|
|
|
284
285
|
|---|---|---|
|
|
285
286
|
| **What it does** | Moves funds from platform balance to connected account balance | Moves funds from connected account balance to seller's bank account |
|
|
286
287
|
| **Speed** | Instant ledger movement | 1–3 business days (varies by country) |
|
|
287
|
-
| **Status lifecycle** | None
|
|
288
|
+
| **Status lifecycle** | None. Transfers are immediate | `pending` → `in_transit` → `paid` / `failed` |
|
|
288
289
|
| **Who triggers it** | Mercur (via `stripe.transfers.create()`) | Stripe (on the connected account's payout schedule) |
|
|
289
290
|
| **Mercur tracking** | Transfer created with status `PAID` immediately | Status tracked via webhooks |
|
|
290
291
|
|
|
@@ -294,8 +295,8 @@ When Mercur's `createPayout` method is called, the Stripe Connect provider creat
|
|
|
294
295
|
|
|
295
296
|
Refunding a charge does **not** automatically reverse the associated transfers. These are two separate operations:
|
|
296
297
|
|
|
297
|
-
1. **Refund the PaymentIntent
|
|
298
|
-
2. **Reverse the Transfer(s)
|
|
298
|
+
1. **Refund the PaymentIntent.** Returns funds to the customer's payment method
|
|
299
|
+
2. **Reverse the Transfer(s).** Claws back funds from the connected account(s)
|
|
299
300
|
|
|
300
301
|
For a full refund of a multi-seller order, you would need to reverse each seller's transfer individually. For partial refunds, you need to calculate how much to reverse from each seller based on which items are being refunded.
|
|
301
302
|
|
|
@@ -343,13 +344,13 @@ Use Stripe test mode keys (`sk_test_`, `pk_test_`) during development. All conne
|
|
|
343
344
|
|
|
344
345
|
### Webhook forwarding with Stripe CLI
|
|
345
346
|
|
|
346
|
-
Since webhooks need to reach your local machine during development, use the [Stripe CLI](https://docs.stripe.com/stripe-cli) to forward events. You need **two separate listeners
|
|
347
|
+
Since webhooks need to reach your local machine during development, use the [Stripe CLI](https://docs.stripe.com/stripe-cli) to forward events. You need **two separate listeners**, one for each webhook endpoint:
|
|
347
348
|
|
|
348
349
|
```bash
|
|
349
|
-
# Terminal 1
|
|
350
|
+
# Terminal 1: Payment webhooks
|
|
350
351
|
stripe listen --forward-to localhost:9000/hooks/payment/stripe_stripe
|
|
351
352
|
|
|
352
|
-
# Terminal 2
|
|
353
|
+
# Terminal 2: Payout webhooks
|
|
353
354
|
stripe listen --forward-to localhost:9000/hooks/payout
|
|
354
355
|
```
|
|
355
356
|
|
|
@@ -370,26 +371,26 @@ stripe listen --forward-to localhost:9000/hooks/payout
|
|
|
370
371
|
|
|
371
372
|
<AccordionGroup>
|
|
372
373
|
<Accordion title="Why do I need two webhook endpoints with two secrets?">
|
|
373
|
-
They belong to two different integrations: the payment webhook feeds Medusa's payment provider (charges, captures, refunds), while the payout webhook feeds Mercur's payout provider (connected-account status, transfer status). Each endpoint verifies its own signing secret
|
|
374
|
+
They belong to two different integrations: the payment webhook feeds Medusa's payment provider (charges, captures, refunds), while the payout webhook feeds Mercur's payout provider (connected-account status, transfer status). Each endpoint verifies its own signing secret. Combining them silently breaks whichever side's signature doesn't match.
|
|
374
375
|
</Accordion>
|
|
375
376
|
<Accordion title="Why must capture be set to false on the payment provider?">
|
|
376
|
-
The marketplace flow authorizes at checkout and captures later, after sellers fulfill. Automatic capture would take the money before the split-order pipeline (fulfillment checks, commission, payouts) has run
|
|
377
|
+
The marketplace flow authorizes at checkout and captures later, after sellers fulfill. Automatic capture would take the money before the split-order pipeline (fulfillment checks, commission, payouts) has run. `capture: false` hands that timing to the payout module's capture job.
|
|
377
378
|
</Accordion>
|
|
378
|
-
<Accordion title="A seller finished Stripe onboarding but is still not ACTIVE
|
|
379
|
-
Check the `accountValidation` options: by default the account must have details submitted, charges and payouts enabled, and **no outstanding requirements**. Stripe often adds follow-up requirements (e.g. extra KYC) after initial onboarding
|
|
379
|
+
<Accordion title="A seller finished Stripe onboarding but is still not ACTIVE. Why?">
|
|
380
|
+
Check the `accountValidation` options: by default the account must have details submitted, charges and payouts enabled, and **no outstanding requirements**. Stripe often adds follow-up requirements (e.g. extra KYC) after initial onboarding. The account shows as `RESTRICTED` until they're cleared.
|
|
380
381
|
</Accordion>
|
|
381
382
|
<Accordion title="Who handles VAT, disputes, and chargebacks?">
|
|
382
|
-
The platform. Separate Charges and Transfers makes the platform the Merchant of Record
|
|
383
|
+
The platform. Separate Charges and Transfers makes the platform the Merchant of Record. See [EU/EEA considerations](#eueea-considerations) for what that entails.
|
|
383
384
|
</Accordion>
|
|
384
385
|
</AccordionGroup>
|
|
385
386
|
|
|
386
387
|
## Next steps
|
|
387
388
|
|
|
388
389
|
<CardGroup cols={2}>
|
|
389
|
-
<Card title="
|
|
390
|
-
|
|
390
|
+
<Card title="Payout" href="/platform/payout/overview">
|
|
391
|
+
Payout accounts, onboarding, and the transfer pipeline.
|
|
391
392
|
</Card>
|
|
392
|
-
<Card title="
|
|
393
|
-
|
|
393
|
+
<Card title="The payout pipeline" href="/platform/payout/concepts/payout-pipeline">
|
|
394
|
+
Statuses, jobs, and webhook events.
|
|
394
395
|
</Card>
|
|
395
396
|
</CardGroup>
|
|
@@ -1,25 +1,28 @@
|
|
|
1
1
|
---
|
|
2
|
-
title: "
|
|
3
|
-
|
|
2
|
+
title: "How to Add a Block"
|
|
3
|
+
sidebarTitle: "Add a Block"
|
|
4
|
+
description: "Install the reviews block end-to-end and follow it live across the admin, vendor, and storefront surfaces."
|
|
4
5
|
---
|
|
5
6
|
|
|
6
|
-
|
|
7
|
+
Install a block and see the feature running on every surface it touches.
|
|
8
|
+
|
|
9
|
+
Blocks are complete features installed as **source code** into your project. A block bundles the backend module, workflows, API routes, and panel UI. This tutorial installs the `reviews` block and follows it across each surface it appears on.
|
|
7
10
|
|
|
8
11
|
<Info>
|
|
9
|
-
|
|
12
|
+
Blocks are copied, not installed as dependencies. `add` writes the block's source files into your project through the aliases in `blocks.json`. You own and can edit every file afterwards. Updates are opt-in through `diff` and `add --overwrite`. When you outgrow the catalog, [build your own block](/rc/resources/tutorials/build-a-block).
|
|
10
13
|
</Info>
|
|
11
14
|
|
|
12
15
|
## Goal
|
|
13
16
|
|
|
14
|
-
Install reviews as a block and
|
|
17
|
+
Install reviews as a block and confirm it runs everywhere it appears.
|
|
15
18
|
|
|
16
19
|
## Install the block
|
|
17
20
|
|
|
18
21
|
<Steps>
|
|
19
22
|
<Step title="Discover the block">
|
|
20
|
-
Search the registry and inspect what the block ships before
|
|
23
|
+
Search the registry and inspect what the block ships before you install it.
|
|
21
24
|
|
|
22
|
-
```bash
|
|
25
|
+
```bash Terminal
|
|
23
26
|
bunx @mercurjs/cli@latest search --query reviews
|
|
24
27
|
bunx @mercurjs/cli@latest view reviews
|
|
25
28
|
```
|
|
@@ -27,16 +30,18 @@ Install reviews as a block and see it running everywhere it appears.
|
|
|
27
30
|
`view` lists the block's files by target (API, admin, vendor) and its dependencies.
|
|
28
31
|
</Step>
|
|
29
32
|
<Step title="Install it">
|
|
30
|
-
|
|
33
|
+
Run `add` to copy the block into your project.
|
|
34
|
+
|
|
35
|
+
```bash Terminal
|
|
31
36
|
bunx @mercurjs/cli@latest add reviews
|
|
32
37
|
```
|
|
33
38
|
|
|
34
|
-
The CLI copies the source into the directories mapped by your `blocks.json` aliases and prints the block's post-install instructions
|
|
39
|
+
The CLI copies the source into the directories mapped by your `blocks.json` aliases and prints the block's post-install instructions: module registration, middlewares, and migrations.
|
|
35
40
|
</Step>
|
|
36
41
|
<Step title="Run migrations and codegen">
|
|
37
|
-
The block introduced a reviews module
|
|
42
|
+
The block introduced a reviews module. Generate and run its migrations, then refresh the typed route map.
|
|
38
43
|
|
|
39
|
-
```bash
|
|
44
|
+
```bash Terminal
|
|
40
45
|
cd packages/api
|
|
41
46
|
bunx medusa db:generate reviews
|
|
42
47
|
bunx medusa db:migrate
|
|
@@ -44,25 +49,27 @@ Install reviews as a block and see it running everywhere it appears.
|
|
|
44
49
|
```
|
|
45
50
|
</Step>
|
|
46
51
|
<Step title="See it live">
|
|
47
|
-
Start the project
|
|
52
|
+
Start the project. Reviews now appear in the admin panel (moderation), the vendor portal (per-seller reviews), and the Store API (customer-facing review routes).
|
|
48
53
|
</Step>
|
|
49
54
|
</Steps>
|
|
50
55
|
|
|
51
56
|
## Verify
|
|
52
57
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
58
|
+
Check that the install landed cleanly:
|
|
59
|
+
|
|
60
|
+
- **Files:** the block's files exist in your repo under the alias-mapped paths.
|
|
61
|
+
- **API:** migrations ran cleanly and the API boots.
|
|
62
|
+
- **Panels and store:** the admin and vendor panels show their reviews pages, and the store review endpoints respond.
|
|
63
|
+
- **No drift:** `bunx @mercurjs/cli@latest diff reviews` reports no drift from the registry.
|
|
57
64
|
|
|
58
65
|
## FAQ
|
|
59
66
|
|
|
60
67
|
<AccordionGroup>
|
|
61
68
|
<Accordion title="What if I've already modified files the block wants to write?">
|
|
62
|
-
The CLI asks before overwriting existing files
|
|
69
|
+
The CLI asks before overwriting existing files, or you can force it with `--overwrite`. If you have customized a page the block also ships, merge by hand. You are merging source, not resolving package versions.
|
|
63
70
|
</Accordion>
|
|
64
71
|
<Accordion title="How do I update a block later?">
|
|
65
|
-
`bunx @mercurjs/cli@latest diff reviews` shows what changed in the registry since you installed. Take updates with `add reviews --overwrite`, re-
|
|
72
|
+
`bunx @mercurjs/cli@latest diff reviews` shows what changed in the registry since you installed. Take updates with `add reviews --overwrite`, then re-apply any local edits afterwards.
|
|
66
73
|
</Accordion>
|
|
67
74
|
</AccordionGroup>
|
|
68
75
|
|
|
@@ -1,33 +1,38 @@
|
|
|
1
1
|
---
|
|
2
|
-
title: "Add a
|
|
3
|
-
|
|
2
|
+
title: "How to Add a Widget"
|
|
3
|
+
sidebarTitle: "Add a Widget"
|
|
4
|
+
description: "Render your own React component in a named zone on a built-in panel page without forking it."
|
|
4
5
|
---
|
|
5
6
|
|
|
6
|
-
A
|
|
7
|
+
A widget is a React component attached to a named zone on a built-in page. You drop one file under `src/widgets/`, and the SDK renders it at that zone while the rest of the page stays exactly as shipped, including its data fetching, filters, and pagination.
|
|
8
|
+
|
|
9
|
+
This is the lightest way to add UI to a page you don't own. Reach for it first when you want to add something to an existing screen.
|
|
7
10
|
|
|
8
11
|
<Info>
|
|
9
|
-
|
|
12
|
+
A widget is additive, not a replacement. Unlike a drop-in route, which owns the whole page, a widget layers your component onto the built-in page at a documented zone.
|
|
10
13
|
</Info>
|
|
11
14
|
|
|
12
15
|
## What you'll build
|
|
13
16
|
|
|
14
|
-
A tip banner above the vendor product list, rendered from a single file
|
|
17
|
+
A tip banner above the vendor product list, rendered from a single file, with the list itself untouched.
|
|
15
18
|
|
|
16
|
-
## Register the typed targets
|
|
19
|
+
## Register the typed targets
|
|
17
20
|
|
|
18
|
-
Widget zones are typed ids that the vendor panel generates from its own pages and ships as `@mercurjs/vendor/extension-targets`. Register them once so the ids resolve everywhere, with a single ambient reference in your app's `src
|
|
21
|
+
Widget zones are typed ids that the vendor panel generates from its own pages and ships as `@mercurjs/vendor/extension-targets`. Register them once so the ids resolve everywhere, with a single ambient reference in your app's `src`.
|
|
19
22
|
|
|
20
23
|
```typescript apps/vendor/src/extension-targets.d.ts
|
|
21
24
|
/// <reference types="@mercurjs/vendor/extension-targets" />
|
|
22
25
|
```
|
|
23
26
|
|
|
24
|
-
|
|
27
|
+
<Note>
|
|
28
|
+
Projects from `create-mercur-app` already ship this file. With it present, an invalid zone fails `tsc` instead of silently doing nothing.
|
|
29
|
+
</Note>
|
|
25
30
|
|
|
26
31
|
## Add the widget
|
|
27
32
|
|
|
28
33
|
<Steps>
|
|
29
34
|
<Step title="Create the widget file">
|
|
30
|
-
Drop a file under `src/widgets/`. Export the component as the
|
|
35
|
+
Drop a file under `src/widgets/`. Export the component as the default and a `config` built with `defineWidgetConfig`. The `zone` names where it renders.
|
|
31
36
|
|
|
32
37
|
```tsx apps/vendor/src/widgets/product-list-banner.tsx
|
|
33
38
|
import { defineWidgetConfig } from "@mercurjs/dashboard-sdk"
|
|
@@ -49,52 +54,56 @@ Projects from `create-mercur-app` already ship this file. With it present, an in
|
|
|
49
54
|
```
|
|
50
55
|
</Step>
|
|
51
56
|
<Step title="Understand the zone id">
|
|
52
|
-
A zone id
|
|
57
|
+
A zone id reads `<domain>.<view>.<placement>`. The last segment is the placement.
|
|
53
58
|
|
|
54
59
|
| Placement | Effect |
|
|
55
60
|
|-----------|--------|
|
|
56
61
|
| `before` | Renders before the built-in content of the zone |
|
|
57
62
|
| `after` | Renders after the built-in content |
|
|
58
63
|
|
|
59
|
-
Multiple `before`
|
|
64
|
+
Multiple `before` or `after` widgets on the same zone stack in registration order.
|
|
60
65
|
</Step>
|
|
61
66
|
<Step title="Reload the panel">
|
|
62
|
-
Start the project
|
|
67
|
+
Start the project and open the vendor portal. Widget files hot-reload. The banner appears above the product list, and the table below it works exactly as before.
|
|
68
|
+
|
|
69
|
+
```bash Terminal
|
|
70
|
+
bun run dev
|
|
71
|
+
```
|
|
63
72
|
</Step>
|
|
64
73
|
</Steps>
|
|
65
74
|
|
|
66
75
|
## Available zones
|
|
67
76
|
|
|
68
|
-
|
|
77
|
+
These zones are mounted today in the vendor portal.
|
|
69
78
|
|
|
70
79
|
| Zone | Where it renders |
|
|
71
80
|
|------|------------------|
|
|
72
81
|
| `product.list.before` / `.after` | Vendor product list page |
|
|
73
|
-
| `seller.setup.before` / `.after` | The store-setup
|
|
82
|
+
| `seller.setup.before` / `.after` | The store-setup and onboarding surface (dashboard home plus store settings), passed the `seller` as `data` |
|
|
74
83
|
| `login.logo.*` | The logo slot on the public login screen |
|
|
75
|
-
| `login.before.*` / `login.after.*` | Around the login form
|
|
84
|
+
| `login.before.*` / `login.after.*` | Around the login form, rendered before authentication |
|
|
76
85
|
|
|
77
|
-
The full, valid set is typed as `WidgetZoneId` and generated into `@mercurjs/vendor/extension-targets` from the panel's own zone hosts
|
|
86
|
+
The full, valid set is typed as `WidgetZoneId` and generated into `@mercurjs/vendor/extension-targets` from the panel's own zone hosts. Let your editor autocomplete `zone:` to see every option. A zone no page renders can't be targeted and won't type-check.
|
|
78
87
|
|
|
79
88
|
## Verify
|
|
80
89
|
|
|
81
90
|
1. The tip banner renders above the product list.
|
|
82
|
-
2. Search, filter, and paginate the list
|
|
83
|
-
3. Change the zone to `product.list.after` and reload
|
|
84
|
-
4. Set `zone: "not.a.zone"
|
|
85
|
-
5. Delete the file
|
|
91
|
+
2. Search, filter, and paginate the list. All built-in behavior still works.
|
|
92
|
+
3. Change the zone to `product.list.after` and reload. The banner moves below the list.
|
|
93
|
+
4. Set `zone: "not.a.zone"`. `tsc` (`bun run lint`) fails with a "not assignable to `WidgetZoneId`" error.
|
|
94
|
+
5. Delete the file. The banner disappears, and nothing else changes.
|
|
86
95
|
|
|
87
96
|
## FAQ
|
|
88
97
|
|
|
89
98
|
<AccordionGroup>
|
|
90
99
|
<Accordion title="Can a widget target more than one zone?">
|
|
91
|
-
Yes
|
|
100
|
+
Yes. `zone` accepts an array (`zone: ["product.list.before", "login.after.before"]`), and the same component renders at each.
|
|
92
101
|
</Accordion>
|
|
93
102
|
<Accordion title="Can a block ship widgets?">
|
|
94
|
-
Yes. A [block](/rc/learn/blocks) can include `src/widgets/` files in its `vendor_ui`
|
|
103
|
+
Yes. A [block](/rc/learn/blocks) can include `src/widgets/` files in its `vendor_ui` or `admin_ui` entry, and they're aggregated just like the host app's. Installing the block adds the widget with no wiring.
|
|
95
104
|
</Accordion>
|
|
96
105
|
<Accordion title="Does the admin panel have widget zones too?">
|
|
97
|
-
The zone set is per panel and generated from each panel's pages. Today the mounted zones live in the vendor portal (`product.list.*`, `login.*`)
|
|
106
|
+
The zone set is per panel and generated from each panel's pages. Today the mounted zones live in the vendor portal (`product.list.*`, `login.*`). The admin panel exposes navigation and product custom fields. Check `@mercurjs/admin/extension-targets` for its current zones.
|
|
98
107
|
</Accordion>
|
|
99
108
|
</AccordionGroup>
|
|
100
109
|
|