Before doing firebase setup, we need to install firebase tools on your machine. To do that, please execute
npm install -g firebase-tools
After installing the firebase tools, now you need to login with your firebase
firebase login
Step 1: Create new project & login to firebase
You need to create new folder anywhere on your machine.
mkdir fcf cd fcf firebase init functions
It might asks your few questions, please answer as followed
- Choose your firebase project
- Language: JavaScript
- EsLint: No
- Npm install: Yes
Step 2: Installing Required dependencies
Then, we need to follow these steps,
cd functions npm install --save firebase-admin npm install --save firebase-functions
Step 3:
- Once you init the functions, by default it’ll create functions/index.js file
- Replace fcf/functions/index.js with fcf1/index.js (purchsed folder)
Step 4: Updating Files
- updating service account
- Rename downloaded files to
service-account-key.json
- Copy your
service-account-key.json
tofcf/functions/
- Open
fcf/functions/index.js
with any text editor & Update your databaseURL
Step 5: Deploying FCF
Important: To Deploy cloud function, you must have pay as you go firebase plan
cd .. firebase deploy --only functions
Note: You must be inside fcf/ (not inside fcf/functions) folder for deploying.