Type something to search...
How to Build Native Modules in React Native Without Losing Your Mind (A Step-by-Step Guide)

How to Build Native Modules in React Native Without Losing Your Mind (A Step-by-Step Guide)

You need a feature that requires native platform access. You search npm. Nothing exists, or what exists is unmaintained, two major versions behind, and last updated 18 months ago. You need to write a native module.

This is the moment most React Native developers panic. It should not be.

What a Native Module Actually Is

A native module is a bridge between your JavaScript code and platform-native APIs. On iOS, it is an Objective-C or Swift class that exposes methods to JavaScript. On Android, it is a Kotlin or Java class that does the same. The React Native bridge (or JSI, in the New Architecture) handles the communication.

The concept is straightforward. The friction comes from unfamiliar tooling — Xcode projects, Gradle configurations, platform-specific language syntax — not from conceptual complexity.

The iOS Side

Create a new Objective-C file in your Xcode project. Import React/RCTBridgeModule.h. Declare your class as implementing RCTBridgeModule. Use the RCT_EXPORT_MODULE() macro to register it. Use RCT_EXPORT_METHOD() to expose individual methods to JavaScript.

For the New Architecture with TurboModules, create a TypeScript spec file that defines the module's interface using TurboModuleRegistrySpec. The codegen tool generates the Objective-C++ bridging code from this spec. Your implementation conforms to the generated protocol.

The most common mistake on iOS: forgetting to add the implementation file to the correct build target. If your module exists but JavaScript cannot find it, check the target membership in Xcode's file inspector.

The Android Side

Create a Kotlin class that extends ReactContextBaseJavaModule. Override getName() to return the module name that JavaScript will use. Annotate methods with @ReactMethod to expose them. Create a Package class that registers your module and add it to getPackages() in your Application class.

For TurboModules, the same TypeScript spec file drives codegen for both platforms. The generated Java interface defines the contract your Kotlin implementation must fulfill.

The most common mistake on Android: not adding the package to the application's package list. The module compiles successfully but is undefined at runtime.

The JavaScript Side

With the classic architecture, access your module through NativeModules.YourModuleName. With TurboModules, import the generated spec and call methods directly. TurboModules are lazily loaded — they initialize only when first accessed, which improves startup time.

For methods that return values asynchronously, use promises on both platforms. For methods that emit events over time, implement RCTEventEmitter on iOS or RCTDeviceEventEmitter on Android and subscribe in JavaScript with NativeEventEmitter.

The Testing Strategy

Test native modules at three levels. Unit test the native code using XCTest (iOS) and JUnit (Android). Integration test the bridge communication using Jest mocks that verify the correct native methods are called with the correct arguments. End-to-end test the full flow using Detox or Maestro on real devices.

Writing your first native module takes a day. Writing your fifth takes an hour. The skill is learnable and it removes the most significant limitation of React Native development. Let's build the native capabilities your app needs.

Related Posts

How to Cut React Native App Startup Time by 60% by Fixing the Bridge

How to Cut React Native App Startup Time by 60% by Fixing the Bridge

A React Native app taking 4+ seconds to cold start on a mid-range Android device will lose users before the first screen renders. The culprit is usually not the JavaScript bundle. It is the bridge.

read more
Expo or Bare Workflow? The Decision That Silently Determines Your React Native App's Ceiling

Expo or Bare Workflow? The Decision That Silently Determines Your React Native App's Ceiling

A startup CTO chose Expo because it promised faster development. Eight months later, his team spent three weeks ejecting to bare workflow because a critical feature required a native module Expo did

read more
The Hermes Engine Migration Nobody Tells You About: 3 Breaking Changes That Will Crash Your App

The Hermes Engine Migration Nobody Tells You About: 3 Breaking Changes That Will Crash Your App

Hermes reduces React Native app startup time by 30-50% and memory usage by 20-30%. Those numbers are real. What the migration guides do not emphasize is that Hermes implements a different JavaScript

read more
How to Hire React Native Developers Who Can Actually Ship (Not Just Pass a Coding Test)

How to Hire React Native Developers Who Can Actually Ship (Not Just Pass a Coding Test)

A developer aces a JavaScript assessment — perfect score on algorithms, clean React component design, strong TypeScript — gets hired onto a React Native team, and three months later still cannot debu

read more
Why React Native Animations Jank and How Reanimated 3 Fixes It

Why React Native Animations Jank and How Reanimated 3 Fixes It

A list scrolling smoothly until a background API call completes — then dropping to 20-something fps for 200 milliseconds while state updates process — is one of the most common React Native performan

read more
How to Build a React Native CI/CD Pipeline That Deploys to Both App Stores in Under 20 Minutes

How to Build a React Native CI/CD Pipeline That Deploys to Both App Stores in Under 20 Minutes

Without a CI/CD pipeline, a React Native team's deployment day looks like this: a developer spends 2–3 hours building, signing, and submitting to both the App Store and Play Store. Every release. Eve

read more
The React Native Debugging Technique That Senior Engineers Use (and Tutorials Never Teach)

The React Native Debugging Technique That Senior Engineers Use (and Tutorials Never Teach)

A junior developer on our team spent two days debugging a crash that only occurred on Android 12 devices when the app returned from background after more than 30 minutes. Console.log showed nothing.

read more
Your React Native App Has a Memory Leak. Here's How to Find It in 15 Minutes.

Your React Native App Has a Memory Leak. Here's How to Find It in 15 Minutes.

Your app works perfectly for the first 10 minutes. Then it starts dropping frames. Then animations stutter. Then it crashes. The crash report says "out of memory" but your code does not load large da

read more
React Native New Architecture in 2026: Is It Finally Ready for Production?

React Native New Architecture in 2026: Is It Finally Ready for Production?

React Native's New Architecture — Fabric renderer, TurboModules, JSI, and Codegen — has been in development since 2018. For years, the community response was justified skepticism: impressive benchmar

read more
React Native Offline-First Architecture: How to Stop Losing Users to Connectivity Problems

React Native Offline-First Architecture: How to Stop Losing Users to Connectivity Problems

A significant portion of mobile app users — particularly those using apps in the field, on commutes, or in buildings with poor signal — experience connectivity interruptions during typical sessions.

read more
React Native vs. Flutter in 2026: The Honest Comparison Nobody Wants to Publish

React Native vs. Flutter in 2026: The Honest Comparison Nobody Wants to Publish

We have shipped production apps in both React Native and Flutter. We have strong opinions about each. And most published comparisons are useless because they are written by advocates, not practitione

read more
Stop Using Redux in React Native. Here's What Replaced It (and Why Your Team Will Ship Faster)

Stop Using Redux in React Native. Here's What Replaced It (and Why Your Team Will Ship Faster)

A React Native app with a mature Redux implementation can easily accumulate thousands of lines of state management code: actions, reducers, selectors, middleware, thunks, and the type definitions con

read more
7 Things to Know Before You Scale a React Native App to a Large User Base

7 Things to Know Before You Scale a React Native App to a Large User Base

A React Native app at 1,000 users feels effortless. At 100,000 users, cracks appear. At millions, everything you assumed about mobile development gets tested. Seven lessons stand out — each one avoid

read more
How to Scale a React Native Codebase Past 100,000 Lines Without Losing Developer Velocity

How to Scale a React Native Codebase Past 100,000 Lines Without Losing Developer Velocity

A React Native codebase at 20,000 lines is a joy to work in. The same codebase at 80,000 lines has 4-minute builds, daily merge conflicts, and developers who are afraid to touch shared utilities. The

read more