Taking a React application live doesn't have to be complicated. If you've built a React app and want a fast, secure, and reliable hosting solution, Firebase Hosting is one of the best options available.
In this guide, you'll learn how to deploy your React application to production using Firebase Hosting in just a few minutes.
Why Firebase Hosting?
Firebase Hosting provides:
- ⚡ Fast global CDN delivery
- 🔒 Free SSL certificates
- 🌍 Custom domain support
- 🚀 Easy deployment with a single command
- 🔄 CI/CD integration with GitHub
Whether you're deploying a personal project, portfolio, SaaS dashboard, or production application, Firebase Hosting offers a simple and scalable solution.
Step 1: Install Firebase CLI
To interact with Firebase services from your terminal, install the Firebase Command Line Interface globally:
npm install -g firebase-tools
After installation, verify that the CLI is available:
firebase --version
Step 2: Login to Firebase
Authenticate your local machine with your Firebase account:
firebase login
You may be asked whether you want to enable anonymous usage reporting.
Allow Firebase to collect CLI usage and error reporting information? (Y/n)
Choose your preferred option.
A browser window will open automatically. Sign in using the Google account associated with your Firebase project and grant the required permissions.
Once authenticated successfully, you'll see a confirmation message in your terminal.
Step 3: Initialize Firebase Hosting
Navigate to your React project directory and run:
firebase init hosting
The Firebase CLI will guide you through several configuration steps.
Configuration Options
✔ Ready to proceed?
Y
✔ Select a Firebase project
Choose:
Use an existing project
Then select your Firebase project from the list.
✔ Public directory
If you're using:
- Vite →
dist - Create React App →
build
dist
or
build
✔ Configure as a Single-Page Application?
Configure as a single-page app (rewrite all urls to /index.html)?
Choose:
Y
This is extremely important for React Router applications. It ensures that refreshing routes such as:
/products
/profile
/settings
won't result in a 404 error.
✔ GitHub Actions Setup
Set up automatic builds and deploys with GitHub?
Choose:
N
unless you want to configure CI/CD immediately.
✔ Overwrite Existing Files?
If Firebase asks to overwrite existing files such as index.html, select:
N
This prevents accidental replacement of your application files.
Step 4: Build Your React Application
Before deploying, create a production build.
Vite
npm run build
Create React App
npm run build
This generates the optimized production assets inside your configured output directory.
Step 5: Deploy to Firebase Hosting
Now deploy your application:
firebase deploy --only hosting
Firebase will:
- Upload your production build
- Configure hosting infrastructure
- Generate a public URL
Example output:
✔ Deploy complete!
Hosting URL:
https://your-project.web.app
Open the URL in your browser and your React application is now live 🎉
Common React Router Fix
If you're using React Router, always answer:
Configure as a single-page app?
with:
Y
Firebase will automatically create the required rewrite rules:
{
"hosting": {
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
]
}
}
This prevents route refreshes from returning 404 errors.
Final Thoughts
Firebase Hosting is one of the easiest ways to deploy a React application. The setup takes only a few minutes, and you get global hosting, SSL, and excellent performance out of the box.
The complete deployment workflow is:
npm install -g firebase-tools
firebase login
firebase init hosting
npm run build
firebase deploy --only hosting
That's it! Your React application is now live and accessible worldwide.
Happy Coding! 🚀
🎥 Prefer a Video Tutorial?
Watch the full deployment tutorial here:
https://www.youtube.com/watch?v=1av63EJzyhg
If you enjoy React, TypeScript, and Full-Stack Development content, follow Codeek on YouTube and Medium for more production-grade tutorials, courses, and real-world engineering practices.
Top comments (0)