Creating a Custom Module for MagicMirror

MagicMirror is a versatile open-source application used to develop a smart mirror interface, named as MagicMirror². Among its many features, the opportunity to create a custom module stands out. This functionality allows developers to personalize

Written by: Sophia Martin

Published on: March 14, 2026

MagicMirror is a versatile open-source application used to develop a smart mirror interface, named as MagicMirror². Among its many features, the opportunity to create a custom module stands out. This functionality allows developers to personalize their smart mirror project based on individual requirements or preferences.

Understanding the Basics of a Custom MagicMirror Module

Creating a custom MagicMirror module requires at least fundamental knowledge of JavaScript, CSS, and Node.js, the core technologies used in MagicMirror². It would also be helpful if you were familiar with ES6, the version of ECMAScript corresponding to JavaScript, as it will make your coding experience much smoother.

Each MagicMirror module is essentially a mini-application that carries out a specific function. Some modules are included in the default installation of MagicMirror², like those displaying the current time, weather, or news feeds. However, the real magic begins when you create your module to serve your unique needs.

Steps to Create a Custom MagicMirror Module

1. Create a Module Folder:

The first step in creating your custom module is to generate a new folder in the modules directory of your MagicMirror² installation. Name this folder corresponding to what your custom module will do. For a general guide, we will name our folder ‘MMM-MyCustomModule’.

2. Add Necessary Module Files:

Inside the ‘MMM-MyCustomModule’ folder, create two essential files: ‘MMM-MyCustomModule.js’ and ‘node_helper.js’. The ‘MMM-MyCustomModule.js’ file is the starting point of your module, serving as the interface between the MagicMirror² core application and your custom module. The ‘node_helper.js’ file is optional, used when your module requires background operations like API calls.

3. Write the Core Module Script:

Open the ‘MMM-MyCustomModule.js’ file and begin writing the core module script. At a bare minimum, your module script should include ‘Module.register()’ function that has the unique module name as a parameter, and an object detailing the module’s configuration.

Module.register("MMM-MyCustomModule", {

    defaults: {
        // Default values go here
    },

    start: function() {
        // This will be called when the module is constructed.
    },

    getDom: function() {
        // This method generates the module’s user interface.
    },

});

4. Implement the ‘start’ function:

In the ‘start’ function, you can set up the environment your module requires to run successfully. You could initiate API calls here, or set up any variables your module needs.

5. Define the ‘getDom’ function:

The ‘getDom’ function helps generate your module’s user interface. By creating the function, you can interact with the Magic Mirror interface and display the real data to the user.

6. Leverage ‘node_helper.js’:

For operations that need to run in the background, utilize the ‘node_helper.js’ file. This file will be used for server-side requests. It should include NodeHelper.create(), which effectively sets up an environment for your helper functions to run.

7. Configure the Module:

Once you’ve written and debugged your custom MagicMirror module, it’s time to add it to the MagicMirror² configuration file ‘config/config.js’. Add your module’s configuration in the format specified by MagicMirror²:

{
    module: "MMM-MyCustomModule",
    position: "top_right", // This can any of the regions.
    config: {
        // The configuration object
    }
}

8. Run Your Custom Module:

Finally, it’s time to check your custom module in action. Start MagicMirror² and see how your module appears on the screen. Debug any issues and read the MagicMirror logs for more details on errors or problems with your script.

Tips For Creating A Successful Custom Module

  1. Ensure Code Quality: Always follow good coding practices and standards. Write well-documented, maintainable, and scalable code.

  2. Test Regularly: Regularly check your module during development to catch and rectify any errors early in the development phase.

  3. Keep Sync with Upstream: Always be in sync with the original MagicMirror repository to ensure compatibility with the latest updates and changes.

MagicMirror²’s custom module creation allows the mirror to align perfectly with the user’s needs. With focused research, understanding of JavaScript and Node.js, and regular practice, creating a powerful and fully customized MagicMirror module is definitely achievable.

Leave a Comment

Previous

Creating a Custom Module for MagicMirror

Next

Smart Mirror with Personal To-Do List