In the previous guides, we learned how to write a basic JavaScript app using built-in functions. However, the set of built-in functions is limited, so when developing your JS apps, you'll likely want to use external JS modules. These modules offer a wide range of functions (methods) for various tasks.
For example:
serial
module enables transmitting and receiving data via a serial interfacebadusb
module enables USB keyboard emulation and sending key press events via USBmath
module provides mathematical functionsJS modules are written in C/C++, making them fast and efficient. They come with Flipper Zero firmware and are stored on the microSD card in compiled form as FAL (Flipper Application File) files.
Before using any of the JS module methods, you must import the module using the require()
function. This loads the module into RAM, allowing you to access its methods.
To save RAM and improve performance, avoid loading modules you don't plan to use. Also, all loaded modules will be automatically unloaded from RAM after the app execution ends.
To load a module, call the require()
function with the module name in quotes. For example, to load the notification
module, write this:
Now you can call methods of the notification
module using the notify
variable to access them:
Congratulations, you've completed the Getting Started section of our JS docs. You've learned how to run and debug JS apps, and how to use JS modules. Now, we invite you to check out the main JavaScript page where you'll find: