Template Module
Quickstart template repository for creating custom Medusa modules.
Zero Development maintains an official starter template at github.com/zerodev-ca/Medusa-Template. The template includes complete implementations of every Medusa subsystem, preconfigured translation files for all 16 supported languages, audit logging, database models, Discord commands, and custom dashboard pages.
Cloning the Template
To begin creating a new module, clone the repository directly into your Medusa modules/ directory or as an isolated git worktree:
git clone https://github.com/zerodev-ca/Medusa-Template modules/my-module
cd modules/my-moduleIf you manage your module as an isolated git branch in the Medusa workspace:
git worktree add modules/my-module -b module/my-moduleRenaming the Module
Update the module identifier in the following files:
-
main.js: Update thenameproperty passed tosuper()to match your folder name in lowercase:modules/my-module/main.js super(medusa, { name: "my-module", author: "Your Organization", version: "1.0.0.0", description: "Custom module built from the Medusa template." }); -
resources/lang/en/common.json(and all 15 other languages): Update the display name key:{ "module.my-module.name": "My Module" }
Directory Structure
The starter template includes the following pre-built files:
modules/my-module/
├── main.js
├── README.md
├── resources/
│ ├── config/
│ │ └── settings.js
│ ├── dashboard/
│ │ ├── pages/
│ │ │ └── template/
│ │ │ ├── page.js
│ │ │ ├── loader.ts
│ │ │ └── view.tsx
│ │ └── previews/
│ │ └── template.tsx
│ ├── docs/
│ │ └── index.md
│ ├── lang/
│ │ ├── de/
│ │ ├── en/
│ │ │ ├── common.json
│ │ │ └── messages.js
│ │ ├── es-ES/
│ │ ├── fr/
│ │ ├── it/
│ │ ├── ja/
│ │ ├── ko/
│ │ ├── nl/
│ │ ├── pl/
│ │ ├── pt-BR/
│ │ ├── ru/
│ │ ├── sv-SE/
│ │ ├── tr/
│ │ ├── uk/
│ │ ├── zh-CN/
│ │ ├── zh-TW/
│ │ └── translations.json
│ ├── leaderboards/
│ │ └── activity.js
│ ├── logs/
│ │ └── templateEvents.js
│ └── nodes/
│ └── sendNotification.js
└── src/
├── clocks/
│ └── cleanup.js
├── commands/
│ └── template.js
├── events/
│ ├── messageCreate.js
│ └── interactionCreate.js
├── handlers/
│ └── Items.js
├── models/
│ └── Item.js
└── routes/
└── items/
└── route.jsDevelopment Workflow
- Database Schema: Define your database columns in
src/models/. When Medusa boots, it automatically alters database tables to match your schema. - Business Logic: Write reusable methods in
src/handlers/. Usethis.fail(statusCode, message)to bubble errors cleanly up to routes or command responses. - Discord Commands & Components: Expose user interactions in
src/commands/. Send interactive buttons, select menus, and modals using Discord.js builders withmedusa:<component>:<module>:<name>:<describer>custom IDs. - Gateway Interactions: Handle button clicks, dropdown selections, and modal submissions in
src/events/interactionCreate.js. - Dashboard Forms & Previews: Declare settings inputs in
resources/config/across all 15 field types, and attach live interactive preview components inresources/dashboard/previews/. - Custom Dashboard Views: Provide bespoke management pages in
resources/dashboard/pages/utilizing built-in Mantine/Tailwind UI components (Button,Select,Input,Switch,Badge,Card,Modal). - Localization: Define keys in
resources/lang/en/messages.jsand provide localized versions inresources/lang/translations.json.
Restart Medusa to compile and load your changes.

