In the React Native community, there are two popular ways to create an app, you can use the Expo CLI or you can use the React Native CLI. Stay here and read what to choose and what to stay away from.
Which is better?
While planning to build a cross-platform app you may get confused when choosing between these two options. We generally tend to make decisions based on opinions by our fellow developers and not by validating them.
In the past, it was pretty common to hear that Expo was only intended for small projects or just to learn React Native. That is because of the well-known limitations of Expo had in the past, like the impossibility to link native libraries or add native code into the project.
Another common argument used against Expo was the App size, a “Hello World” application could weigh 25 MB at minimum.
However, Expo has received important updates in recent years and it has overcome most of its drawbacks. Therefore, I decided to research, analyze, and bring together some valuable information, of a hands-on comparison between the two frameworks!
Let's dive in.
Let me tell you something first
Well, after diving in, let me tell you something about my career and why I hace the experience to tell you all of these. Are you in?
Ok, ket me start telling you that I have been developing React Native apps for the last six years. I really must say that things have evolved drastically in React Native, and Expo has a big role towards its success as well.
What is React Native?
And, what is Expo?
Expo is basically a set with tools and services built on top of React Native. It will help you begin with building React Native apps with ease. It provides you with a list of tools that simplify the creation and testing of React Native apps.
When and Why Should You Use Expo?
You must make this decision early on while React Native app development. You must determine whether or not you will use Expo for your project. It is because your whole project’s architecture is based on this decision.
In the previous versions before Expo SDK 40, you needed to strongly consider the Expo limitations before deciding whether to use it or not. Now, Expo comes with development builds, which allow you to divide your application into:
A native runtime: A native binary that is built with Xcode or Android Studio. Expo Go is an example of a native runtime for developing React Native apps.
When your project requires custom native code, a config plugin, a custom runtime version, or a reduced bundle size of the app, you can transition from using Expo Go to develop to a development build.
A development build of your app is a Debug build that contains the expo-dev-client package. Like a production build is for the general public, and a preview build lets your team test your next release, a development build lets developers iterate as quickly as possible. It comes with extensible development tools to develop and test your project.
What is an expo-dev-client
Although a managed Expo project looks like a typical web app, it is a native app, and does have native code. You can see the native code by running expo eject. This command will add all the native code necessary to build complete iOS and Android apps to the project. This is essentially what happens when running the eas build command for a managed Expo app. The project is uploaded to a cloud server that ejects it and builds standalone iOS and Android applications.
Config plugins provide developers with the ability to hook into the build process and make controlled modifications to the native code before it is built. For example, an RN package may require that some library initialization code be added to MainApplication.java and AppDelegate.m. A config plugin can insert the necessary code into the default native files used by Expo after the project is ejected but before the native build tools run. A config plugin is a part of the project, either in a dependency or directly included in the project, and is run during the build process on EAS servers.
The upshot is that config plugins let a developer modify the native code in an app without having to eject. Because config plugins run at build time, they can work even if parts of the underlying app are updated — the managed Expo update process still works with config plugins.
Putting it all together
By using these two tools a developer can end up with most of the benefits of a managed Expo workflow while still making use of custom native code. The first step is to create a config plugin that can make any required changes to the native code. This will allow the app to be built and upgraded using the managed Expo flow. The second step is to build a custom development client that makes use of the updated native code. Once developers and testers have access to the custom client, app development can proceed just as it would for a typical managed flow Expo app.
Build’s Production May Be Delayed
As Expo provides free standalone services to developers, where there are limited clusters of shared resources, it is sometimes possible for builds to queue. For developers who do not like to stay, you can use the priority building infrastructure by purchasing a priority plan. We believe that this is not a problem, but a result of the Expo’s opportunities. Servers cost money, and business users can help you meet those costs to use them first. Either way, a priority plan is cheaper than having your server.
You can not select a Push Notification Provider
When using Expo, you cannot select a Push Notification Provider like Firebase, you may need to use the solution Expo already provides, which is OneSignal. If this represents a problem for you and the requirements of your App, then Expo might not be a good fit for you.
With Expo’s new features, you can finally use it for the whole development process. Adding plugins and native code has never been easier. Since the building process lasts only a few minutes, your clients can now get day-to-day updates on your progress! Other than that, definitely check out the documentation for other commonly used features.
Have fun and stay tuned for more!