Metin Ilhan
Metin Ilhan

Reputation: 241

How to use Expo libraries in a react native bare app?

I have created an app with expo but I have to change it to React Native bare app. Since app size is huge and waiting for builds is a burden.

The question is I have some dependencies like

"@expo/vector-icons": "^10.0.6",
"@react-native-community/netinfo": "^4.6.0",
"expo": "^35.0.0",
"expo-barcode-scanner": "^7.0.0",
"expo-font": "^7.0.0",
"expo-image-manipulator": "^7.0.0",
"expo-image-picker": "^7.0.0",

I want to use them in new created React Native app which does not depend on expo.

Is it possible and how?

I already tested but cant get any result there is a warning about

Possible Unhandled Promise Rejection Error: The method or property of expo-file-system.downloadAsync is not available on android

Upvotes: 6

Views: 15236

Answers (3)

Gaurav Roy
Gaurav Roy

Reputation: 12210

Update For Expo SDK >= 43

As of expo SDK 43, react-native-unimodules is deprecated and shouldn't be used. Instead, setup your project with npx install-expo-modules and then install any desired Expo libraries.

For Expo SDK < 43

Yes , it's possible via react-native-unimodules where you have to install and configure it to use other expo modules in react native bare app.

Expo link this link beautifully explains how to use expo libraries in bare react native applications.

Even you can refer the expo-camera Expo camera module where during installation they have stated how to use it in bare react native apps. Most of the expo packages are available for bare react native app. Do check it out.

Feel free to ask any doubts.

Expo camera

Upvotes: 10

Irfan wani
Irfan wani

Reputation: 5065

react-native-unimodules has been deprecated in sdk 43 and to use expo-modules in bare project, you need to configure expo first.

More details here

Upvotes: 0

Vipul
Vipul

Reputation: 794

react-native-unimodules is deprecated and you don't need to install react-native-unimodules now.

You can simply add expo-modules to you existing react-native-cli app as follows:

  1. npx install-expo-modules
  2. cd ios && pod install

If you find any error in installing, you can refer to the guide: https://docs.expo.dev/bare/installing-expo-modules/

Now you can add any expo-module(available here: https://docs.expo.dev/versions/latest/) that you like in your app. There are some pretty good libraries like expo-notifications, expo-haptics or expo-av.

If you are concerned about the size of the app, it does not increase significantly. Here is a reference:

The expo package is lightweight, increasing only about ~0.2MB for app download size and ~0.45MB app install size on iOS. enter image description here https://blog.expo.dev/embracing-expo-modules-in-your-react-native-projects-cd8ed4cbec3

Upvotes: 1

Related Questions