# Can't find variable: Buffer (React Native App)

**URL:** <https://forums.losant.com/t/cant-find-variable-buffer-react-native-app/316>\
**Category:** Help\
**Created:** [December 20, 2016, 6:56am UTC](https://forums.losant.com/t/cant-find-variable-buffer-react-native-app/316 "2016-12-20T06:56:13Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Arvind\_Padmanabhan](https://avatars.discourse-cdn.com/v4/letter/a/e0b2c6/32.png) [@Arvind\_Padmanabhan](https://forums.losant.com/u/Arvind_Padmanabhan)\
**Post date:** [December 20, 2016, 6:56am UTC](https://forums.losant.com/t/cant-find-variable-buffer-react-native-app/316/1 "2016-12-20T06:56:14Z")

</div>

I am trying to use losant-mqtt JS from within a React Native mobile application. For this, I used the repository available at GitHub: [https://github.com/Losant/losant-mqtt-js](https://github.com/Losant/losant-mqtt-js)

Since React Native does not run in a node.js environment, I had to install dependent modules as used by losant. Specifically I did `npm install util events mongodb-extended-json buffer`.

When I deploy my app, I get this error:  
`Can't find variable: Buffer`

The error appears from file `bson/lib/bson/bson.js:30`

At the start of file `bson/lib/bson/binary.js`, the following code is present:

```
// Test if we're in Node via presence of "global" not absence of "window"
// to support hybrid environments like Electron
if(typeof global !== 'undefined') {
  var Buffer = require('buffer').Buffer; // TODO just use global Buffer
}

```

Has anyone tried using Losant-MQTT with React Native? Thanks.

---

<div class="post-metadata">

**Author:** ![anaptfox](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/anaptfox/32/873_2.png) [@anaptfox](https://forums.losant.com/u/anaptfox)\
**Post date:** [December 20, 2016, 10:07pm UTC](https://forums.losant.com/t/cant-find-variable-buffer-react-native-app/316/2 "2016-12-20T22:07:34Z")

</div>

@Arvind_Padmanabhan So there is a couple of things here.

When you did: `npm install util events mongodb-extended-json buffer`, you installed the [buffer](https://github.com/feross/buffer) npm module. `mongodb-extended-json` uses the Native node.js [buffer core module](https://nodejs.org/api/buffer.html). They are very different.

Secondly, depending on your use case, you can just use our API or MQTT directly. Check out:

> **[mqttjs/MQTT.js](https://github.com/mqttjs/MQTT.js)**
>
> The MQTT client for Node.js and the browser. Contribute to mqttjs/MQTT.js development by creating an account on GitHub.

It doesn’t look like it has any dependencies that would conflict with React Native.  
Also check out our MQTT docs:

> **[MQTT Protocol](https://docs.losant.com/mqtt/overview/)**
>
> Learn about communicating with the Losant platform over MQTT.

Let me know if that works. This is a cool use case. 🤗

---

<div class="post-metadata">

**Author:** ![Arvind\_Padmanabhan](https://avatars.discourse-cdn.com/v4/letter/a/e0b2c6/32.png) [@Arvind\_Padmanabhan](https://forums.losant.com/u/Arvind_Padmanabhan)\
**Post date:** [December 21, 2016, 4:47am UTC](https://forums.losant.com/t/cant-find-variable-buffer-react-native-app/316/3 "2016-12-21T04:47:15Z")

</div>

Thanks for the quick response. I solved the buffer problem but encountered other issues. For now, I am putting this hold.

Yesterday I tried [losant-rest-js](https://github.com/Losant/losant-rest-js). I managed to integrate this with my React Native Android app. It went smoothly.

Your other suggestion of using [MQTT JS](https://github.com/mqttjs/MQTT.js) directly, I think I will try this.

So far, I have found Losant easy to learn and use.

---

<div class="post-metadata">

**Author:** ![anaptfox](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/anaptfox/32/873_2.png) [@anaptfox](https://forums.losant.com/u/anaptfox)\
**Post date:** [December 21, 2016, 4:57am UTC](https://forums.losant.com/t/cant-find-variable-buffer-react-native-app/316/4 "2016-12-21T04:57:05Z")

</div>

Sweet! I’m happy to hear that. If have anymore questions, let us know!
