Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I implement firebase using React native?

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?

like image 845
andyttran Avatar asked Feb 12 '26 02:02

andyttran


1 Answers

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/

like image 101
Anuj Tomar Avatar answered Feb 15 '26 11:02

Anuj Tomar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!