The complete open source platform to run your entire marketplace. Storefront, vendor panel, admin console, and integrations in one enterprise-grade platform you own.
Patterns (how the pieces fit together)
The structural rules for Mercur dashboard pages. These are conventions, not lint rules — follow them so generated code reads like the rest of the codebase. Each pattern says what to do and, where it's a common mistake, what not to do.
Sections do X
Every section on a page is a Container with the standard shell:
<Container className="divide-y p-0" data-testid="customer-general-section">
<div className="flex items-center justify-between px-6 py-4">
<Heading>{t("customers.general.title")}</Heading>
<div className="flex items-center gap-x-2">
<StatusBadge {...statusProps}>{statusText}</StatusBadge>
<ActionMenu groups={[...]} />
</div>
</div>
{/* rows, each px-6 py-4; label/value rows use SectionRow */}
</Container>
- Do:
className="divide-y p-0"; header rowflex items-center justify-between px-6 py-4;<Heading>on the left; status badge +ActionMenuon the right. - Don't: a
Containerfor a section withoutp-0(you'll get default padding and misaligned rows); raw<h2>/<h3>instead of<Heading>; hand-built dropdowns instead ofActionMenu.
Modals do X
Create =
RouteFocusModalhost +TabbedForm. The page'sRootopens the modal on mount and renders defaults unless children are passed:const Root = ({ children }) => ( <RouteFocusModal> <RouteFocusModal.Title asChild><span className="sr-only">{t("...")}</span></RouteFocusModal.Title> {Children.count(children) > 0 ? children : <CreateXForm />} </RouteFocusModal> )Each tab is a component whose
RootcarriesRoot._tabMeta = defineTabMeta<Schema>({ id, labelKey, validationFields }). Tab body:flex flex-col items-center p-16→ innerflex w-full max-w-[720px] flex-col gap-y-8.Edit =
RouteDrawerhost +RouteDrawer.Form+KeyboundForm:<RouteDrawer> <RouteDrawer.Header> <RouteDrawer.Title asChild><Heading>{t("domain.edit.header")}</Heading></RouteDrawer.Title> <RouteDrawer.Description className="sr-only">{t("domain.edit.description")}</RouteDrawer.Description> </RouteDrawer.Header> {ready && <EditXForm entity={entity} />} {/* ready = !isPending && !!entity */} </RouteDrawer>Drawer body:
flex flex-col gap-y-4. Footer: secondary Cancel (RouteDrawer.Close) + primary Save (isLoading={isPending}). Close/redirect viauseRouteModal().handleSuccess().Don't: render raw
FocusModal/Drawerfrom@medusajs/uifor a page create/edit surface; nest a raw modal inside another (useStackedFocusModal/StackedDrawer).
Forms do X
- Every field:
Form.Field→Form.Item→Form.Label/Form.Control/Form.ErrorMessage. Help text viaForm.Hint. Never render error text by hand (Form.ErrorMessagereads RHF). - React Hook Form +
zodResolver(schema); infer type withz.infer. One schema per form. - Wrap the
<form>inKeyboundFormso Cmd/Ctrl+Enter submits. - Selects: destructure
{ ref, onChange, ...field }, passonValueChange={onChange}anddir={useDocumentDirection()}. - Nullable/optional values go through
transformNullableFormData/transformNullableFormNumberbefore the mutation. - Don't: raw
<input>/<textarea>/<select>; react-hook-form<Controller>directly. Use the primitives incomponents.md. (Rare justified exceptions — data-grid cells, custom comboboxes — exist in the codebase, but new page code should not need them.)
Destructive actions do Y
Extract to a hook pages/<domain>/common/hooks/use-delete-<entity>-action.tsx:
usePrompt()(@medusajs/ui) with i18ntitle/description/confirmText/cancelText.- Await confirmation → call the mutation.
toast.success/toast.error.- Navigate back on success.
Place the delete action last, in its own ActionMenu group (edit/navigation actions first). Don't inline a confirmation modal.
Compound-component export shape
Every page exports a Root assembled with named parts, so downstream code can override slots:
export const CategoryListPage = Object.assign(Root, {
Header: CategoryListHeader,
HeaderTitle: CategoryListTitle,
HeaderActions: CategoryListActions,
DataTable: CategoryListDataTable,
})
Root uses Children.count(children) > 0 ? children : <DefaultContent /> so it renders defaults when used as-is but exposes every part.
Data fetching
- All HTTP via the typed SDK (
sdk.admin.*/sdk.vendor.*) inhooks/api/<domain>.tsx. Never callfetchfrom a page. - One hook file per domain:
useX(detail),useXList(list),useCreate/Update/DeleteX(mutations). Build keys withqueryKeysFactory("x"). - Mutations invalidate
lists()/details()/detail(id)and forwardonSuccess. - Detail pages seed with a
loader.ts→initialData. Throw onisError(if (isError) throw error) soErrorBoundarycatches it. UseSkeleton/TwoColumnPageSkeletonwhile loading.
Tables
DataTable + useDataTable, page size 20, keepPreviousData. Build columns with createColumnHelper<Row>() + an actions display column rendering ActionMenu. Row navigation via navigateTo={(row) => row.id}. Empty states: NoResults (filtered) / NoRecords (no data).
Internationalization
- Every visible string via
useTranslation()/t(key). No literal UI strings. - Add keys to
packages/<pkg>/src/i18n/translations/en.jsonfirst (English is canonical). Common namespaces:actions.*,fields.*,general.*,<domain>.domain(sidebar),<domain>.<verb>.header|hint|successToast|description.
Test ids
Every interactive element (buttons, inputs, selects, action menus, headings, sections, modals) carries a kebab-case data-testid scoped to the page/section, e.g. customer-general-section-header, create-customer-form-first-name-input.
Do-not list (quick scan)
- No component library other than
@medusajs/ui/@mercurjs/dashboard-shared. - No icon pack other than
@medusajs/icons. - No raw
<input>/<textarea>/<select>/<Controller>in forms. - No raw
FocusModal/Drawerfor page create/edit surfaces. - No hardcoded
#hex,rgb()/rgba(), or palette utilities (text-gray-*,bg-slate-*) — use Medusa UI tokens (spacing.md). - No arbitrary spacing values where the scale has one (
gap-y-3/4/8,px-6 py-4,p-16). - No literal UI strings — always
t(...).