0
# @medusajs/admin
1
2
@medusajs/admin is a TypeScript-based plugin for the Medusa e-commerce platform that provides a comprehensive admin dashboard for managing online stores. It serves as both a build tool and runtime server component, enabling merchants to manage products, orders, customers, and store configuration through a web interface.
3
4
## Package Information
5
6
- **Package Name**: @medusajs/admin
7
- **Package Type**: npm
8
- **Language**: TypeScript
9
- **Installation**: `npm install @medusajs/admin` or `yarn add @medusajs/admin`
10
11
## Core Imports
12
13
```typescript
14
import { withCustomWebpackConfig, PluginOptions } from "@medusajs/admin";
15
```
16
17
For CommonJS:
18
19
```javascript
20
const { withCustomWebpackConfig } = require("@medusajs/admin");
21
```
22
23
## Basic Usage
24
25
The package is primarily used as a Medusa plugin in `medusa-config.js`:
26
27
```javascript
28
module.exports = {
29
plugins: [
30
{
31
resolve: "@medusajs/admin",
32
options: {
33
serve: true,
34
path: "/app",
35
autoRebuild: false,
36
outDir: "build"
37
}
38
}
39
]
40
};
41
```
42
43
## Architecture
44
45
@medusajs/admin is built around several key components:
46
47
- **Plugin System**: Integrates with Medusa's plugin architecture providing admin routes and UI serving
48
- **CLI Tools**: Command-line interface for building, developing, and bundling admin extensions
49
- **Build Pipeline**: TypeScript compilation, Rollup bundling, and asset management for production deployments
50
- **Extension Framework**: Support for custom routes, widgets, and settings that extend the admin interface
51
- **Development Server**: Hot-reload development environment with webpack integration
52
53
## Capabilities
54
55
### Plugin Integration
56
57
Core plugin functionality for integrating with Medusa server instances. Provides Express routes and static file serving for the admin dashboard.
58
59
```typescript { .api }
60
export function withCustomWebpackConfig(): any;
61
62
export interface PluginOptions extends AdminOptions {
63
/** Whether to serve the admin dashboard */
64
serve?: boolean;
65
/** Auto rebuild when options change (memory intensive) */
66
autoRebuild?: boolean;
67
}
68
```
69
70
[Plugin Integration](./plugin-integration.md)
71
72
### CLI Commands
73
74
Command-line tools for building, developing, and bundling the admin dashboard and extensions.
75
76
```typescript { .api }
77
interface BuildOptions extends AdminOptions {
78
deployment?: boolean;
79
}
80
81
interface DevelopArgs extends AdminOptions {
82
port: number;
83
}
84
```
85
86
Available commands:
87
- `medusa-admin build` - Build admin dashboard for production
88
- `medusa-admin develop` - Start development server
89
- `medusa-admin bundle` - Bundle admin extensions
90
91
[CLI Commands](./cli-commands.md)
92
93
### Type Definitions
94
95
Complete TypeScript definitions for configuration options, UI extension components, and Medusa entity integrations.
96
97
```typescript { .api }
98
export interface PluginOptions extends AdminOptions {
99
serve?: boolean;
100
autoRebuild?: boolean;
101
}
102
103
export interface RouteConfig {
104
// Re-exported from @medusajs/admin-ui
105
}
106
107
export interface WidgetConfig {
108
// Re-exported from @medusajs/admin-ui
109
}
110
```
111
112
[Types](./types.md)
113
114
## Global Types
115
116
```typescript { .api }
117
interface AdminOptions {
118
/** Path to serve admin dashboard on */
119
path?: string;
120
/** Output directory for build files */
121
outDir?: string;
122
/** Backend URL for API calls */
123
backend?: string;
124
/** Development server options */
125
develop?: {
126
port?: number;
127
host?: string;
128
open?: boolean;
129
allowedHosts?: string;
130
webSocketURL?: string;
131
};
132
}
133
```