First, ensure you're using at least version 0.60.2 of React Native. If you're upgrading an existing app ensure everything works before trying to switch to Hermes.
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 ]
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 normal:
Confirming Hermes is in use
If you've just created a new app from scratch you should see if Hermes is enabled in the welcome view:
const isHermes = () => global.HermesInternal != null;
To see the benefits of Hermes, try making a release build/deployment of your app to compare. For example:
react-native run-android --variant release
Debugging Hermes using Google Chrome's DevTools
Chrome connects to Hermes running on device via Metro, so you'll need to know where Metro is listening. Typically this will be on
localhost:8081, but this is configurable. When running
yarn start the address is written to stdout on startup.
Once you know where the Metro server is listening, you can connect with Chrome using the following steps:
chrome://inspectin a Chrome browser instance.
Configure...button to add the Metro server address (typically
localhost:8081as described above).
You should now see a "Hermes React Native" target with an "inspect" link which can be used to bring up debugger. If you don't see the "inspect" link, make sure the Metro server is running.