Can I use JS libraries like mqtt.js in Expo

#1

Hello, I am trying to use MQTT backend with my expo app. Can I ‘require’ JavaScript libraries in my Expo apps?

#2

Did you try it? It might work, hard to know until you try.

#3

You can npm install (or yarn add) any module from npm. If they are just JS, they will probably work unless they use node APIs that aren’t supported in React Native or native compiled code.

I think there is a decent chance that MQTT support will require a native module since my understanding of it is that its not based on HTTP, so I don’t know how you would build it on top of fetch but maybe it will work.

If it doesn’t work out of the box, MQTT support is something we would consider adding to Expo. You can vote for features here: https://expo.canny.io/feature-requests

What do you want to use MQTT for? (What’s your use case?)

If you need to add native code to make something work, you’ll need to eject/detach.

#4

I am writing a chat app. For now, I’ve built a native app for Android and iOS version is pending. I am keeping tabs on Expo.