0
# Types
1
2
Complete TypeScript definitions for configuration options, UI extension components, and Medusa entity integrations.
3
4
## Capabilities
5
6
### Plugin Configuration Types
7
8
Core configuration interfaces for plugin options and build settings.
9
10
```typescript { .api }
11
/**
12
* Plugin configuration options extending AdminOptions
13
*/
14
interface PluginOptions extends AdminOptions {
15
/** Whether to serve the admin dashboard */
16
serve?: boolean;
17
/**
18
* Re-build admin automatically when options change since last server start
19
* Memory intensive process - use carefully in production
20
* Only used if serve is true
21
*/
22
autoRebuild?: boolean;
23
}
24
25
/**
26
* Build command configuration options
27
*/
28
interface BuildOptions extends AdminOptions {
29
/** Build for deployment to external host */
30
deployment?: boolean;
31
}
32
33
/**
34
* Base admin options interface from @medusajs/admin-ui
35
*/
36
interface AdminOptions {
37
/** Path to serve admin dashboard on (cannot be "admin" or "store") */
38
path?: string;
39
/** Output directory for build files */
40
outDir?: string;
41
/** Backend URL for API calls */
42
backend?: string;
43
/** Development server configuration */
44
develop?: DevelopmentOptions;
45
}
46
47
/**
48
* Development server configuration
49
*/
50
interface DevelopmentOptions {
51
/** Port for development server */
52
port?: number;
53
/** Host for development server */
54
host?: string;
55
/** Auto-open browser on start */
56
open?: boolean;
57
/** Allowed hosts configuration */
58
allowedHosts?: string;
59
/** WebSocket URL for hot reload */
60
webSocketURL?: string;
61
}
62
```
63
64
### UI Extension Types
65
66
Type definitions for creating custom admin UI extensions (re-exported from @medusajs/admin-ui).
67
68
```typescript { .api }
69
/**
70
* Route configuration for custom admin pages
71
*/
72
interface RouteConfig {
73
// Re-exported from @medusajs/admin-ui
74
// Specific properties not available in source inspection
75
}
76
77
/**
78
* Props interface for route components
79
*/
80
interface RouteProps {
81
// Re-exported from @medusajs/admin-ui
82
// Specific properties not available in source inspection
83
}
84
85
/**
86
* Settings page configuration
87
*/
88
interface SettingConfig {
89
// Re-exported from @medusajs/admin-ui
90
// Specific properties not available in source inspection
91
}
92
93
/**
94
* Props interface for settings components
95
*/
96
interface SettingProps {
97
// Re-exported from @medusajs/admin-ui
98
// Specific properties not available in source inspection
99
}
100
101
/**
102
* Widget configuration for embedding in admin pages
103
*/
104
interface WidgetConfig {
105
// Re-exported from @medusajs/admin-ui
106
// Specific properties not available in source inspection
107
}
108
109
/**
110
* Base props interface for widget components
111
*/
112
interface WidgetProps {
113
// Re-exported from @medusajs/admin-ui
114
// Specific properties not available in source inspection
115
}
116
```
117
118
### Entity-Specific Widget Props
119
120
Specialized widget props interfaces for different Medusa entities, extending the base WidgetProps.
121
122
```typescript { .api }
123
/**
124
* Props for widgets on product detail pages
125
*/
126
interface ProductDetailsWidgetProps extends WidgetProps {
127
/** The product being viewed */
128
product: Product;
129
}
130
131
/**
132
* Props for widgets on product collection detail pages
133
*/
134
interface ProductCollectionDetailsWidgetProps extends WidgetProps {
135
/** The product collection being viewed */
136
productCollection: ProductCollection;
137
}
138
139
/**
140
* Props for widgets on order detail pages
141
*/
142
interface OrderDetailsWidgetProps extends WidgetProps {
143
/** The order being viewed */
144
order: Order;
145
}
146
147
/**
148
* Props for widgets on draft order detail pages
149
*/
150
interface DraftOrderDetailsWidgetProps extends WidgetProps {
151
/** The draft order being viewed */
152
draftOrder: DraftOrder;
153
}
154
155
/**
156
* Props for widgets on discount detail pages
157
*/
158
interface DiscountDetailsWidgetProps extends WidgetProps {
159
/** The discount being viewed */
160
discount: Discount;
161
}
162
163
/**
164
* Props for widgets on price list detail pages
165
*/
166
interface PriceListDetailsWidgetProps extends WidgetProps {
167
/** The price list being viewed */
168
priceList: PriceList;
169
}
170
171
/**
172
* Props for widgets on gift card detail pages (product-based)
173
*/
174
interface GiftCardDetailsWidgetProps extends WidgetProps {
175
/** The gift card product being viewed */
176
giftCard: Product;
177
}
178
179
/**
180
* Props for widgets on custom gift card pages
181
*/
182
interface CustomGiftCardWidgetProps extends WidgetProps {
183
/** The custom gift card being viewed */
184
giftCard: GiftCard;
185
}
186
187
/**
188
* Props for widgets on customer detail pages
189
*/
190
interface CustomerDetailsWidgetProps extends WidgetProps {
191
/** The customer being viewed */
192
customer: Customer;
193
}
194
195
/**
196
* Props for widgets on customer group detail pages
197
*/
198
interface CustomerGroupDetailsWidgetProps extends WidgetProps {
199
/** The customer group being viewed */
200
customerGroup: CustomerGroup;
201
}
202
```
203
204
### Medusa Entity Types
205
206
Core Medusa entity types used in widget props (imported from @medusajs/medusa).
207
208
```typescript { .api }
209
/**
210
* Product entity from Medusa
211
* Imported from @medusajs/medusa
212
*/
213
interface Product {
214
// Complete Product interface definition available in @medusajs/medusa
215
id: string;
216
title: string;
217
// ... additional properties
218
}
219
220
/**
221
* Product collection entity from Medusa
222
* Imported from @medusajs/medusa
223
*/
224
interface ProductCollection {
225
// Complete ProductCollection interface definition available in @medusajs/medusa
226
id: string;
227
title: string;
228
// ... additional properties
229
}
230
231
/**
232
* Order entity from Medusa
233
* Imported from @medusajs/medusa
234
*/
235
interface Order {
236
// Complete Order interface definition available in @medusajs/medusa
237
id: string;
238
status: string;
239
// ... additional properties
240
}
241
242
/**
243
* Draft order entity from Medusa
244
* Imported from @medusajs/medusa
245
*/
246
interface DraftOrder {
247
// Complete DraftOrder interface definition available in @medusajs/medusa
248
id: string;
249
status: string;
250
// ... additional properties
251
}
252
253
/**
254
* Discount entity from Medusa
255
* Imported from @medusajs/medusa
256
*/
257
interface Discount {
258
// Complete Discount interface definition available in @medusajs/medusa
259
id: string;
260
code: string;
261
// ... additional properties
262
}
263
264
/**
265
* Price list entity from Medusa
266
* Imported from @medusajs/medusa
267
*/
268
interface PriceList {
269
// Complete PriceList interface definition available in @medusajs/medusa
270
id: string;
271
name: string;
272
// ... additional properties
273
}
274
275
/**
276
* Gift card entity from Medusa
277
* Imported from @medusajs/medusa
278
*/
279
interface GiftCard {
280
// Complete GiftCard interface definition available in @medusajs/medusa
281
id: string;
282
code: string;
283
// ... additional properties
284
}
285
286
/**
287
* Customer entity from Medusa
288
* Imported from @medusajs/medusa
289
*/
290
interface Customer {
291
// Complete Customer interface definition available in @medusajs/medusa
292
id: string;
293
email: string;
294
// ... additional properties
295
}
296
297
/**
298
* Customer group entity from Medusa
299
* Imported from @medusajs/medusa
300
*/
301
interface CustomerGroup {
302
// Complete CustomerGroup interface definition available in @medusajs/medusa
303
id: string;
304
name: string;
305
// ... additional properties
306
}
307
```
308
309
## Usage Examples
310
311
### Plugin Configuration with Types
312
313
```typescript
314
import type { PluginOptions } from "@medusajs/admin";
315
316
const adminConfig: PluginOptions = {
317
serve: true,
318
path: "/admin",
319
autoRebuild: false,
320
outDir: "build",
321
backend: "/",
322
develop: {
323
port: 7001,
324
host: "localhost",
325
open: true,
326
allowedHosts: "auto"
327
}
328
};
329
```
330
331
### Widget Implementation with Types
332
333
```typescript
334
import type { ProductDetailsWidgetProps } from "@medusajs/admin";
335
336
const ProductAnalyticsWidget = ({ product }: ProductDetailsWidgetProps) => {
337
return (
338
<div>
339
<h3>Analytics for {product.title}</h3>
340
{/* Widget implementation */}
341
</div>
342
);
343
};
344
345
// Widget configuration
346
export const config = {
347
zone: "product.details.after"
348
};
349
```
350
351
### Route Implementation with Types
352
353
```typescript
354
import type { RouteProps } from "@medusajs/admin";
355
356
const CustomReportsPage = (props: RouteProps) => {
357
return (
358
<div>
359
<h1>Custom Reports</h1>
360
{/* Route implementation */}
361
</div>
362
);
363
};
364
365
// Route configuration
366
export const config = {
367
label: "Custom Reports"
368
};
369
```
370
371
## Type Imports
372
373
All types are available from the main package:
374
375
```typescript
376
import type {
377
PluginOptions,
378
BuildOptions,
379
RouteConfig,
380
RouteProps,
381
SettingConfig,
382
SettingProps,
383
WidgetConfig,
384
WidgetProps,
385
ProductDetailsWidgetProps,
386
OrderDetailsWidgetProps,
387
CustomerDetailsWidgetProps
388
// ... other widget prop types
389
} from "@medusajs/admin";
390
```
391
392
## Default Values
393
394
### Plugin Options Defaults
395
- `serve`: `true`
396
- `autoRebuild`: `false`
397
- `path`: `"/app"`
398
- `outDir`: `"build"`
399
- `backend`: `"/"`
400
401
### Development Options Defaults
402
- `port`: `7001`
403
- `host`: `"localhost"`
404
- `open`: `true`
405
- `allowedHosts`: `"auto"`