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 Zone ids are typed. A zone that does not exist fails
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
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.The vendor panel runs on
Terminal
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, orcustomers. - View is the surface within that family:
listfor a list page, ordetail.mainanddetail.sidefor the two columns of a detail page. - Placement is
beforeorafter. It is the last segment and decides whether the widget renders above or below the target.
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. Thelogin.* 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.