React Native vs Expo deep dive

Full Stack Engineer
April 9, 2024
Updated on June 8, 2024
0 MIN READ
#web-dev#performance#cicd#testing#backend

React Native vs Expo Deep Dive

Introduction

When building cross-platform mobile applications with JavaScript, React Native has emerged as the go-to framework for many developers. However, Expo—a toolchain built around React Native—has gained significant traction by simplifying the development workflow. While both technologies share the same foundation, they cater to different use cases and developer preferences.

This deep dive explores the key differences between React Native and Expo, covering performance, development experience, customization, and deployment. By the end, you'll have a clearer understanding of which solution best fits your project requirements.

Development Experience

React Native (Vanilla)

React Native, often referred to as "vanilla" React Native, provides a barebones setup where developers have full control over the project configuration. This means manually linking native modules, managing platform-specific code, and handling build configurations.

Pros:

  • Full control over native modules and configurations.
  • Better suited for apps requiring deep native integrations.
  • No restrictions on third-party libraries.

Cons:

  • Requires Xcode/Android Studio for native builds.
  • More complex setup and maintenance.

Example of manually linking a native module in React Native:

// Android - MainApplication.java  
@Override  
protected List<ReactPackage> getPackages() {  
  return Arrays.<ReactPackage>asList(  
    new MainReactPackage(),  
    new CustomNativeModulePackage()  
  );  
}

Expo

Expo abstracts much of the native complexity, offering a streamlined development experience with tools like Expo CLI and managed workflows. It includes a rich set of pre-configured modules (e.g., camera, notifications) and simplifies builds with Expo Application Services (EAS).

Pros:

  • Faster setup with expo init.
  • Over-the-air (OTA) updates for quick bug fixes.
  • No need for Xcode/Android Studio in most cases.

Cons:

  • Limited access to native modules without "ejecting."
  • Larger app size due to bundled Expo libraries.

Example of using Expo's Camera module:

import { Camera } from 'expo-camera'; const App = () => { const [hasPermission, setHasPermission] = useState(null); useEffect(() => { (async () => { const { status } = await Camera.requestPermissionsAsync(); setHasPermission(status === 'granted'); })(); }, []); return ( <Camera style={{ flex: 1 }} /> ); };

Performance and Customization

Native Module Access

React Native excels in scenarios requiring deep native integrations. If your app needs custom native code (e.g., Bluetooth low-energy handling), vanilla React Native is the better choice.

Expo, while convenient, restricts direct native module access unless you "eject" to a bare workflow. Even then, some libraries may require additional configuration.

App Size

Expo apps tend to be larger because they bundle the Expo SDK. A minimal Expo app can be ~25MB, whereas a vanilla React Native app can start at ~7MB. If app size is critical, React Native offers more optimization flexibility.

Deployment and Build Process

React Native

Deploying a React Native app involves:

  1. Generating Android (./gradlew assembleRelease) and iOS (xcodebuild) builds manually.
  2. Handling code signing and provisioning profiles.

This process is more hands-on but allows fine-grained control.

Expo

Expo simplifies deployment with:

  1. eas build for generating binaries.
  2. OTA updates via expo publish.

Example of building with EAS:

eas build --platform android  
eas build --platform ios

However, Expo’s managed workflow may not support all app store policies (e.g., background location).

When to Choose Which?

Choose React Native If:

  • Your app requires custom native code.
  • You need granular control over performance optimizations.
  • App size is a critical concern.

Choose Expo If:

  • You prioritize rapid development and prototyping.
  • Your app uses common features (e.g., push notifications, camera).
  • You want OTA updates without app store approvals.

Conclusion

React Native and Expo serve different needs within the same ecosystem. React Native is ideal for complex, performance-sensitive apps requiring native customizations, while Expo accelerates development for standard use cases.

Evaluate your project's requirements—whether it's control versus convenience—and choose accordingly. For many teams, starting with Expo and ejecting later (if needed) strikes a practical balance.

Both tools continue to evolve, narrowing the gap between them. Regardless of your choice, React Native remains a powerful solution for cross-platform mobile development.

Share this article