I am building a mobile app using react-native/ expo, and I was wondering if there is a way to drop support for the web, so the app cannot be run in a web browser?
Web JS code is automatically stripped when bundled for other platforms. You can still disable the ability to open automatically from the Expo CLI by defining the platforms array in the app.json and only adding ios and android.
You can always remove react-dom and react-native-web from the package.json, this will be the default in the future since the CLI can automatically add them if needed.
Related
I have a react-native App which is not using Expo and runs on android and iOS. Is it possible to make it run on Web? I found multiple projects for this purpose but I am not sure if those projects are aimed to be used only with Expo projects or not. I use multiple android and iOS modules in my app, I can't imagine how those modules will be converted to run on web. Any advise? Is what I am trying to do is even possible?
If you're using native modules with android or IOS specific functionality then you'll have to find a replacement that supports web, (or keep them and use something else for web).
Also no need to stay away from expo modules, expo modules can be used outside of expo too, here's how you can set them up: https://docs.expo.dev/bare/installing-expo-modules/
I'd suggest you listen to some of Fernando Rojo's talks about this:
https://www.youtube.com/watch?v=0FfvIuSouTU&ab_channel=SoftwareMansion
I have an React Native application that was created without using Expo. So, I have to manually manage a bunch of stuff. Not my choice.
I noticed that the package.json has a version field. However, as far as I understand, if I want to deploy my app to the app stores, I have to set the new versions in Android Studio and Xcode.
So, what's the point of the version number in package.json? Is it just like leaving yourself a note? Does it matter if you even use it?
After some investigation, I realized I'd have to detach/eject my Expo app in order to use libraries such as nodejs-mobile-react-native, a library that allows you to run (and ship) a NodeJS singleton thread with your client app.
So the problem here is that I can't use this library unless I detach - something that I've been doing my best thus far to avoid. It sees all references to this library as null and I've tried to even manually link it.
Is there perhaps another approach that someone knows of that allows you to run Node alongside React-Native, which is compatible with Expo?
I have also used Expo in the past and because of similar limitations I switched over to Native Development using Swift but, in your situations what you can do is:
expo eject
in the application directory to detach your app from expo, once you have done this then you will have a plain react native app, then you can add any nodejs packages compatible with React Native.
Done!
There was create-react-native-app just like create-react-app
However I see https://github.com/react-community/create-react-native-app has been merged to expo.
Since I need native (android or ios) support, I can do either of theses
expo bare workflow
https://docs.expo.io/versions/v34.0.0/bare/exploring-bare-workflow/
react native init
https://facebook.github.io/react-native/docs/getting-started (react native cli quickstart)
What do I gain by going through expo bare workflow?
If you use Expo, you can use the module in Expo. Of course, Expo needs to install modules for APK availability starting with SDK33. However, you do not need to link the Expo separately.
If you use Expo, it will automatically reload the code when it is refreshed and not restarted, making it easy to see the code change.
And with fast feedback, the development cycle will be faster. Because the process of communicating from simulator to native apps is still slow, build time will be increased when using Web versions that run directly into the browser, until HMR creates a basic framework for the app because it is fast and fully available with Chrome Developer tools.
Also, if you want to install a React-native module that requires a link, you can use the 'expo eject' command to eject Expo. Then you can use React-native.
I want to know if there is a way to use Expo SDK without publishing on their servers. To be honest, i want to use my own OTA server with Electrode and a react native app, but, Expo has many helpful native resources (fb ads, SecureStore, admob, push notitications, FileSystem, Asset, Payments and many many more...).
I have read and apparently it is imposible (i guess) use Expo SDK Api without using Exp online services even detaching or ejecting (CRNA) the app.
I apreciate your help
You need to add the follow properties to app.json
"updates": { enabled: false }:
If set to false, your standalone app will never download any code, and will only use code bundled locally on the device.
"assetBundlePatterns": [<insert paths>] (if you use any local assets):
An array of file glob strings which point to assets that will be bundled within your standalone app binary.
If you need to detach (to add other native modules), you need to be on Expo SDK v27:
ExpoKit projects on iOS and Android which were created with exp detach now support bundling your assets inside your native app archive so that your app can launch with no internet.
The Expo team is also planning to add the following features:
modularise the SDK to allow non-Expo projects to use the sdk
allow JS bundle and assets to be self-hosted.