Creating a Custom Module for MagicMirror

Getting started with Creating a Custom Module for MagicMirror MagicMirror is an incredibly functional and customizable open-source software that allows you to turn your computer into a smart mirror. The true power of MagicMirror lies

Written by: Sophia Martin

Published on: March 14, 2026

Getting started with Creating a Custom Module for MagicMirror

MagicMirror is an incredibly functional and customizable open-source software that allows you to turn your computer into a smart mirror. The true power of MagicMirror lies in its extensive module system. With the right set of modules installed, you can transform your mirror into an information hub, displaying data such as the weather, time, date, news headlines, among others. However, to fully leverage the potential of MagicMirror, you might need to create custom modules that fit your specific needs. This guide will take you through a detailed, step-by-step process of creating a custom module for MagicMirror.

Understanding MagicMirror Modules

Before beginning the creation process, it’s important to understand what a MagicMirror module is. Simply put, a module is an extension for the MagicMirror that adds a unique functionality or feature. Available modules range from basic features such as displaying the date and time, to more complex ones like integrating Google Fit data or displaying live train departure times.

In essence, a MagicMirror module is a Node.js application, structured in a certain way. With some basic knowledge of JavaScript and the Node.js environment, you can create your own custom module. The Node.js basis of MagicMirror modules means that they are non-blocking and run asynchronously – ensuring smooth operation of the mirror even when a module takes longer than expected to fulfill its function.

Setting up the Development Environment

Before you start coding your custom module, you have to set up the development environment. This step involves installing the MagicMirror software on your computer and having a text editor that supports JavaScript, HTML, and CSS. The MagicMirror’s setup guide gives a detailed step-by-step walkthrough on how to install the software on your computer. Thereafter, you can use text editors like Visual Studio Code, Atom, or Brackets for your coding.

Creating the Module’s Directory and Files

Each module in MagicMirror resides in its own specifically named directory inside the modules folder of the MagicMirror installation. To create a new module, start by making a new directory inside the modules directory using your module’s name.

Inside your custom module’s directory, you will need two files: the module’s JavaScript file and the node helper file. The main JavaScript file should have the same name as your module’s directory, while the Node helper file should be named node_helper.js.

Creating the Main Module File

The main module file is where most of the module’s functionality resides. It starts with a definition of the module and its defaults. MagicMirror uses the Node.js module.exports pattern to define modules. Essentially, a JavaScript object is assigned to module.exports and this object represents your custom module.

The module’s defaults are set in the getDefaults method. This method returns an object with each property corresponding to a configuration option for your module. It features critical components including start, getDom, getStyles, getScripts, getTranslations, socketNotificationReceived, among others.

Creating the Node Helper File

The node_helper.js file is optional in a module but it handles operations that don’t involve interacting with the user interface. It’s especially useful when you need to perform server-side operations like API requests. For example, if you’re building a module that retrieves data from a REST API or a database, you can delegate this task to the node helper. Just like the main module file, the node helper file uses the module.exports pattern to define its exported object.

Your node_helper.js file will have methods including start, socketNotificationReceived, and sendSocketNotification that aid in functions such as module start-up, communication with the main module file, among others.

Testing Your Custom Module

Once you’ve set up your module files, save and exit your text editor. Then, you must add your module to the MagicMirror configuration. This action is done within the main MagicMirror configuration file, config.js, located in the ‘config’ directory.

After successfully adding your module, run the MagicMirror software on your development computer. If your module functions as expected, congratulations – you’ve created a MagicMirror custom module!

Enhancing Your Custom Module

Creating your own custom module doesn’t stop at getting it to perform its basic functions. Always seek to improve it by adding new features or making it more efficient. You can also add localization support, to make your module more accessible for users of different languages.

Remember, creativity births innovation. As you get more comfortable with creating MagicMirror modules, you might come up with unique ideas that transform the way MagicMirror is used!

In Conclusion,

Creating a custom module for MagicMirror requires basic knowledge of JavaScript and Node.js. The process involves setting up your development environment, creating your module’s directory and files, and adding functionality to the main module file and a node helper file. After creating your custom module, you should test it thoroughly to ensure it functions as expected. And remember, the best MagicMirror modules are not just functional, but also creative and innovative!

Creating and using custom modules is an exciting way to enhance your MagicMirror user experience. Whether you are building a module for personal use or for the MagicMirror community, the key is to keep learning, experimenting, and innovating. Enjoy the process and happy coding!

Leave a Comment

Previous

Boot Setup Simplified for Raspberry Pi Smart Mirrors

Next

Creating a Custom Module for MagicMirror