Expo vs React Native CLI in 2023

Reading Time: 5 minutes

 

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.

But, let’s star with the basics so I can reveal my veredict to you…
 

 

What is React Native?

React Native is a cross-platform library that builds native mobile apps (iOS and Android) using JavaScript and React. It combines the best parts of native development with React, a best-in-class JavaScript library for building user interfaces.

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.

An update: A bundle of your application’s JavaScript code and assets (images, video, fonts, and so on). An update can be served from your local computer with Expo CLI, embedded in the binary by EAS Build, or hosted on a publicly available server.

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

The expo-dev-client package is used to create a development build. It is a library designed to support any workflow, release process, or set of dependencies in the Expo/React Native ecosystem. Whatever your project needs, either now or in the future, you will be able to create a development build for it and get the productivity and quality of life improvements of JavaScript-driven development.

Config plugins

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.

Limitations

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.

The Veredict

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!

0 Shares:
You May Also Like
Read More

Classes vs Hooks on React

Reading Time: 4 minutesPreviously, in the world of React, we had to use Classes in order to create components. Since version…