pg238
pg238

Reputation: 1155

how do I include native module (not installed from npm) in my react-native application

I am writing a native module (Android) for a react-native application I am working on. I am not publishing it to npm. This will be used locally in my application. I am trying to understand how I can include the native module, which won't be in node_modules directory, in the javascript code?

Can someone please help me with this?

Thanks in advance.

Upvotes: 1

Views: 136

Answers (1)

Daniel Basedow
Daniel Basedow

Reputation: 13396

If you are only going to use your module in that one app, you could simply put it in your projects android/app/ directory. Making your native module accessible to JavaScript works exactly the same: extend ReactContextBaseJavaModule and ReactPackage then create an instance of your package in your MainActivitys getPackages method.

If you want to re-use your module you could also make it a separate project and put a local path or private git repo in your package.json

Upvotes: 1

Related Questions