loading...
Cover image for Quick Start Firebase using Node JS

Quick Start Firebase using Node JS

nodefiend profile image chowderhead ・2 min read

Photo cred: Fancy crave

Purpose:

This guide will get you up and running with a a very simple Node API firebase backend.

  1. create a firebase project, click goto console , set it up with all default settings .

alt text

  1. Select default settings for creating new project

alt text

  1. Create a directory where you want to load our firebase project (and navigate to it ):

Sites/firebase_project

  1. Make sure you are inside the new directory of our firebase_project

  2. If you don't have it installed on your machine, install firebase global package

npm install -g firebase-tools
  1. if you have never done this before and are not logged in then type: firebase login

6a. this will open up browser window where it will ask you to login to your google account.

Navigate back to your firebase_project directory and type this:

firebase init

  1. in the command line you will see options , use the arrow keys to select: Functions: Configure and deploy Cloud Functions and press spacebar to select it

  2. now press enter

    1. when it asks for language, click Javascript.
    2. if it asks for ESLINT, press no (unless you want to get bugged often)
    3. when it asks to install , dependences click yes,

if you get an error check to make sure your directory has the correct permissions.

if you are still getting an error run firebase init --debug mode , this will help you see any errors that may appear.

  1. Navigate to functions/index.js and uncomment this :
exports.helloWorld = functions.https.onRequest((request, response) => {
  response.send("Hello from Firebase!");
});

  1. Now from the terminal, inside of the directory run :
firebase deploy

After you deploy, you should get a URL like the one seen below:

helloworld

Now paste this link that you see in the terminal , into your favourite HTTP request tool, fore example (POSTMAN) and try to hit the URL, and see if you get "Hello from Firebase!"

Congratz!

This is your first node js request endpoint, you can assign a route to it , or add whatever youd like!

Posted on by:

nodefiend profile

chowderhead

@nodefiend

code is my paint and the interwebs is my canvas. [https://nodefiend.github.io]

Discussion

markdown guide