How to enable and use Hermes in a React Native app

Key takeaways:

  • Hermes is a JavaScript engine optimized for React Native, bundled from version 0.70.

  • It uses Ahead-of-Time (AOT) compilation, reducing runtime bytecode conversion.

  • Improves app start time, reduces memory usage, and shrinks binary size using tree-shaking and minification.

  • For React Native version ≥ 0.70, Hermes is enabled by default; older apps need upgrades.

  • Android: Enable hermesEnabled=true in android/gradle.properties, clean the build, and rebuild the app.

  • iOS: Set :hermes_enabled => true in ios/Podfile, install dependencies, and rebuild the app.

  • Confirm Hermes with !!global.HermesInternal in the app's code.

  • Debug Android apps using Chrome DevTools at chrome://inspect#devices.

  • iOS apps require debugging configurations via Xcode or Chrome extensions.

Hermes is a an open-source JavaScript engine which is used for optimizing React Native apps. From React Native 0.70 onwards, Hermes is bundled with React Native—this distribution model is called bundled Hermes.

Before Hermes, React Native apps were read in bytecodes at runtime. This meant that the same code when run 100 times would be converted into bytecode before compilation. Hermes removes this redundancy in compilation by using an ahead-of-time compiler, which runs the code beforehand and optimizes it before runtime. Thus, the code can be efficiently mapped to memory at runtime, thus saving the start time of the app and the memory needed to store it during runtime.

Babel: A JavaScript compiler that converts modern JavaScript code into backwards-compatible versions for older browsers.

Minify: The process of removing unnecessary characters from code (like spaces and comments) to reduce its size and improve performance.

The pipeline of app precompilation using Hermes
The pipeline of app precompilation using Hermes

Hermes offers the following advantages:

  • Hermes reduces the time-to-interact (TTI), thus making the app functional in less time.

  • Due to code optimization, the binary size of the app is reduced by using techniques like tree shaking and minificationMinification is the process of reducing file size by removing unnecessary characters without affecting functionality..

  • The app consumes less memory after installation by using Ahead-of-Time (AOT) compilation.

How to enable Hermes in React Native

For apps created on a React Native version later than or equal to 0.70, Hermes is already enabled as the default engine, and we should be able to view it on the app welcome page. However, older apps require a React Native version of at least 0.64 on iOS but can use version 0.60.4 for Andriod to run Hermes. For older versions, we’ll first need to upgrade the React Native version before enabling Hermes.

To enable Hermes in a React Native app for Android, complete the following instructions:

  1. Enable hermesEnabled in the android/gradle.properties file using the following code snippet:

# Use this property to enable or disable the Hermes JS engine.
# If set to false, you will be using JSC instead.
hermesEnabled=true
Enabling Hermes for Android
  1. If the app is already built, we'll need to clean it by running the following command in the terminal:

cd android && ./gradlew clean
Cleaning the application
  1. To test the installation of Hermes, use the HermesInternal global variable as follows:

const isHermes = () => !!global.HermesInternal;
Testing the installation of Hermes

To enable Hermes in a React Native app for iOS, follow these steps:

  1. In your ios/Podfile, set the :hermes_enabled flag to true under the use_react_native! function:

use_react_native!(
:path => config[:reactNativePath],
:hermes_enabled => true
)
Enabling Hermes for iOS
  1. After enabling Hermes in the Podfile, install the dependencies:

cd ios && pod install
Installing the dependencies
  1. Rebuild the iOS app using Xcode or by running:

npx react-native run-ios
Rebuilding the iOS application
  1. Use the HermesInternal global variable to confirm Hermes is enabled:

const isHermes = () => !!global.HermesInternal;
console.log('Is Hermes enabled?', isHermes());
Ensuring Hermes is enabled

How to use Hermes

To use Hermes, first create a React Native app, navigate to the application folder, and run it using the following command:

npx react-native run-android
Command to create React Native application for Android

For iOS, use the following command instead:

npx react-native run-ios
Command to create React Native application for iOS

In Chrome, this can be done by following these steps:

  1. Open a new tab and type chrome://inspect#devices. This is used to debug remote Android devices in Google Chrome.

  2. Press the "Configure..." button and add the port address that your app is listening to.

  3. Once the app appears under "Remote Target," it is available for debugging.

canvasAnimation-image
1 of 2

Quiz

Let's test the understanding of the concepts learned in this Answer with a short quiz.

1

What does Hermes use to optimize app performance?

A)

Just-in-Time (JIT) compilation

B)

Ahead-of-Time (AOT) compilation

C)

Dynamic loading

D)

Runtime patching

Question 1 of 30 attempted

Take your app development skills further by Building Applications with React Native. Learn essential concepts, master React Native Expo, and use your web expertise to open doors to exciting career prospects.

Conclusion

Hermes enhances app performance by leveraging AOT compilation and efficient memory management, making it a valuable tool for React Native developers aiming for high-performing apps.

Frequently asked questions

Haven’t found what you were looking for? Contact Us


What JavaScript engine does React Native use?

By default, React Native uses the Hermes JavaScript engine, which is optimized for mobile environments and provides faster startup times, reduced memory usage, and smaller app sizes. However, you can also choose to use the JavaScriptCore engine, which is the JavaScript engine used by Safari.


What is Hermes's engine?

Hermes is a lightweight and high-performance JavaScript engine specifically designed for React Native. It’s open-source and aims to improve the performance and efficiency of React Native apps.


How does React Native UI work?

React Native uses a bridge to communicate between the JavaScript layer and the native platform layer (iOS or Android). When you write React Native components, they are translated into native UI components by the bridge. This allows you to build native-looking apps using JavaScript and React’s declarative style.


Free Resources

Copyright ©2025 Educative, Inc. All rights reserved