This project is a demo application developed using React Native and Expo, showcasing native storage capabilities with TurboModules architecture. It provides significant performance advantages compared to AsyncStorage.
- Native storage modules developed with TurboModules architecture:
- Kotlin implementation for Android
- Objective-C implementation for iOS
- Automatic code generation with Codegen
- Generation of native module interfaces from spec files
- Install dependencies:
npm install
- Start the app:
npx expo start
/specs
- Native module specifications/android
- Android native module implementation- Storage module written in Kotlin
- TurboModules integration
/ios
- iOS native module implementation- Storage module written in Objective-C
- TurboModules integration
This project follows the modern React Native native module development approach:
- Spec Definition: Native module interfaces are defined in spec files
- Codegen: Native code templates are generated from spec files using React Native CLI
- Native Implementation:
- Android: NativeStorageModule implementation in Kotlin
- iOS: RCTNativeStorageModule implementation in Objective-C
- JavaScript Usage: Type-safe native module usage through TurboModules
import { NativeStorage } from './NativeStorage';
// Type-safe native module usage
await NativeStorage.setItem('key', 'value');
const value = await NativeStorage.getItem('key');
This project's native storage implementation has been benchmarked against the widely-used @react-native-async-storage/async-storage package.
Graph: Native Storage vs Async Storage performance comparison
- Read Operations: Native Storage is 2.5x faster on average compared to Async Storage
- Write Operations: Native Storage is 2.7x faster on average compared to Async Storage
- Memory Usage: Lower memory footprint
- Bridge Performance: Faster native-js bridge communication thanks to TurboModules