React Native and Firestore - reactjs

I am beginner on firebase and need some help with project decision. I am building a react native app for someone and for the database I was thinking of using firebase, but when I was going through the docs I realized that firestore offers Backend Service, does this mean I don't have to use any framework for the backend. I was originally planning to use Django but if firestore provides backend service, it will provide lot more ease to the project. Can anyone give me an explanation on this ?

You can indeed directly connect your ReactJS application to Cloud Firestore, bypassing the need for your own server. To secure the application you'd use Firebase's server-side security rules, which allow you to control who can read and write what data. This is of course extra important, since you're opening up the database for direct access from the client applications, and the rest of the internet.
To access Firebase from React Native, many developers use the react-native-firebase library, which wraps more Firebase services than the JavaScript SDK does.

Related

Does Firebase's Firestore work better with an express API?

I followed some Firestore tutorials and I didn't need to build an API, instead, Firestore connected with the front end and offered features similar to an API. Is this the optimal way to use Firestore? Should I be building an API on top of my front end app to connect to Firestore?
I'm new to using Firestore and NoSQL but I want to quickly build an MVP that's scalable. I'm used to building a python (Flask) API and a PostgreSQL DB, but I want to do something simpler and quicker. Any insight into how Firestore works will help.
If I understand correctly, you would like to know if you should create a back end API to request/pass data between your front end and Firestore.
You do not need your own custom API to connect with Firestore. Googles SDK connects directly from your front-end to your Firestore. Here is their quick start guide.
To make this secure, you will need to set good security rules as documented here.

Can I host a SPA React app with firebase without cloud functions?

I have the intention to deploy a small react single page app for educational purposes and wanted to test something new. Firebase seems like a good option especially because it offers free tier. However there is something that is bothering me, the free tier's cloud functions only support node.js 8 which is obsolete . I plan to use the NoSQL database and hosting options offered by firebase. Correct me if I am wrong but if the CRUD operations are made by a react hooks there is no node.js involvement and therefore no cloud functions are needed? Basically the CRUD is done by the user's browser because he runs the react app .js files and this means that I can safely use the free tier?
If you are just performing queries directly to Firestore or Realtime database from your web app code, then you don't need Cloud Functions at all, and do not need to enable billing on your project. This is should be easy to try for yourself - simply follow the instructions in the documentation for the database you've chosen.

Using the presence feature in react redux firebase

Picture of react redux firebase documentation
I see how they included the presence parameter in the rrfConfig. Does this mean I need to create a presence collection on cloud firestore. Also, how would I actually implement this in react so that I can retrieve the online status of users. I am confused on how to structure this in my react project. Thanks a lot for the help.
The presence feature in react-redux-firebase wraps the similar feature in the Firebase Realtime Database, which depends on this database's web socket nature. This feature is not natively available in Cloud Firestore, due to the complete different (and connectionless) wire protocol that Firestore uses.
So you'll need to either use Realtime Database to use this feature in react-redux-firebase, or wrap it in Cloud Firestore as shown in the Firebase documentation on implementing presence in Firestore with Cloud Functions and Realtime Database.

Serverless Log in and registration

Im new to using the serverless framework and I need to make a log in page and registration in my React js app. I'm using MongoDB and Serverless as my api. Could someone point me in the right direction how to make this work, since I had no luck finding any examples online.
Here is a serverless fullstack application boilerplate which contains registration and login, using AWS Lambda, AWS HTTP API, Express.js and React. It does not use MongoDB, however, as that does not pair well w/ AWS Lambda due to connection issues. Instead it uses a single-table design with AWS DynamoDB to store application data.
https://github.com/serverless-components/fullstack-app

How can I access a Heroku Postgres database from a React Native application?

I have a web application hosted on Heroku that uses PostgreSQL. I want to make a React Native application that can access that database.
How can I do that?
A typical architecture would be to add an API to your web application and have your React Native application talk to the API. I'm not sure how much obfuscation is provided by React Native, but generally speaking client-side code shouldn't contain sensitive information like database credentials.
I wouldn't recommend having multiple applications talk directly to the database, regardless of technology.
Having said that, Heroku does have some guidelines about how to access your database from outside of Heroku. Briefly,
don't hard-code your database credentials since they could change at any time
instead, use heroku config:get DATABASE_URL to retrieve the credentials from your Heroku application
This is commonly used with graphical database clients, for example.

Resources