Skip to content
Lucent
SEARCH LUCENT

Search guides, APIs, and examples.

GitHub

Very early and experimental. The language, the generated native code and every package API change without notice. Do not use Lucent in production.

Three places your code runs

Your code runs in the JS app, crosses the boundary, and runs natively. Values are copied across; class instances, functions and promises keep what they are.

The three places your code runs, and what crosses between them1 · THE JS APPyour components and JS codeHermes, on the JS thread2 · THE BOUNDARYvalues are copiednumbers · strings · arrays · objectsinstances keep identityclass instances, by referencefunctions become callbacksretained until Lucent drops thempromises stay promisesin both directions3 · NATIVEyour module's C++ · the SDKsJS thread · Lucent thread · main thread
shapes.lucent.ts
export type Point = { x: number; y: number };
export function nudge(p: Point): Point {
p.x += 1;
return p;
}
export class Counter {
count = 0;
increment(): number {
return ++this.count;
}
}
ValueCrosses asSo
number, string, booleana copythe same value on the other side
arrays, object types, Record, Map, Set, Uint8Array, Datea copychanges on one side don't reach the other
class instancesa referencethe same object each time, with its identity
functionsa callbackLucent can call JavaScript back
promisesa promiseawait works in both directions
errorsan Errorwith its message and code

Copying is what makes the boundary safe: no JavaScript object is shared with native code. It is also what costs time, so large data should cross rarely.

SDK objects, such as a CLLocationManager, stay in native code. JavaScript never sees them.