Cloud Firestore is a NoSQL document database provided by Firebase. It allows developers to store, sync, and query data. Firestore organizes data into collections and documents, making it easy to access and manipulate data.
Firestore is useful for React Native because it offers a reliable and secure way to store data in the cloud. It keeps the data in sync across multiple devices. With Firestore, React Native developers can easily store and retrieve data, perform complex searches, and create responsive applications without worrying about building and maintaining server infrastructure.
Follow the steps outlined below to successfully create the Cloud Firestore database for React Native.
First, we have to create a Firebase project. Follow the following steps to create a Firebase project:
Navigate to the Firebase console and click the “Create a project” button to add a new project.
Next, add the project name and click the “Continue” button.
Next, enable or disable the Enable Google Analytics for this project
option as per the requirements of the project. Once done, click on the “Create project” button to create the project.
Once the project has been created, click on the “Continue” button to navigate to the project dashboard.
Once the Firebase project has been created, we have to obtain the credentials for the Firebase configuration file. Follow the steps below to get these credentials.
Navigate to the project dashboard and click on the web icon as shown in the illustration below. This will add a web application to the Firebase project.
Perform the following actions on the next screen:
Also set up Firebase Hosting for this app.
option according to the requirements of the project.Click the “Register app” button to register the application.
Once the web application has been registered, the credentials for the Firebase configuration file will be available on the screen. Copy the credentials and store them somewhere safe.
google-services.json
fileNext, we have to obtain the credentials for the google-services.json
file. Follow the steps below to get these credentials.
Navigate to the project dashboard and click on the Android icon as shown in the illustration below. This will add an Android application to the Firebase project.
Perform the following actions on the next screen:
applicationId
inside the <projectName>/android/app/build.gradle
file within the React Native project.Note:
<projectName>
is the name of the React Native project.
Click the “Register app” button to register the application.
Note:
Debug signing certificate SHA-1
is optional. However, configure it as per the requirements of the React Native project.
Once the Android application has been registered, the credentials for the google-services.json
file will be available on the screen. Download the credentials and store them somewhere safe.
Once all the above steps have been completed successfully, we can create the Cloud Firestore database for React Native. Follow the steps below to create the Cloud Firestore database.
Click the “Cloud Firestore” card on the project’s dashboard, as shown in the illustration below.
Click the “Create database” button.
Select the Start in production mode
or Start in test mode
options as per the requirements of the project and click the “Next” button.
Select the location for the Cloud Firestore and click on the “Enable” button.
Congratulations! The cloud Firestore database for React Native has successfully been created and initialized. The database can now be integrated into React Native applications with the help of the firebase configuration and google-services.json
files, respectively.
Free Resources