A Fast deploying Realtime Firebase + React-based blog
Tags: react, firebase, webdev, javascript
Published: 2020-04-16 14:18:42

![](https://images.unsplash.com/photo-1486312338219-ce68d2c6f44d?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1952&q=80)

---
### The Problem
---

TLDR;

Hey guys,  
Being a full-stack developer is a tedious task, won't you agree?

For every web-app I make, I have got to manage the frontend as well as the backend.  

I mean come on, this much work? The mobile app guys don't have to deal with two different
projects at a time,  
let alone two different technologies. Lucky folks.

But what do they say, with great power comes great responsibility. Many times we are just confused even on things like what tech stack to use.

I was also tangled in questions like this when I started my search for a more efficient and sustainable development method.  
That's when I was reminded of Firebase by [Sonu Sharma](https://github.com/thealphamerc), of course, why did I not think of it.

I went through the documentation and learned the basics, got my hands on a few practice projects before I got confident about it.

So here I am with a solution to all of our problems, Over the last few weeks, I have been investing quite a few hours in it.

---
### The Solution
---

Comes in the **TFM-BLOG**, 

It removes the overhead of server handling and APIs from you.
Configuring it is pretty easy and straight forward too.

Almost no programming experience is required. Everything is handled by the developers already. Just plug and play.

TFM-BLOG aims to be a simple, minimalistic, yet powerful blogging platform.

**Estimated deployment time** - 10 Minutes

---
### Features
---


1. Firebase Authentication.
2. Serverless.
3. Markdown based.
4. Firestore for database.
5. Cloudinary for CDN (Optional).
6. Realtime updates.
7. Minimal sleek UI.

---
### The Steps
---

1. Visit [The Github repo](https://github.com/thefallenmerc/tfm-blog) to use the template.

    ![](https://res.cloudinary.com/tfm-cdn/image/upload/v1585847573/tfm-blog-step-1_zzbknz.png)

2. Customize your repository

    ![](https://res.cloudinary.com/tfm-cdn/image/upload/v1585849823/tfm-blog-step-2_hwyyak.png)

3. Clone the newly created repo to your local machine

    ![](https://res.cloudinary.com/tfm-cdn/image/upload/v1585849991/tfm-blog-step-3_ekump8.png)
    
    ---
   
    ![](https://res.cloudinary.com/tfm-cdn/image/upload/v1585850289/TFM_BLOG_TUTORIAL/tfm-blog-step-3a_hfjlsb.png)

4. Run `npm install` on the newly created directory to install the npm dependencies. (**This step needs npm installed on your system**, please refer to [this link](https://nodejs.org/en/))

5. look for a file .env.sample in the created directory and make two duplicates of it namely, .env.development and .env.production.

    ![](https://res.cloudinary.com/tfm-cdn/image/upload/v1585849027/Image_006_yshrqk.png)

6. Now head on to the [firebase console](https://console.firebase.google.com/), (**hope you are signed in**) and create a new project.

    ![](https://res.cloudinary.com/tfm-cdn/image/upload/v1585851605/TFM_BLOG_TUTORIAL/tfm-blog-step-4_sl7f4w.png)

7. Insert the project name, and click on continue, click continue new on the following screen as well.

    ![](https://res.cloudinary.com/tfm-cdn/image/upload/v1585851898/TFM_BLOG_TUTORIAL/tfm-blog-step-5_hypize.png)

8. Select analytics account if opted for google analytics on the previous screen and click continue.

    ![](https://res.cloudinary.com/tfm-cdn/image/upload/v1585852039/TFM_BLOG_TUTORIAL/tfm-blog-step-6_wsfnt6.png)

9. It will take a few seconds to set up all the things necessary, click on Continue when ready.

10. Once you are at firebase dashboard of the newly created project, click on authentication tab in sidebar (can change with newer firebase UI updates) and then click on `Set up sign-in methods`

    ![](https://res.cloudinary.com/tfm-cdn/image/upload/v1585852655/TFM_BLOG_TUTORIAL/tfm-blog-step-10_wwev3q.png)

11. On the next screen, click on pencil icon next to the Email, and then click on save after enabling the relative checkboxes.

    ![](https://res.cloudinary.com/tfm-cdn/image/upload/v1585852850/TFM_BLOG_TUTORIAL/tfm-blog-step-11a_ea4xid.png)

    ![](https://res.cloudinary.com/tfm-cdn/image/upload/v1585853006/TFM_BLOG_TUTORIAL/tfm-blog-step-11b_xr9htx.png)

12. Switch to the Users tab, click on add, fill in the credentials and click on add user to save the user.

    ![](https://res.cloudinary.com/tfm-cdn/image/upload/v1585853298/TFM_BLOG_TUTORIAL/tfm-blog-step-12_y0jkj4.png)

13. Make a note of the new user's uid as we will need it to fetch the list of blog posts by us.

    ![](https://res.cloudinary.com/tfm-cdn/image/upload/v1585853449/TFM_BLOG_TUTORIAL/tfm-blog-step-13_sla1ge.png)

14. Now time to get the configuration to connect firebase to our blog, click on the cog icon in the sidebar and head on to settings

    ![](https://res.cloudinary.com/tfm-cdn/image/upload/v1585853611/TFM_BLOG_TUTORIAL/tfm-blog-step-14_hiembe.png)

15. Click on the code icon (its the icon for web-app) and it will redirect you to a page where you will add a new web app to firebase.

    ![](https://res.cloudinary.com/tfm-cdn/image/upload/v1585853763/TFM_BLOG_TUTORIAL/tfm-blog-step-15_dd19yy.png)

16. Fill in the form, add a nickname, check the also set up firebase hosting (this is crucial), click on register app, click on next, we don't need the scripts right now, also click next until the setup is complete.  
I will guide you through the remaining steps, so you don't have to worry about missing anything.

    ![](https://res.cloudinary.com/tfm-cdn/image/upload/v1585853903/TFM_BLOG_TUTORIAL/tfm-blog-step-16_vt9o7j.png)

17. Now this step includes integrating firebase in the that we created previously back in step 3. Go to the repo directory, open up bash or cmd and run the following command, it installs firebase-tools globally, so you don't have to run it next time you are creating an app following this tutorial - 

    ```
        npm install -g firebase-tools
    ```

18. Once done, run the following and follow steps to log in to firebase, most probably it would be web-based authentication - 

    ```
        firebase login
    ```

19. After the login is successful, run the following command - 

    ```
        firebase init
    ```

    Type `y` when asked to confirm
    When asked `Which Firebase CLI features do you want to set up for this folder? Press Space to select features, then Enter to confirm your choices.`
    use up/down arrow to navigate, space to select `Hosting`

    ![](https://res.cloudinary.com/tfm-cdn/image/upload/v1585854732/TFM_BLOG_TUTORIAL/tfm-blog-step-19_rifvzn.png)

20. On the next prompt select 'Use an existing project', it will then prompt you with all the available project, select your desired (in our case it is 'my-awesome-tfm-blog (my-awesome-tfm-blog)')

21. Now it will prompt what directory to use as public, **it is the build directory of your react app by default**, so input build and press enter.

22. Now it asks whether our app is SPA, which it most definitely is, so press 'y' and followed by enter.

23. Firebase is now initialized in our project. Time to configure the APP_KEYS and other credentials.

24. Remember we made two files '.env.development' and '.env.development' in step 5? The development file is used in the development environment and production in production as the name suggests, we will now populate data in these files, mostly you will use the same credentials in both.

25. Head over to console once again you will still be on the settings page, if not, click on cog icon in the sidebar and then go to project settings. 

26. Scroll down to the bottom, your app will now be listed there.

27. Under the section 'Firebase SDK snippet', click on the radio that says config and you will snippet of JS code - 

    ![](https://res.cloudinary.com/tfm-cdn/image/upload/v1585855550/TFM_BLOG_TUTORIAL/tfm-blog-step-27_wxtcsh.png)

28. Switch back to local and open .env.development in any text editor, what you will see is an env file with various variables that have blank value prepended with 'REACT_APP'

    ![](https://res.cloudinary.com/tfm-cdn/image/upload/v1585855748/TFM_BLOG_TUTORIAL/tfm-blog-step-28_pkkfih.png)

29. Fill all the values from the firebase console to relevant variable in the env file, the string can be surrounded in double-quotes, also do not add a comma at the end.

30. After filling most of the values you might notice that REACT_APP_NAME and REACT_APP_DEFAULT_USER_ID are two value you cannot find relevant data for,  
Let's fill them up too...  
**REACT_APP_NAME** will take the value that you want to be displayed on the navbar of your blog.  
**REACT_APP_DEFAULT_USER_ID** will take the uid value of the user that we created in step 3, to get the uid, go to the console, select authentication and then users tab, from there just copy the uid and insert it in the app. Make sure your both env files look like this - 

    ![](https://res.cloudinary.com/tfm-cdn/image/upload/v1585856237/TFM_BLOG_TUTORIAL/tfm-blog-step-30_jv96rk.png)

31. Time to build and deploy the app. Run the following command on the terminal to build the project

    ```
        npm run build --prod
    ```

32. Run the following command to deploy the project

    ```
        firebase deploy
    ```

    Both of these commands will result in the following output, stating that the deployment is successful! Cheers!

    ![](https://res.cloudinary.com/tfm-cdn/image/upload/v1585857011/TFM_BLOG_TUTORIAL/tfm-blog-step-32_mbvxcz.png)

33. Before heading over to the URL provided as the output of the last step, for me it is [https://my-awesome-tfm-blog.firebaseapp.com](https://my-awesome-tfm-blog.firebaseapp.com), let us complete the last task.

34. Let us set up the realtime database 'firestore' provided by firebase. Head to the console, select 'database' from the sidebar and click on create database button.

    ![](https://res.cloudinary.com/tfm-cdn/image/upload/v1585857450/TFM_BLOG_TUTORIAL/tfm-blog-step-34_dys34i.png)

35. It will prompt you to set up, rules, for the sake of simplicity, let us choose test mode, for now, we will learn more about rules in another tutorial.

    ![](https://res.cloudinary.com/tfm-cdn/image/upload/v1585857594/TFM_BLOG_TUTORIAL/tfm-blog-step-35_ofz9q8.png)

36. On the next screen select any of the locations you prefer and finish the setup. Firestore is now configured.

37. Now we can head over to the URL that we got in step 33 after deploying the app. For me, it was [https://my-awesome-tfm-blog.firebaseapp.com](https://my-awesome-tfm-blog.firebaseapp.com), we can see the deployed app now, but it feels empty.

38. To know how to create a blog post and about other features of the blog head over to [TFM-BLOG Getting Started](/tfm-blog-getting-started)