Home > OS >  Can expo-based npm packages be used in react-native project or vice-versa?
Can expo-based npm packages be used in react-native project or vice-versa?

Time:08-22

I want to build a npm package for react-native. Before I get started I have some question in my mind:

  • Should I start with expo or bare react-native?
  • If I start with expo, will it run successfully on react-native project or vice-versa?
  • If no, then what's the solution?

Thanks in advance :)

CodePudding user response:

Short answer: Yes for both cases, but needs some time to configure

Almost all of expo packages can be used inside a CLI app, you can follow this link for more details: https://docs.expo.dev/bare/exploring-bare-workflow/

As for using packages that aren't meant for expo then you also can achieve that but you have to differentiate between two different cases:

1- Packages that include Native Modules: the process is a little more complicated but can be achieved without ejecting, checkout EAS https://docs.expo.dev/workflow/customizing/

2- JS/TS only packages: usually you can install those safely if they are compatible with your configs

My suggestion is that you should try to build an app with both bare and expo to get a feel of what expo's benefits and drawbacks are, although in the current state of expo you should be able to achieve anything without having to eject.

CodePudding user response:

1.Start with bare react native always, coz at some point you have to migrate from expo to this.

  1. No, expo is a wrapper on top of react native, so expo projects you have to eject to use it in bare react native

  2. Start with bare react native, or if youre going with expo, at later point eject from expo to RN.

also expo packages (some) can be used in RN, but the vice versa is not possible if it requires native dependencies.

Hope it helps. feel free for doubts

  • Related