Skip to content
RNUEReact Native for Unreal Engine

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

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

  1. 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.

  2. Generate the boilerplate

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

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

  4. Implement the native service

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

  5. 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.