What is Expo?
Use case of expo eject
Are you planning to eject expo from your react-native app? If yes, I hope the following are the use cases that you’d have.
1- You want to add an “NPM” package to your project which requires a react–native link. And as a rule of thumb, if the documentation for a third-party package states that you need to run the command react-native link as part of the setup process, then this package can’t be used with expo.
2- You are more of a native (Java/Kotlin/Swift/Objective C) person, and want to integrate native module into your React–native app but couldn’t find a way to do it in the expo, so want to get rid of it?
3- You want to add an awesome push notification library like OneSignal in your app which expo doesn’t support.
Are there some other reasons? If yes, write in the comment box below, and I’ll personally look and reply.
Before ejecting Expo, let’s have a look at the drawbacks that you’d face:
Once you eject expo, you can’t inject it back. So, all the great development experience that you had with expo is gone now. Typically to develop a feature in non-expo takes almost 3x the time as compared to expo.
If the developer chooses to eject from Expo, these great development features of the Expo are lost and it takes almost 3x the time as compared to the expo to develop those features in the non-expo state.
Some Advantages Of Using Expo
Expo is kind of an extension to ReactNative that offers a bunch of components and libraries already included to facilitate the development of mobile apps with React Native. Let’s see a few of them:
- Fast and simple project installation.
- Opens a convenient utility Expo CLI in a browser and facilitates ‘app status’ checking on the device it runs on, scan QR code, send the link via email to open the app in Expo Client, or switch the production/ development mode and publish your app on expo server.
- Develop from Windows/macOS or whatever you just only need Nodejs and an internet connection.
- Library linking with react–native links not necessary as everything is covered by the expo.
- Expo client is an app that is easily installed from the Google Play Store or Apple Store on your phone. It allows the opening of projects without build via XCode or Android Studio during the development process. With Expo Client, the apps can be sent to others for review which is greatly required when testing without any need of creating APK or IPA files.
- The app can be updated over the air without repeated deployment on Google Play Store or Apple Store. When users open the app, it will automatically update the app by pulling the recent js bundle published on the expo server.
- Automatic management of certificates and app signatures.
- Easy to use and gives the intermediate results fast.
- Test directly on the device for both iOS and Android.
- One can develop apps for ios without macOS with ios device and test them with Expo client
- Expo SDK offers the collection of ready solutions, such as working with the device accelerometer, camera, notifications, geolocation, etc.
The expo team regularly updates the SDK with new solutions which is very useful for the user.
Let’s look into each use case of “expo eject” one by one:
1. Want to add an “NPM” package that requires linking: The thing that you should ask yourselves is, are there some other packages which don’t require linking and still solves the purpose? Most of the time, you’d find that such a solution already exists. The Expo community has already included many useful packages in the build and the users are just not aware of it. Be it SVGs, animation, or video, most of the packages are already in the expo. If you couldn’t find the replacement package in expo, then there is no way apart from expo eject.
2. You want to add your written custom native module: When writing your react–native bridge and of which the ‘NPM’ package doesn’t exist yet, for such a scenario the Expo eject is the only way and it has to be done.
3. Third-party notification library like OneSignal: Before integrating any awesome push notification service, you’d first explore the push notification service of expo. Although, Expo’s push notification service isn’t great but it solves the purpose in most of the cases. If you don’t like it, and still want to integrate OneSignal or other notification services, then expo eject is the way out.
So far we have seen that in some of the cases, expo eject has to be done. And expo itself says that.
But wait, what if I tell you that there is a way in which you can add custom native modules in expo without ejecting it.
Well, my above statement is not totally true. You have to eject it, but you won’t lose any of the benefits that you were getting with expo. You can still use the modules provided by expo, you can still have the same development flow, you don’t need to re-build native modules over and over again, you don’t need to worry about pod files, swift, kotlin etc.
Won’t that be great? In the following blog, I have described in detail how you can run expo along with custom native modules, or simply do react-native link with expo