Native Modules
Native modules allow React Native developers to write platform-specific code in Java, Kotlin, Swift, or Objective-C and expose it to JavaScript, enabling access to functionality not available through pure JavaScript alone.
Why Native Modules Are Needed
While React Native provides many built-in components and APIs, some device capabilities or third-party SDKs are only accessible through native code, requiring a bridge between JavaScript and the native platform.
Common Use Cases for Native Modules
- Accessing device sensors not covered by existing libraries
- Integrating a native SDK, such as a payment processor
- Performing computationally intensive tasks in native code for better performance
- Accessing platform-specific APIs unavailable in JavaScript
How Native Modules Work
A native module exposes specific methods to JavaScript, which can then be called like any other JavaScript function, with the underlying implementation running native platform code.
Native Modules vs Existing Libraries
Before writing a custom native module, always check if an existing, well-maintained community library already provides the functionality you need, since writing and maintaining native code adds complexity.
The Old Bridge vs the New Architecture
Traditionally, native modules communicated through React Native’s asynchronous bridge. The newer TurboModules system, built on JSI, allows more efficient, synchronous communication between JavaScript and native code.
When to Write a Custom Native Module
Writing a custom native module is appropriate when no existing library covers your specific requirement, or when you need direct access to a native SDK not yet wrapped for React Native.
Conclusion
Native modules extend React Native’s capabilities beyond what JavaScript alone can provide, enabling deep integration with platform-specific features and third-party native SDKs when needed.

