React Native CLI vs Expo CLI - Comparison
The most popular question when starting react native journey
This is one of the most important questions that people getting started to React Native come across. Whether to choose React Native CLI or Expo CLI ?
If you want a quick answer then I would say go with Expo CLI! And read along if you want to know why not to choose react-native-cli !
React Native Basic Concepts
All React Native apps whether made with react-native-cli or expo-cli have 2 parts:
Native part ( Android code, iOS code )
JavaScript part
React Native is basically an extra layer on top of Native Android and Native iOS. Meaning when you build react native apps you are basically using the native tools that are used to build native android and native ios apps PLUS we also have a mechanism to load JavaScript code.
React Native CLI
So, if you are building React Native apps with React Native CLI ( Command Line Interface ). You first need to manually do the environment setup on your development machine so that can compile / build Native code ( i.e Java/Kotlin + Swift/Objective C ) PLUS your JavaScript.
Now, if you make any changes to your native code ( android / ios ), then in order to have the updated app on your device, you need to rebuild the app with updated code and push it your device. And if you update only the JavaScript part of your application, then you only need to push the updated JavaScript to your device i.e no need to rebuild the native code since it is the same.
Expo CLI
Expo uses the above concept. We have an Expo Go client app available for both Android and iOS. You basically install this client app on your mobile phone. This app already has most common native libraries that are required by most modern apps.
For doing environment setup on your development machine you only need to install Node.JS on your development machine and right away you can start making applications.
You write your code in JavaScript. Since, you are not updating native code, so you need not to rebuild the Android / iOS app, right! and only need to push the updated JavaScript which takes a few seconds. This makes your development faster.
You can check out the below image for a quick comparison overview.
When building applications with react-native-cli we use the react-native run android or react-native run ios and with expo we use expo start.
Similarity
Now, in both the cases development server starts, bundles JavaScript code and pushes the JavaScript code with native code to the mobile device.
Difference
The difference being, in react-native-cli we use Metro to bundle and push JavaScript to the mobile device and use Native Tools to build android and ios bundle that would be installed on the mobile device.
And in expo-cli we already have the client app on our device, so expo development server starts and sends JavaScript which is received by the client app. And the client app is updated in real time.
You can also refer the below image for more details:
Expo is an independent company that has a lot of tools and services around React Native to improve developer experience. They have contributed a lot of open source tools and packages. You can check their website and Github for more details.
Conclusion
So, In the React Native CLI vs. Expo CLI debate, the latter emerges as a better choice, offering speed, efficiency, and additional perks. Dive into the specifics and explore what aligns best with your development goals.
Thanks for reading!