Why I Recommend Adopting Expo Prebuild

Last month, I attended the Chain React conference, where I was inspired by Keith Kurak’s talk, Not Your Grandparents’ Expo. In the talk, Keith described the evolution of Expo and detailed the flexibility introduced in the framework. He gave an example given where a team migrated between various offerings as needed. That motivated me to look into adopting prebuild on my current project.

Prebuild, or the “managed workflow,” is one of my favorite things about working with Expo. It reduces developer friction by making upgrading easier and providing a consistent place to configure application details. In my opinion, if an app can use prebuild, it should.

Before going too far, it’s worth understanding whether you can achieve parity using prebuild. Generally speaking, the answer is yes. But, is it worth it? The answer depends on your project needs and current customizations.

Our Team’s Example

On my current project, we made minimal changes to the Android and iOS native projects. We had, however, introduced changes that required a few different approaches to support.

Icons

Expo has built-in support for icons. I simply added configuration in the app config.

Splash Screen

I switched out ReactNative Bootsplash for Expo SplashScreen. Like icons, a simple configuration in the app config was all that was required.

Detox

Like many React Native libraries, Detox requires some native configuration. Plugins exist to allow for that configuration but keep the project “managed”. When necessary, you can write your own plugin for a library, but, in this case, config-plugins/detox already exists. Pulling this into the project did the trick.

Build Variant

In our project, we use variants to allow testing, development, and production builds on a single device. Setting this up in Expo was straightforward. Ultimately, it boiled down to determining the variant based on an environment variable within app.config.js and then setting the app name and bundleID/package accordingly.

I also added the environment variable to each EAS build profile and the npm run dev script. This ensures that logic based on the variant is always correct.

Key Takeaways

Keith Kurak’s recent talk motivated me to look into adopting prebuild on my current project, and here’s what I’ve learned.

  • Start by determining whether your app should use prebuild.
  • Follow Expo’s Adopting Prebuild guide.
  • Use React Native Directory to check for libraries compatible with Expo.
  • In general, configure your app.json, run `npx expo prebuild –clean` . Then investigate the diffs, and repeat until you achieve parity
Conversation

Join the conversation

Your email address will not be published. Required fields are marked *