widget-must-have-default-export - ESLint plugin rules

This rule requires widget files to default-export the widget component.

Severity#

error. This rule is enabled in the recommended preset.

What it Targets#

This rule targets files in your project's src/admin/widgets directory. It reports a widget file that doesn't have a default export.

The following code is reported by the rule:

src/admin/widgets/product-widget.tsx
1import { defineWidgetConfig } from "@medusajs/admin-sdk"2
3const MyWidget = () => null4
5export const config = defineWidgetConfig({6  zone: "product.details",7})8
9export { MyWidget }

Instead, default-export the widget component:

src/admin/widgets/product-widget.tsx
1import { defineWidgetConfig } from "@medusajs/admin-sdk"2
3const MyWidget = () => null4
5export const config = defineWidgetConfig({6  zone: "product.details",7})8
9export default MyWidget

Why it's Important#

Medusa renders the default export of a widget file in the configured zones. Without a default export, the widget has no component to render.

Learn more in the Admin Widgets documentation.

Fixable#

This rule isn't auto-fixable.

Was this page helpful?
Ask Bloom
For assistance in your development, use Claude Code Plugins or Docs MCP server in Cursor, VSCode, etc...FAQ
What is Medusa?
How can I create a module?
How can I create a data model?
How do I create a workflow?
How can I extend a data model in the Product Module?
Recipes
How do I build a marketplace with Medusa?
How do I build digital products with Medusa?
How do I build subscription-based purchases with Medusa?
What other recipes are available in the Medusa documentation?
Chat is cleared on refresh
Line break
⇧↵