Hacker News new | ask | show | jobs
by gorbypark 1270 days ago
It probably won’t help with native dependencies on the web. I’ve done a few projects that were android/iOS and then later on we added react-native-web support.

The best way is to go through your package.json dependencies one by one, figure out which support web and which don’t, then go into your project and make an empty component (eg: file.web.js) for any component that doesn’t work on the web. Once you have your app up and running on the web (even with a ton of “blank” web components), start the work of finding web equivalents for the missing functionality. Be diligent that the props for the native component and web component are the same or at least compatible, so that the component calling the now web compatible component needs no changes.

In my experience it’s super important to keep “platform specific” code isolated into its own component. General layout and the skeleton of your app should remain cross platform. In-line use of Platform.OS should be kept to a minimum.

2 comments

Makes total sense, thanks a lot! I've been weighing the pros and cons from going RNW or just try a monorepo with Next.js and share logic and navigation (with new expo-router, when it gets to 1.0) but then rebuild the rest.

I like your suggestion though, a good start to see how much of a lift RNW would be or if it is just better to start "fresh" through Next.js

This is great advice. It’s very helpful to have a step-by-step procedure to follow for such a transition.