Logo

dev-resources.site

for different kinds of informations.

To Obfuscate or Not Obfuscate (React Native)

Published at
8/5/2024
Categories
reactnative
expo
obfuscation
android
Author
rgomezp
Author
7 person written this
rgomezp
open
To Obfuscate or Not Obfuscate (React Native)

Protecting Your React Native App's Intellectual Property: Using Hermes and JavaScript Obfuscation

Let's just jump to the point.

Code obfuscation is a software development process that makes source or machine code more difficult for humans or computers to understand.

This does not protect your app from being reverse-engineered. Someone with enough time, resources, or dedication can reverse-engineer your app.

NEVER include secrets on the client-side app, even if it's obfuscated.

So in the world of React Native, should you obfuscate your code?

To answer this question we have to first understand how React Native works. Your Javascript code will contain all your business & app logic. It runs and communicates with the native level through the "bridge." When something changes, the Javascript side sends a message to the native side telling it to update the UI, interact with the camera, etc...

Hermes

When it comes to your JS code, should you obfuscate it? If you're running the hermes engine, no. This is because hermes inherently obfuscates your code by compiling your JS to optimized bytecode ahead of time. This should be enough to deter reverse-engineering.

If you're not running the hermes engine and your JS code is included as plaintext in the APK, maybe you should consider switching to hermes.

Proguard / R8

Should you enable proguard / R8 to obfuscate the native code? In the React Native world, you shouldn't be worried about IP theft of the native code since there's likely little going on here -- barring some heavy proprietary native customization.

Now, should you enable proguard / R8 for the minification benefits? Up to you. If your app is big, this might be worth it. Just know that it comes at the cost of making debugging more difficult / viewing crash logs, etc... It also might break your app if you're using 3rd party libraries that may introduce regressions.

For most React Native apps, the critical logic is in JavaScript, but some native modules might still benefit from obfuscation if they contain sensitive logic.

TLDR

If you're concerned about IP theft, using the hermes engine should be enough. If you have proprietary native logic, consider using proguard / R8 while understanding the drawbacks. If your app is large, consider proguard / R8 for its minification capabilities.

Finally please feed the algorithm and give me some feedback if my post helped you πŸ™!

Follow Me


LinkedIn Badge


Twitter Badge

Check out my other articles and projects!

expo Article's
30 articles in total
Favicon
Read Text Asset File in Expo
Favicon
Run Storybook with NX Expo and React Native Paper
Favicon
Explorando Notificaçáes Push no React Native com Expo e OneSignal!
Favicon
Starting React Native Project in 2025
Favicon
Guia Completo: Como Integrar WatermelonDB no React Native 0.76 com Expo 52 e TypeScript
Favicon
How to create authenticated routes with the new Expo SDK 51 using Expo Router
Favicon
React Native Expo with NativeWind v4 and Typescript
Favicon
Translate & Guess: Build a Flag Quiz with Expo and Tolgee
Favicon
How i implemented my server login screen for Mastodon
Favicon
How to Change iOS Push Notifications Permission Dialog with Expo
Favicon
Exploring React Native Navigation with Expo: A Complete Guide
Favicon
How to Render OpenStreetMap in an Expo React Native Web App Using React Leaflet
Favicon
EAS build reads your .gitignore file
Favicon
#2 - Expo apk keeps on crashing after build
Favicon
Dear expo, who are you?
Favicon
npm i openai-react-native
Favicon
Expo51 Jotai Template + flashlist + tamagui
Favicon
Scroll-Responsive Animated Header Bar with Expo Router
Favicon
Expo vs. React Native: Pros, Cons, and Key Differences
Favicon
To Obfuscate or Not Obfuscate (React Native)
Favicon
How to disable keyboard suggestions for Android in React Native
Favicon
Expo51 Jotai Template, ready to use
Favicon
Let's get started with React Native + Expo
Favicon
Generar APK con EAS βš›οΈ React Native
Favicon
How to publish your React Native app to Expo Store 2024
Favicon
Creating a WebView app in React Native using Expo
Favicon
Embracing Expo: The New Standard for Creating React Native Apps
Favicon
Automate Your Expo Builds with EAS Using GitHub Actions: A Step-by-Step Guide (Android)
Favicon
How to Generate APK Using React Native Expo
Favicon
Creating Chat Bubbles with curls in React Native (svg)

Featured ones: