How to create Android instant app in React Native?

Viewed 877

It seems like there isn't any examples, tutorials or guides on the internet for creating Android instant app with react native.

I have an existing react native app and I want to create an Android instant app. The existing app that was created in react native resides in the directory app, and the instant app I created natively resides in the directory instantapp. I can run this instantapp as an instant app in Android Studio, and all it does is to show a text "Hello instant app" on a blank screen.

I can write Android native code to add more ui and features to this instantapp natively, but I would like to do that in react native and using javascript instead of writing native Android code. How can I do that?

3 Answers

I would look at Integration with Existing Apps, My bet would be you need to create what is essentially another react native app with a separate AppRegistry call. and then integrate the ReactRootView into the instant app.

I might totally be wrong here. But this is what I would try...Please post if your successful. I would love to try this in one of my apps.

Creating a new react native app with the same package name, then configure the android manifest and gradle file for instant app. Although it's a new codebase, but this worked.

You would need to manually create a Catalyst instance & pass the modules, load the JS bundle, and place a ReactView. Now, given the performance penalty & bundle size (you have to start RN first, and you have to load up RN in the native instant bundle, alongside any libraries you need), it does not sound like a good idea.

Related