DEV Community

Himanshu Sharma
Himanshu Sharma

Posted on

A Guide to React Native Expo and Bare Bone Projects

React Native is a powerful framework for building mobile applications using JavaScript and React. It offers two main ways to start a project: using Expo or starting with a Bare Bone project. While both approaches can lead to a successful mobile app, they have different advantages, disadvantages, and use cases.

In this blog, we'll explore React Native Expo and Bare Bone projects, how to get started with each, and when to use one over the other.

What is Expo?

Expo is a framework and platform for React Native that allows developers to build native iOS and Android apps using JavaScript. It simplifies a lot of the underlying setup and offers a rich ecosystem of tools and services.

Key Features of Expo:

  • Out-of-the-box features: It includes a large number of pre-built components, such as camera access, push notifications, and file system management.
  • Zero build configuration: You don’t need to install Android Studio or Xcode to build and test apps. Expo provides a build service that can create the final binaries for both platforms.
  • Faster development cycle: You can preview changes instantly with Expo Go, a mobile app that helps you run your code directly on your device.

Setting Up an Expo Project

  1. Install Expo CLI: First, install the Expo CLI globally on your machine:
npm install -g expo-cli
Enter fullscreen mode Exit fullscreen mode

2.Create an Expo Project: Use the following command to create a new Expo project:

expo init MyExpoApp
Enter fullscreen mode Exit fullscreen mode

You'll be prompted to choose between different project templates (blank, tab navigation, or managed workflow with TypeScript). Select the one that fits your needs.

3.Start the Development Server: Navigate into your project folder and run:

cd MyExpoApp
expo start
Enter fullscreen mode Exit fullscreen mode

You can then open the Expo Go app on your iOS or Android device, scan the QR code, and immediately see the app running on your phone. This allows for a fast and efficient development workflow.

Benefits of Expo:

  • 1. Ease of Use: Expo abstracts much of the native complexity, making it easier for beginners to start building mobile apps.
  • 2. Cross-Platform Development: The same code works on both iOS and Android with minimal adjustments.
  • 3. Quick Setup: No need to deal with Xcode, Android Studio, or any complex configurations to get started.

Limitations of Expo:

  • Limited Native Customization: If you need to implement custom native modules, Expo might not support them directly unless you "eject" to a bare project.
  • App Size: Expo apps are generally larger because they include all the native modules, even if you don’t use them.
  • Dependency on Expo: You rely on the Expo SDK and updates, which may sometimes limit flexibility in using the latest native features.

What is a Bare Bone React Native Project?

A Bare Bone React Native project is a more traditional approach where you have full control over the native code for both Android and iOS. Unlike Expo, a bare project doesn't abstract native configurations, meaning you'll need to manage build tools like Xcode and Android Studio yourself.

This approach is highly customizable and is ideal when you need direct access to native code or custom libraries.

Setting Up a Bare Bone Project

  1. Install React Native CLI: First, ensure you have the React Native CLI installed globally:
npm install -g react-native-cli
Enter fullscreen mode Exit fullscreen mode

2.Create a Bare React Native Project: You can create a new project using the React Native CLI:

npx react-native init MyBareApp
Enter fullscreen mode Exit fullscreen mode

3.Running the App:

  • For iOS: You need to have Xcode installed. To run the app:
npx react-native run-ios
Enter fullscreen mode Exit fullscreen mode
  • For Android: You need Android Studio set up. To run the app:
npx react-native run-android
Enter fullscreen mode Exit fullscreen mode

This will build the app natively on your machine and allow you to test it on a simulator or device.

Benefits of a Bare Bone Project:

  • Full Customization: You have full access to native code, which is ideal for apps requiring custom native modules or integrations with native features.
  • Smaller App Size: Since you control which libraries are included, your app can be leaner, including only the native code necessary for your functionality.
  • More Flexibility: You can install and use any React Native or native library, even if it's not supported by Expo.

Limitations of a Bare Bone Project:

  • Complex Setup: You'll need to manage separate build environments for iOS and Android, which may require tools like Xcode and Android Studio.
  • Longer Build Times: Because you're compiling the code natively, you might experience longer build and iteration times compared to Expo’s hot reload.
  • More Maintenance: You'll be responsible for updating native dependencies and keeping your project in sync with new versions of React Native.

When to Use Expo vs. Bare Bone

  • Use Expo If:

    • You want a fast, easy setup with minimal native configuration.
    • You're building an MVP (Minimum Viable Product) or a prototype.
    • Your app's functionality fits within the native modules provided by Expo.
    • You want to avoid managing native build tools (Xcode, Android Studio).
  • Use a Bare Bone Project If:

    • You need full access to native APIs and want to integrate custom native code.
    • Your app requires a small footprint and needs to avoid unnecessary libraries.
    • You plan to maintain the app long-term and need full control over dependencies.
    • You’re working on an enterprise-level app with specific custom requirements.

Ejecting from Expo

If you start with Expo and eventually need more control over native code, Expo provides an option to "eject" to a bare React Native project.

Run the following command to eject:

expo eject
Enter fullscreen mode Exit fullscreen mode

This will give you access to native code but will also require you to manage native dependencies moving forward, like any other bare React Native project.

Conclusion
Choosing between Expo and a Bare Bone React Native project depends on your app's requirements and your familiarity with native development tools. Expo is perfect for quickly starting a project with a great development experience and lots of pre-built functionality, while a bare project gives you full control over the native code and app customization.

When starting your next React Native project, consider your specific needs—Expo for simplicity and quick setup, or a bare project for flexibility and long-term customization. Both approaches are valid, and each shines in different scenarios.

Happy coding with React Native!

Top comments (0)