When I try to use npm install to use firebase with React native, I am getting errors.
Then when I try to use require for the firebase module, it says that the document can't be found.
Is there a way to utilize the firebase API with React native instead?
Firebase uses WebSockets, which currently is not supported by React Native. As of now, there is no good solution to integrate Firebase with React Native.
In lieu of requiring firebase as a module, you can indeed use the firebase API instead. If you were doing a simple get request, your fetch function would look like this:
var url = "https://YourDatabaseName.firebaseio.com/some/val.json";
fetch(url)
.then((response) => response.json())
.then((responseData) => {
console.log(responseData);
})
.done();
For more information, you can check out a blog post I wrote about the topic here: http://anuj.io/using-firebase-api-with-react/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With