1 ---
2 sidebar_label: "widget-must-export-config"
3 ---
4
5 export const metadata = {
6 title: `widget-must-export-config - ESLint plugin rules`,
7 }
8
9 # {metadata.title}
10
11 This rule requires widget files to export a named `config` initialized with `defineWidgetConfig`.
12
13 ## Severity
14
15 `error`. This rule is enabled in the [recommended](../../page.mdx#recommended) preset.
16
17 ## What it Targets
18
19 This rule targets files in your project's `src/admin/widgets` directory. It reports a widget file that's missing a named `config` export, or whose `config` export isn't initialized with `defineWidgetConfig`.
20
21 The following code is reported by the rule:
22
23 ```tsx title="src/admin/widgets/product-widget.tsx"
24 const MyWidget = () => <>Widget</>
25
26 export default MyWidget
27 ```
28
29 Instead, export a `config` initialized with `defineWidgetConfig`:
30
31 ```tsx title="src/admin/widgets/product-widget.tsx"
32 import { defineWidgetConfig } from "@medusajs/admin-sdk"
33
34 const MyWidget = () => <>Widget</>
35
36 export const config = defineWidgetConfig({
37 zone: "product.details",
38 })
39
40 export default MyWidget
41 ```
42
43 ## Why it's Important
44
45 The `config` export tells Medusa which zones a widget is injected into. Without it, Medusa can't register the widget in the admin dashboard.
46
47 Learn more in the [Admin Widgets documentation](!docs!/learn/fundamentals/admin/widgets).
48
49 ## Fixable
50
51 This rule isn't auto-fixable.