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.

Port a TurboModule or Nitro module

The spec becomes the module's exports, hybrid objects become classes, and codegen goes away.

TurboModule or NitroLucent
the spec: NativeX.ts, or a Nitro .nitro.ts interfacethe module's exports: its functions, types and classes
codegen, or Nitrogennone: lucent build compiles the module
Objective-C++, Swift, Kotlin or C++ implementationsone .lucent.ts file, with a branch per platform
a Nitro hybrid objectan exported class: its instances cross by reference
Promise<T> methodsasync exports; they run on the Lucent thread
events through RCTEventEmitter or listenersa callback parameter and a stop function
ArrayBufferUint8Array, copied
the library's podspec and Gradle filelucent.json, if the module needs pods, dependencies or permissions
counter.lucent.ts
/** A Nitro hybrid object becomes a class: JavaScript holds one native instance. */
export class Counter {
private value = 0;
increment(by: number): number {
this.value += by;
return this.value;
}
async reset(): Promise<void> {
this.value = 0;
}
}
App.tsx
import { Counter } from "./src/counter.lucent";
const counter = new Counter();
counter.increment(2); // 2

Values that Nitro passes without copying, such as large arrays, are copied here. Keep them in native code across calls, as Design the boundary first shows.