rnue
Bridging JS & C++

TurboModules

Using TurboModules to connect JavaScript to C++

It is recommended to read the React Native TurboModules documentation before diving into this section to understand the general principle of operation.

TurboModules are the way to connect JavaScript to C++ in a rnue project.

rnue TurboModulesC++JavaScriptTypeScript SpecDefines methodsevents and shareddata@rnue/codegenReads the spec andcreates the bridgeReact AppCalls methods andreceives eventsGenerated BridgeConnects React toUnrealUnreal ServiceImplements nativebehavior and ownsnative stateYour Unreal ProjectUses the nativeservicesource of truthstrong typescreatesdefines interfacetyped callsforwards callsnative callsOwnerYournue
rnue TurboModulesC++JavaScriptTypeScript SpecDefines methodsevents and shareddata@rnue/codegenReads the spec andcreates the bridgeReact AppCalls methods andreceives eventsGenerated BridgeConnects React toUnrealUnreal ServiceImplements nativebehavior and ownsnative stateYour Unreal ProjectUses the nativeservicesource of truthstrong typescreatesdefines interfacetyped callsforwards callsnative callsOwnerYournue

Below is a bird's eye view of the process of creating a TurboModule:

Create a TypeScript spec

The spec defines the methods, events and types for the module. Those will be used by the JavaScript and C++ sides when calling the implemented module.

Generate the boilerplate

This step is automatic and done by running @rnue/codegen.

This step is also automatic and done by running @rnue/cli.

Implement the native service

Now you can implement the functionality intended by the spec you supplied to the code generator.

Use the native service

You can now use the native service in your JavaScript code by importing the spec.

If you are ready to dive in, continue to the Building a TurboModule guide.