10

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?

s-hunter
  • 24,172
  • 16
  • 88
  • 130

3 Answers3

2

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.

1

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.

s-hunter
  • 24,172
  • 16
  • 88
  • 130
  • This is what i thought would but, how are you planning to maintain instant app in such case? If something is changes in main app how it will be updated in instant app. – Amit Chauhan Oct 22 '21 at 10:01
  • Yes, this might create some unwanted maintenance burdens. One way come to mind is that you can create modules that can be used for both the main app and the instant app. Updating the module will update both apps. Instant app can also be something that is very unique which does not need anything from the main app. At the end of the day, instant app is supposed to be super light weight, just a hook to get users to download the main app. – s-hunter Oct 22 '21 at 14:21
0

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.

Fco P.
  • 2,486
  • 17
  • 20