Deploying to Firebase Hosting
In this guide, you will learn how to deploy your Gatsby site to Firebase Hosting.
Firebase Hosting is a free web content hosting platform for developers. With a single command, you can quickly deploy web apps and serve both static and dynamic content to a global CDN (content delivery network).
Make sure you have:
This guide assumes that you already have a Gatsby project on your local machine.
Install the Firebase CLI with
npmby running the following command:
Sign into Firebase using your Google account by running the following command:
You can test if the CLI is correctly installed by running
firebase projects:list, which should show you a list of your Firebase Projects.
Navigate into your gatsby project directory and setup firebase:
This command will prompt you to:
- select the Firebase products you wish to setup. Be sure to select Firebase Hosting.
- select the Firebase Project you wish to use or create a new one, if you haven’t done it previously.
When prompted to select your public directory, press enter. It will default to
public, which is also Gatsby’s default public directory.
firebase.jsonwith the following cache settings
Prepare your site for deployment by running
gatsby build. This generates a publishable version of your site in the
Deploy your site by running the following command:
All done! Once the deployment concludes, you can access your website using
Check the Firebase Docs for information about how to customize your deployment further. Remember that each time you wish to redeploy your site, you will need to rerun
gatsby build first.