Deploying React app by creating a project from the Firebase console.
Prerequisites
The following needs to be installed globally create-react-app
and firebase-tools.
npm install -g create-react-app
npm install -g firebase-tools
Steps for creating a React app and deploying it to Firebase.
- Create a new React project
create-react-app myapp
2. Go to the Firebase console and click on create a project.
3. Enter a unique name for your project. This name will be your hosted URL, and click on the next button.
Example: myapp-unique.web.app
4. Press continue.
5. Configure google analytics and press create project button.
6. Your project has been created successfully now head back to your command prompt.
7. Open the command prompt in the root of your project and enter the following commands.
firebase login
You will be redirected to the browser. Log into the same account in which you created the project.
firebase init
8. Scroll down using the arrow keys and press the spacebar to select the Hosting option and then press enter.
Now press enter to select the existing project.
9. Scroll down to select your project and press enter.
10. Now write build to be used as your public directory and press enter.
Write Yes to configure it as a single-page app.
Write No for not setting automatic builds and deploy with GitHub.
Now finally run following command.
npm run build && firebase deploy
Your project has been deployed successfully.
Now if you go to this link in the browser you can view the project.
Congratulations you have deployed your React App on Firebase. If you have any questions, feel free to reach me on LinkedIn. I’d love to hear if this helped anyone.