I’ve built a small app with React Native and it looks awesome, but I was wondering - can I just export it for web (HTML/JavaScript) instead making a separate code in ReactJS for it? And if it’s possible, what are the pros and cons? BTW I used a free UI kit for the developing. Thanks!
2 Answers
You have two options:
Use react-native-web and share 90% the same source code, between native and webapp.
- Good for non-complex projects;
- If your app have native/complex navigation, then it will have issues, because this can't work on web.
Use web
reactand share some components.- Recommended for complex projects;
- If you have a complex native app, share the components can be the best option;
- bit.dev can be useful to achieve this solution.
More info: https://blog.bitsrc.io/6-ways-to-share-and-reuse-react-components-6d80e2fd16cd
Comments
You can use Expo to build for any platform: IOS, Android, Web
For the web, you can use expo build:web
It creates a production ready static bundle in the web-build/ directory
Here is the full document for the web