Docs
Developer Documentation

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-module

If you manage your module as an isolated git branch in the Medusa workspace:

git worktree add modules/my-module -b module/my-module

Renaming the Module

Update the module identifier in the following files:

  1. main.js: Update the name property passed to super() 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."
    });
  2. 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.js

Development Workflow

  1. Database Schema: Define your database columns in src/models/. When Medusa boots, it automatically alters database tables to match your schema.
  2. Business Logic: Write reusable methods in src/handlers/. Use this.fail(statusCode, message) to bubble errors cleanly up to routes or command responses.
  3. Discord Commands & Components: Expose user interactions in src/commands/. Send interactive buttons, select menus, and modals using Discord.js builders with medusa:<component>:<module>:<name>:<describer> custom IDs.
  4. Gateway Interactions: Handle button clicks, dropdown selections, and modal submissions in src/events/interactionCreate.js.
  5. Dashboard Forms & Previews: Declare settings inputs in resources/config/ across all 15 field types, and attach live interactive preview components in resources/dashboard/previews/.
  6. 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).
  7. Localization: Define keys in resources/lang/en/messages.js and provide localized versions in resources/lang/translations.json.

Restart Medusa to compile and load your changes.

On this page