Skip to main content
A widget is a React component that renders in a named slot on a built-in page. Use a widget to show extra information or an action next to the data a page already displays, such as a payout summary on the order detail page. You add a widget by dropping a file into a panel’s src/widgets/ folder. The SDK finds it at build time. There is no manifest to edit and no route to register.

Create a widget

1

Add a widget file

Create a file anywhere under src/widgets/ in the panel you want to extend. The file name is up to you.
apps/vendor/src/widgets/product-list-banner.tsx
2

Target a zone with `defineWidgetConfig`

Export a config that names the zone to render in. The last segment of the zone id, before or after, sets the placement.
apps/vendor/src/widgets/product-list-banner.tsx
Zone ids are typed. A zone that does not exist fails tsc (bun run lint), so you cannot target a page that has no slot. See Available zones for the full list.
3

Run the panel

Start the panel and open the page you targeted. The widget renders in its zone.
Terminal
The vendor panel runs on http://localhost:7001 and the admin panel on http://localhost:7000.

Configuration

defineWidgetConfig takes one object.

Component props

The widget component receives a single prop.
The public login.logo, login.before, and login.after zones render before authentication and receive no data.

Zone ids

A zone id reads <domain>.<view>.<placement>.
  • Domain is the page family, such as product, orders, or customers.
  • View is the surface within that family: list for a list page, or detail.main and detail.side for the two columns of a detail page.
  • Placement is before or after. It is the last segment and decides whether the widget renders above or below the target.
Each surface in the tables below expands to two zone ids. The product detail main column, for example, gives you product.detail.main.before and product.detail.main.after.

Vendor zones

Widgets in @mercurjs/vendor (apps/vendor) can target these surfaces. Each cell expands to a .before and an .after zone.

Vendor public and setup zones

These sit outside the list and detail shape. The login.* zones render before authentication and receive no data.

Admin zones

Widgets in @mercurjs/admin (apps/admin-test) can target these surfaces. Each cell expands to a .before and an .after zone.
Admin splits the product list and product detail across two domains. List zones are products.list.* (plural) and detail zones are product.detail.* (singular). Vendor uses product for both. Detail-page reservation zones are reservation.* (singular) in admin and reservations.* (plural) in vendor. Follow the tables above rather than guessing the pluralization.

Next steps

Custom Fields

Add fields, section rows, and list columns to a built-in model.

Create a new page

Add a route with file-based routing and register it in the sidebar.