nickborrett.co.uk

Using Expo to turn ideas into mobile apps faster

expo
react native
mobile apps
cross-platform mobile app development

June 23, 2020 - It builds upon React Native and claims to be "the fastest way to build an app", but what is Expo, what does it do, and is it a suitable option for cross-platform mobile app development?


Modern frameworks for cross-platform mobile app development have made it easier to build mobile apps without the need for specific iOS or Android expertise. There are many popular frameworks available to do this, with three of the leading contenders being React Native, Flutter, and Xamarin. The features, advantages, and disadvantages of each of these frameworks are already well-documented online, but the basic principle behind all of these is that the app is developed using the chosen language of the framework, before the framework takes over and converts this into the platform-specific language that iOS and Android understand. Google Trends illustrates that, over the last five years, worldwide searches for React Native have increased and then plateaued over the last two years, searches for Flutter have steadily increased since its release in 2017, and searches for Xamarin have declined over the last three years. Of course, the number of searches for a given term may not directly correlate with how popular or superior it is, but it gives an indication about how much noise there is around it.

React Native was first released by the team at Facebook in March 2015, and despite the growth of features, the growth of the ecosystem and the adoption of the framework by many large companies, it has not yet had an major release - at the time of writing, the current stable version of React Native is v0.62. React Native apps are written in JavaScript using React, the modular JavaScript library which is used to power many of today's modern web applications. To have full control over the apps being developed, React Native requires the use of native iOS and Android tools, but this can increase the initial learning curve for developers, and can add time and complexity to getting an app off the ground. Sacrificing some of this control in return for a set of platform-agnostic tools, which are still able to leverage the power of React Native, is possible, and this is where Expo comes in.

features-of-expo.jpg

Expo provides a suite of tools and services to allow apps to be developed, built, and deployed for iOS and Android using a common codebase developed in JavaScript using React. It is built upon React Native, and offers the same features and components provided by React Native. The strapline on their website is "the fastest way to build an app", substantiated by the ability to use their tools to create a new mobile app with just one basic command. The Expo tools include the Expo SDK, a library of components which provides easy access to native features available on iOS and Android, above and beyond those already available in React Native.

The components in the Expo SDK include: OAuth integration, audio components, barcode and QR code scanner, camera integration, device information such as battery and network status, access to user contacts, file system integration, haptics integration, biometric authentication, GPS location and map components, push notifications, printing services, secure storage of data, voice and SMS integration, simple database components, and components to display web content.

All apps developed using Expo follow one of two workflows - the managed workflow, which takes full advantage of the Expo tools and services, and the bare workflow, which offers more control to the developer, but at the expense of some of the automated features provided by the Expo tools. As an example, the bare workflow may be needed when apps need to use native features which are not yet supported by the Expo SDK (for example, Bluetooth integration or Apple and Google Pay integration). It is possible to start developing apps in the managed workflow, but then "eject" to the bare workflow at a later date, if it becomes apparent that more control over the app is needed than the managed workflow offers.

The tools provided by Expo are modern, and promote a slick and seamless development experience. Using these tools, an app can be created on a developer's local environment and connected to a mobile device by scanning an app-specific QR code. Once the app is running on the mobile device, it will be instantly updated when the developer makes any changes in their local environment. This feature, known as hot reloading, provides developers with instant feedback of the changes they make, which has obvious benefits in reducing the time taken to develop mobile apps. It's worth pointing out that this feature is available in React Native.

expo-development-workflow.jpg

Once an app has been built, Expo makes the deployment and distribution of that app straightforward. Using a combination of its tools and platform-specific configuration, Expo can prepare the apps for deployment to the App Store and Play Store using some simple commands. In addition, Expo provides a useful feature known as "over the air" updates, which allows certain app changes to be deployed without the need to build and re-submit apps to their respective app stores. By default, apps developed using Expo are configured to check for updates when they are launched, but this can be customised with more specific rules (for example, only when connected via Wi-Fi), or switched off altogether.

Expo builds on the foundations laid by React Native, has a rich set of features, and provides modern tools to develop, build, and deploy cross-platform mobile apps, so what's not to like? Expo doesn't hide the fact that the tools, the services, or the apps built using Expo are not appropriate for all scenarios, which is clearly outlined in the "Limitations" section of their website. In return for rapid app development, using Expo makes it more difficult to integrate with any native features not yet supported by Expo, so React Native may be a better choice when full control over the development of an app is needed. Expo adds a certain degree of technical overhead, which makes app size an area of concern, as all Expo apps built using the managed workflow contain all of the Expo components, regardless of whether they are being used or not. This means that the most basic app weighs in at around 15-20MB before any features have been added - not massive when compared to other apps, but not lean either if an app only uses one or two of the features that Expo provides, or if an app will be downloaded over a poor data connection. No set of tools will cater for all scenarios, but knowing the limitations of the tools available helps to establish which tools are the most suitable.

The question of whether to use native tools or to use a framework is an interesting one. In general, if you're not using a framework, you're building a framework, and it's important to realise that building a framework from scratch takes time, effort, and expertise, and many not cover all of the edge cases which a framework handles. Using an open-source framework which can be extended and customised where appropriate is often a common approach, providing it is able to meet the functional and non-functional requirements of a project.

It is clear that the tools and services provided by Expo allow for rapid development of cross-platform mobile apps. Expo builds on the strengths of the popular React Native framework and provides a comprehensive set of components which supports the majority of native features available on iOS and Android. As with any architectural decision, whether to use this or any other set of tools doesn't depend on whether they are the best ones, but rather whether they are the most suitable ones for what is trying to be achieved. With the ability to bootstrap a new mobile app within minutes, Expo proves that it is one of the fastest ways to build an app, and together with its substantial library of components and the seamless workflow between development and deployment, it is certainly a tool which should be strongly considered.


Switch to dark mode
© 2021 Nick Borrett