-
Notifications
You must be signed in to change notification settings - Fork 0
Export Functions
s edited this page Aug 1, 2026
·
3 revisions
The generator finds marked Kotlin/Java methods or C++ functions and creates the bridge and TypeScript declaration for each export.
By default, JavaScript uses the source function name. Override it when needed:
@SupernoteExport(name = "greet")
fun makeGreeting(name: String): String = "Hello, $name"// @SupernoteExport(name = "greet")
std::string makeGreeting(std::string name) {
return "Hello, " + name;
}Export names must be unique and JavaScript-safe.
Use the annotation generated for the module:
import com.example.math.nativemodule.annotation.SupernoteExport
class Example {
@SupernoteExport
fun add(left: Double, right: Double): Double = left + right
}- public instance methods on concrete public classes;
- public constructors taking
ReactApplicationContext, AndroidContext, or no arguments; - unique export names;
- the supported types in the table below.
- suspend, inline, operator, or static methods;
- generics, extension methods, or varargs;
- nullable values, collections, arrays, callbacks, and arbitrary objects;
- unsupported constructors or value types.
| Kotlin/Java type | TypeScript | Call behavior |
|---|---|---|
Boolean / boolean
|
boolean |
Promise when returned |
Double / double
|
number |
Promise when returned |
String |
string |
Promise when returned |
Unit / void return |
void |
Call without await
|
Place the marker immediately before a top-level definition:
// @SupernoteExport
double add(double left, double right) {
return left + right;
}- top-level definitions in
.cc,.cpp, or.cxx; -
bool,double, and UTF-8std::stringby value; -
voidreturns andnoexcept; - explicitly named parameters;
- an optional export-name override.
- overloads, namespaces, or templates;
- pointers or references;
- variadic or default arguments;
-
static,inline,constexpr, orextern "C"exports; - decorated signatures or export markers in
.cfiles.
C files compile as C23 and may provide helpers. C++ and generated bindings compile as C++23. Generated JNI code transports strings as UTF-8 byte arrays, not JNI modified UTF-8.
| Backend | Returned value | Example |
|---|---|---|
| Native | Promise | const total = await Math.add(20, 22); |
| JNI | Promise | const total = await MathJni.add(20, 22); |
| JSI | Synchronous | const total = MathJsi.add(20, 22); |
For editable and replaceable files, see Files the Generator Creates.