Introduction: Deploying a React application can be a daunting task, but Firebase makes it straightforward with its hosting service. This article will guide you through the steps to deploy your React app using Firebase.
Step-by-Step Guide:
- Create a React Project: Start by creating a new React project using Create React App.
npx create-react-app my-app cd my-app
- Set Up Firebase: Create a Firebase project in the Firebase console. Install Firebase tools and initialize Firebase in your project.
npm install -g firebase-tools firebase login firebase init
- Configure Firebase Hosting: During the initialization, select Firebase Hosting and choose your project. Set the build directory to
build. - Deploy Your App: Build your React app and deploy it to Firebase.
npm run build firebase deploy
Example: This example demonstrates deploying a React-TypeScript project. After setting up Firebase hosting, you can configure GitHub actions for continuous deployment, ensuring your app is always up-to-date with the latest changes.