-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Supernote Module Generator adds native functionality to an existing Supernote plugin.
It does not create the plugin itself. This Wiki assumes that you already have a plugin that builds and runs, understand its basic project structure, and have read the official Supernote plugin documentation.
If you are comfortable writing JavaScript/TypeScript and find no issue getting your plugins to work the way you want them to, then you can stick with it. But if your plugin reaches a point where it needs to directly call Android APIs, integrate with an existing native library, or you simply want to make your code faster, this generator will help you deal with all the dull and messy boilerplate and help you get back to working on the code that actually matters for your project.
Adding native code to React Native normally requires you to write much more boilerplate than anyone should be subjected to. Depending on the module type, you may need Android library setup, React Native registration, Kotlin or Java bridge code, JNI bindings, CMake configuration, JSI installation code, package linking, and TypeScript declarations.
The generator creates all that stuff for you inside your plugin. All you have to do is choose the type and name of your module, then write the Kotlin, Java, C, or C++ code that belongs to your feature.
The generator does not:
- Create, package, install, or debug the Supernote plugin itself.
- Decide whether native code is actually faster for your workload.
- Make an Android API or third-party library compatible with the target device.
- Guarantee that a compiled JSI library can execute in the target PluginHost.
- Preserve manual changes made inside files that the generator owns.
| CLI type | You write | JavaScript call | Best fit |
|---|---|---|---|
Native Module (native) |
Kotlin or Java | Promise for returned values | Android APIs, Kotlin or Java libraries, and work that can be batched into a few larger calls |
Native JNI Module (jni) |
C or C++ | Promise for returned values | C or C++ processing that can be asynchronous and may still need normal Android integration |
JSI Module (jsi) |
C++ | Synchronous | Short, frequent operations that genuinely need to return directly to JavaScript |
Choose a Native Module when Kotlin or Java is the natural implementation, when the feature needs Android APIs, or when you want to use an Android or JVM library.
Returned values are exposed as Promises. The bridge has overhead, but it is often insignificant when each call performs a meaningful amount of work. Prefer one call that processes a stroke, page, or file over thousands of tiny calls.
Implement a Kotlin or Java module.
Choose a Native JNI Module when the implementation needs C or C++ but does not require JavaScript to receive the result synchronously.
JavaScript calls a normal Promise-based Native Module. The generated Kotlin and JNI code then connects that module to your C or C++ function. This is normally the safest middle ground for native libraries, lower-level processing, and C or C++ code that must exist alongside Android integration.
The generated Kotlin and JNI layers are managed glue, not the normal places for persistent custom Kotlin implementation. When a feature needs substantial user-owned Kotlin or Java code, use a separate Native Module for that part or be prepared to maintain manual changes to generated files.
Implement a Native JNI module.
Choose a JSI Module only when JavaScript genuinely needs a direct, synchronous C++ API.
JSI is useful for short operations that may be called frequently or must return immediately. It can also read files or perform large computations, but the function normally runs on the JavaScript thread, so JavaScript stays blocked until it returns.
A successful build does not prove runtime support. The target PluginHost, firmware, linker namespace, and SELinux policy must allow the generated library to load and execute.
- Adding your first module: Getting Started
- Understanding the menu and commands: Using the CLI
- Updating, validating, or removing a module: Managing Modules
- Recovering from an error: Troubleshooting
The Wiki follows the current default branch. The exact behavior and options available in your installed version are shown by:
supernote-module --version
supernote-module --help
supernote-module help add