In this codelab, we're going to learn how to add firebase to your web app and deploy it i.e Firebase Hosting.
Codelab Flow
What you will learn
Adding Firebase
To host your site, you need to install Firebase command line tools using npm
; (Node.js) ; Install Firebase tools: $ npm install -g firebase-tools
If you've previously installed Firebase command line tools, run the install command again to make sure you have the latest version
<script src="https://www.gstatic.com/firebasejs/7.11.0/firebase-app.js"></script>
<script>
// Initialize Firebase
// Set the configuration for your app
// TODO: Replace with your project's config object
var config = {
apiKey: "apiKey",
authDomain: "authDomain",
databaseURL: "databaseURL",
storageBucket: "storageBucket"
};
firebase.initializeApp(config);
</script>
Firebase Hosting
Make sure you are in the root
folder of your project to Initialize your app to use Firebase. Select your Project ID and follow the instructions. If you haven't recently signed in to the Firebase tools, update your credentials:
firebase login
When prompted, you can choose any Alias, such as add-firebase
for instance. Select Firebase Hosting as the Firebase CLI feature. Provide the default directory as /
or e.g build
for your node project.
firebase init
Let's serve and test the firebase project locally. Run the following command from the root of your local project directory.
firebase serve
Finally, deploy your web app to Firebase:
firebase deploy
Celebrate. You're done! Your app will be deployed to the domain:
https://YOUR-FIREBASE-APP.firebaseapp.com
What's next?
You got any bug? report it here for support. You want to contribute? Create your feature here. Learn more on firebase web setup here