Levi Daniels
Levi Daniels

Reputation: 1

How can i use a NodeJS npm package in my Android app with Jetpack Compose?

Upvotes: 0

Views: 38

Answers (1)

Marsroverr
Marsroverr

Reputation: 747

You can't natively include an NPM package in a Compose app - Node packages are written in JavaScript while Compose apps are compiled to Java bytecode after being written in Kotlin. I'd suggest either searching for a Java package that does something similar or implementing the functionality you need yourself.

If you're dead-set on using that module specifically, I'd suggest one of these options:

  • Use a different app framework that allows you to import npm modules - Have you considered React Native?

  • Host an API using a node-based framework like nestjs and use it to expose the module's functionality to your app (I'd personally recommend this option if you're set on writing a native Compose app)

  • Host a separate node-based web app and embed it in your app using a WebView (Not really a great option since you can't communicate with the embedded site)

Upvotes: 0

Related Questions