Skip to main content
Widgets are reusable UI components that can be injected into specific zones throughout the admin dashboard, allowing you to extend existing pages without modifying core code.

Overview

Widgets enable you to:
  • Add custom content to existing pages
  • Display additional information alongside core features
  • Integrate third-party services into the admin
  • Create reusable UI components across multiple pages

Creating a Widget

Basic Widget

Create a widget by defining a React component and specifying where it should appear:
1

Create Widget File

2

Define the Widget Component

3

Configure Injection Zone

The widget will automatically appear on all order detail pages, after the main content.

Widget Configuration

The defineWidgetConfig function accepts:

Multiple Zones

Inject a widget into multiple locations:

Injection Zones

Injection zones are specific locations in the admin where widgets can be inserted. They follow the pattern:

Available Zones

The full list of injection zones is defined in packages/admin/admin-shared/src/extensions/widgets/constants.ts:210:

Order Zones

Product Zones

Customer Zones

Other Entity Zones

See the complete list in the source code.

Data Access

Route Parameters

Access route parameters to fetch relevant data:

Medusa SDK

Fetch data from Medusa using the Admin SDK:

Styling Widgets

Using Design System

Leverage Medusa UI components for consistent styling:

Responsive Layout

Advanced Patterns

Conditional Rendering

Show widgets based on conditions:

Interactive Widgets

Create widgets with state and interactions:

Chart Widget

Integrate charts and visualizations:

Complete Example

Here’s a complete widget that displays product inventory across locations:

Best Practices

Each widget should have a single, clear purpose. Create multiple small widgets rather than one large complex widget.
Always show loading indicators while fetching data to prevent layout shifts.
Wrap widgets in <Container> from @medusajs/ui for consistent spacing and styling.
Use React Query for efficient data fetching and caching. Avoid expensive computations in render.
Choose injection zones carefully. Use .side zones for supplementary info and .before/.after for primary content.

Next Steps