Skip to content

rahulnainwal107/RN-Hermes

Repository files navigation

RN-Hermes

What is hermes?
Hermes is an open-source JavaScript engine optimized for React Native. For many apps, enabling Hermes will result in improved start-up time (Hermes-powered apps launch faster, thanks to build-time precompilation of JavaScript into efficient bytecode.), Hermes is small in APK size, lean on memory, and starts instantly. It won't weigh your app down.

  • Initially available with react-native version 0.60.4 and only available for android.
  • With react-native 0.64, Hermes also runs on iOS.
  • Android app bundles are supported from React Native 0.62 and up.
  • By default, you will be using Hermes if you're on the New Architecture which is available with react-native 0.68 onwards. By specifying a value such as true or false you can enable/disable Hermes as you wish.
  • Starting with React Native 0.69.0, every version of React Native will come with a bundled version of Hermes. We will be building a version of Hermes for you whenever we release a new version of React Native. This will make sure you're consuming a version of Hermes which is fully compatible with the version of React Native you're using.
  • Enabling Hermes

    Android

  • Edit your android/app/build.gradle file and make the change illustrated below:
  • 
    project.ext.react = [
          entryFile: "index.js",
    -     enableHermes: false  // clean and rebuild if changing
    +     enableHermes: true  // clean and rebuild if changing
      ] 
    
  • Also, if you're using ProGuard, you will need to add these rules in proguard-rules.pro :
  • 
    -keep class com.facebook.hermes.unicode.** { *; }
    -keep class com.facebook.jni.** { *; }
    
  • Next, if you've already built your app at least once, clean the build:
  • $ cd android && ./gradlew clean
  • That's it! You should now be able to develop and deploy your app as usual:
  • $ npx react-native run-android

    iOS

  • To enable Hermes for iOS, edit your ios/Podfile file and make the change illustrated below:
  • 
    use_react_native!(
         :path => config[:reactNativePath],
         # to enable hermes on iOS, change `false` to `true` and then install pods
         # By default, Hermes is disabled on Old Architecture, and enabled on New Architecture.
         # You can enable/disable it manually by replacing `flags[:hermes_enabled]` with `true` or `false`.
    -    :hermes_enabled => flags[:hermes_enabled],
    +    :hermes_enabled => true
       )
    
  • Once you've configured it, you can install the Hermes pods with:
  • $ cd ios && pod install

    Size of apk (react-native 0.69.1)

    With hermes and proguard enable

    Screenshot

    Without hermes and proguard

    Screenshot

    More about hermes

    https://reactnative.dev/docs/hermes
    https://hermesengine.dev/