DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Newsletter
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • How We Reduced LCP by 75% in a Production React App
  • My First Practical Agentic App: Using Firebase and Generative AI to Automate Office Tasks
  • Building an AI-Powered Text Analysis App With React: A Step-by-Step Guide
  • Mastering React App Configuration With Webpack

Trending

  • Designing Frontend Applications for Failure, Not Just Success
  • Introducing Graph Concepts in Java With Eclipse JNoSQL, Part 2: Understanding Neo4j
  • DevOps Is Dead, Long Live Platform Engineering
  • Java Concurrency: AtomicReference

Draft This article hasn't been published, so readers can't see it.

In moderation This article is waiting for review, so readers can't see it yet.

Deleted This article has been deleted, so readers can't see it.

  1. DZone
  2. Coding
  3. JavaScript
  4. Deploy React Apps for Free With Firebase

Deploy React Apps for Free With Firebase

The fastest and easiest way to deploy your react apps online with fire-base hosting by google, explained step by step in detail with screenshots and snippets.

By 
Yajas Sardana
·
Updated Jul. 06, 20 · Tutorial
Post on X (opens in a new tab) Share on LinkedIn (opens in a new tab)
49.0K Views

Join the DZone community Save articles, join the discussion, and download Refcards and Trend Reports with a free account.

Join for free Already a member? Log in

With the rise of cloud computing, hosting web apps on services like Heroku, AWS, Azure, and many more has been on the rise. Amidst all these options, Firebase has emerged as a great solution to host serverless web apps. It's easy, pretty fast, and Free!

Getting Started

In this tutorial, I'll take you through all the steps involved in deploying a React app on firebase. 

Prerequisites:

  1.  A firebase project set up. If you don't have one, create one using the firebase console.
  2. A React app set up that you wish to deploy.

Getting Your React App Ready for Deployment 

Run the following command to create a build directory with a production build of your app:

$ npm run build

Inside the build/static directory will be your JavaScript and CSS files. To know more about React production builds, refer to the production build section of the create-react-app docs.

Configuring Firebase

Install Firebase CLI

To host your site with Firebase Hosting, you need the Firebase command-line tool (CLI). Run the following npm command to install the CLI on your system globally:

$ npm install -g firebase-tools

Login to Firebase

Make sure you're in the root directory of your React app and run the following command to login to firebase in your terminal:

$ firebase login

If you're not logged in, you'll be asked to enter the credentials for your google account.

Initiate your project

Now that you've got the firebase CLI configured, it's time to initialize firebase in your react app. Run the following command:

$ firebase init

You will now enter the firebase tools shell and will be prompted with a sequence of questions and various configuration options. Let's go through these questions together step by step to achieve our desirable configuration.

firebase home page - select, hosting: configure and deploy Firebase Hosting sites

Select - Hosting: Configure and deploy Firebase Hosting sites.

select: use an existing project

Select - Use an existing project

select: fir-tutorial-project-93dac (demo-tutorial-project)Select the firebase project that you created (e.g. demo-tutorial-project in my case)

specify build and configuration

  1. Specify the build that we created in the previous section, to be used as your project's public directory.
  2. Select whether or not you need your firebase app to be configured as a single-page app. I'm selecting No in my case.
  3. As we've already created a build directory in our previous section, therefore build/index.html already exists. We would want to let it be as is and enter No for this question.

This marks the end of our configuration process and our app is now ready to deploy!

To verify the successful completion of the initialization process, simply check the presence of .firebasercand firebase.json files. These are automatically created by firebase during the initialization process.

Deploy to Firebase

Just run the following command to deploy your app:

$ firebase deploy

Firebase will now run the deploying process and will give you a unique URL where your app is deployed. For e.g. in my case, it was - https://fir-tutorial-project-93dac.firebaseapp.com/.

Voila! Your ReactApp is now deployed with Firebase hosting. 

To know more about Firebase hosting, refer to the hosting section of the firebase docs.

Firebase app React (JavaScript library)

Opinions expressed by DZone contributors are their own.

Related

  • How We Reduced LCP by 75% in a Production React App
  • My First Practical Agentic App: Using Firebase and Generative AI to Automate Office Tasks
  • Building an AI-Powered Text Analysis App With React: A Step-by-Step Guide
  • Mastering React App Configuration With Webpack

Partner Resources

×

Comments

Loading comments

The comments didn't load

Please try again in a moment.

Likes

Loading

The next likes didn't load. Please try again.

The likes didn't load

Please try again in a moment.

See who liked this

Log in or join DZone for free to see who liked this article.

Log in Join for free
  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook