Skip to content
tezvyn:
Menu

Adding Native Code to Expo (The Modern 'Eject')

Source: docs.expo.devHardHow cards are made

Adding native code to Expo no longer means 'ejecting'. You create a custom development build with your specific native modules. This is for when a library has native code not in the Expo SDK. The footgun is thinking you must abandon Expo's tools and services.

Why it exists

The standard Expo Go app provides a huge range of native APIs, but it can't include every possible native module a developer might need. Projects often require specialized functionality, like unique hardware integrations or payment SDKs, that involve custom native code. This created a need for a way to add these modules without completely abandoning Expo's streamlined workflow.

The mental model

Forget the old idea of 'ejecting' as a one-way exit from the Expo ecosystem. The modern mental model is additive, not destructive. You are not leaving Expo; you are creating a custom, personalized version of the Expo Go app, called a 'development build,' that includes the specific native libraries your project requires. You build this custom client once, then develop inside it, retaining much of the fast refresh experience.

How it works

When you need to add a library with custom native code (Java/Kotlin on Android, Swift/Objective-C on iOS), you first install it like any other package. Then, instead of using the generic Expo Go app, you use Expo Application Services (EAS) Build to create a development build. This process compiles an installable app (.apk or .ipa) that bundles your new native dependencies. For libraries that require changes to native project files (like AndroidManifest.xml), you use 'config plugins' to script these modifications, avoiding manual and error-prone edits.

When to use it

Use this workflow whenever your project depends on a React Native library that includes native code not already present in the Expo SDK. This is common for features like Bluetooth, NFC, specialized payment processors, or health data kits. If a library's installation instructions mention linking or modifying native Android/iOS project files, it's a candidate for this process.

When not to use it

If a library is pure JavaScript or if the functionality you need is already available through a module in the Expo SDK, you do not need to create a development build. The Expo SDK libraries are tested to work together, ensuring smoother upgrades. Sticking to the standard SDK when possible simplifies maintenance.

One canonical example

A developer wants to add a third-party facial recognition library that has its own native Android and iOS components. Instead of 'ejecting,' they install the library and its config plugin. They then run an EAS command to create a development build. After installing this custom build on their test device, they can write JavaScript that calls the facial recognition library, with full access to its native features, while still using Expo's core development tools.

Interview question

Which scenario requires creating a custom development build in Expo?

  • a.Adding a new JavaScript-only utility library to your project.
  • b.Utilizing a native device feature like the camera, which is already part of the Expo SDK.
  • c.Optimizing app performance by pre-compiling all JavaScript code into native binaries.
  • d.Integrating a React Native library that includes native Android/iOS code not part of the Expo SDK.Correct
Why?

Custom development builds are specifically for integrating React Native libraries that contain native code not already included in the Expo SDK. Pure JavaScript libraries or features already in the SDK do not require a custom build, and performance optimization through pre-compilation is not the primary purpose of this process.

Just read this? Test yourself on what you have been reading.

Read the original → docs.expo.dev

Put your scrolling time to good use

Learn one idea, try a quiz and save useful cards for revision. Tezvyn makes it easy to learn and stay current in your tech field, a few minutes at a time.

The iPhone app is on the way

We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.

Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.

Get it on Google PlayiPhone app coming soon

We are hiring for this. Open roles that interview on react-native — each one lists the topics its interview covers.

See open roles