Okay so you have built your website and now you wandering how to deploy this, you did some research and you most likely came across a thousand different solutions, a lot of them costing money or require experience in spinning up servers and configuring apache or nginx or some sort of complicated web server to run and interpret your website code.
Well thats where firebase comes in handy, you can simply host and deploy your static frontend website without to much hassel and it won’t even cost you a cent depending on your usability of course, but even so firebase is very affordable and if you do go over your limit it won’t break the bank.
so to get started you first require ‘node.js’ installed in your machine, if you haven’t already please head over to their official documents and install it locally on your machine.
Okay great, you have node install, but to actually get started you simply need to install Firebase CLI
npm install -g firebase-tools
This snippet you can paste directly in your terminal(Macosx/Linux) or Command Prompt(Windows).
This will install the firebase cli globally for you and you will be able to use the CLI in any directory of your choosing.
We will be using an Angular Application as an example but the following will really apply to most if not all static website code, essentially you just want to build your project to a distribution and deploy that bundle.
To start the deployment process we first need to login with our firebase account, if you don’t have one then go to firebase and make an account.
if you do have an account then enter this in your terminal.
$ firebase login
after logging in successfully you can navigate to the root of your project directory by using
once you are there then you will need to first bundle your application with
$npm run build --prod
if you aren’t building a single page application then you can skip that step entirely and just continue on.
follow that step with the following
$ firebase init
this will actually start the hosting process, follow the steps like so:
Firebase CLI features…: Hosting.
Database rules file: You can keep that default file name that they provide, or change it if you prefer. This file will be created and will contain the database rules for your app.
Public directory: Type in dist, because this is where your production-ready Angular app assets are.
Configure as single-page app: Most of the time you’ll say yes (y) for this one.
Overwrite index.html: No.
after those steps you can simply enter
and that will deploy your bundle static application files located in your dist folder.
every time you make a change you can just re-enter
$firebase deploy to re-deploy
Firebase is really simple to get started and to use, and once you do it once or twice you won’t ever want to use anything else.
that being said it doesn’t of course support your backend server, however Firebase does have cloud actions that you can setup that can replace the basic functionality of a backend setup.
if you do want to host for example a Node.js or PHP server I would recommend using a service such as Heroku, which is just as simple as firebase but slightly more flexible on what stack you choose to use for your project, however the free tier of heroku can quickly run out if you plan on building a project that is expecting a bit of traffic like a blog application.