react

React Native Turbo Starter

React 0.68+ Turbo Module starter using codegen with typescript for Objective-C and Java/Kotlin with C++ shared library.

screenshot of React Native Turbo Starter

Overview

The React 0.68+ Turbo Module starter is a code generator for Objective-C and Java/Kotlin with a shared C++ library. It is designed for use with React Native version 0.68 and above. The starter includes features such as TurboModule, codegen with TypeScript, usage of arrays/dictionaries/promises, and native functionality. Note that this module does not offer backward compatibility and requires the new architecture enabled.

Features

  • React Native 0.68+: Compatible with React Native version 0.68 and above.
  • Upgraded react-native-create-library module to TurboModule: Utilizes the TurboModule feature.
  • Codegen with TypeScript: Generates code using TypeScript.
  • Objective-C using JSI without the bridge: Uses Objective-C with JavaScript Interface (JSI) without the bridge.
  • Java/Kotlin using JSI without the bridge: Uses Java/Kotlin with JSI without the bridge.
  • Shared C++ TurboModule: Includes a shared C++ TurboModule.
  • Array/Dictionaries/Promises usage: Supports usage of arrays, dictionaries, and promises.
  • Native usage (battery level): Allows for native functionality usage, such as getting the battery level.
  • M1 e2e Compilation of RN New Architecture: Supports compilation on M1 machines with the new architecture.

Installation

To install the React 0.68+ Turbo Module starter, follow the steps below:

  1. Running the example project:

iOS

  • Run RCT_NEW_ARCH_ENABLED=1 pod install in the example/ios folder.
  • Open the workspace by running xed ios in the terminal.
  • Navigate to Pods -> Development Pods -> react-native-turbo-starter -> ios -> TurboStarter.mm in the left side-bar of XCode.
  • Next to the @implementation, XCode will offer to complete the missing protocol for you. Alternatively, you can manually implement the new function in TurboStarter.mm.

Android

  • Run ./gradlew generateCodegenArtifactsFromSchema in the example/android folder.
  • Open Android Studio and navigate to android/src/main/java/com/reactnativeturbostarter/TurboStarterModule.kt.
  • Android Studio will offer to complete the missing new function for you. Alternatively, you can manually implement the new function in TurboStarterModule.kt.
  1. Adding new functionality:
  • For native functionality, open src/NativeTurboStarter.ts and add your function definition inside the Spec.
  • Export your new function by opening src/index.ts and wrapping it.
  • To test your new function, call it from App.tsx.
  1. C++ functionality:
  • Declare your C++ function in cpp/react-native-turbo-starter.h.
  • Implement your C++ function in cpp/react-native-turbo-starter.cpp.

Summary

The React 0.68+ Turbo Module starter is a powerful tool for developing React Native applications with advanced features. It allows for efficient code generation, compatibility with Objective-C and Java/Kotlin without the bridge, and usage of C++ for enhanced functionality. The installation process involves setting up the example project, adding new functionality in both native and C++ contexts, and running the project to test the code.

react
React

React is a widely used JavaScript library for building user interfaces and single-page applications. It follows a component-based architecture and uses a virtual DOM to efficiently update and render UI components

eslint
Eslint

ESLint is a linter for JavaScript that analyzes code to detect and report on potential problems and errors, as well as enforce consistent code style and best practices, helping developers to write cleaner, more maintainable code.

React Native

React Native is a framework for building mobile applications using React and JavaScript. It enables developers to write once and deploy to multiple platforms, including iOS, Android, and the web, while providing a native app-like experience to users.

typescript
Typescript

TypeScript is a superset of JavaScript, providing optional static typing, classes, interfaces, and other features that help developers write more maintainable and scalable code. TypeScript's static typing system can catch errors at compile-time, making it easier to build and maintain large applications.