How to deploy a React app to Firebase



Here is how you can easily deploy your React app to Firebase.


In my example I used the create-react-app to get started, I'm going to assume that you are done with developing your react app and that you ran the npm run build command and that Webpack had bundle your development app into a optimized production build. That is actually what gets deploy - the bundled static resources, typically located in the build folder.


If you don't have one, you will need to register for a Firebase account, it's free. After registering just go the the Console and Add a new project, we will reference this project in Firebase CLI.  
  1. Now just install Firebase tools by running: npm install -g firebase-tools this will install it globally so you can access it easily from your terminal in the future.  
  2. Second, run the: firebase login command which will open up the login page in your browser prompting you to login into your Firebase account
  3. Third run: firebase init command which will prompt you to select which features do you want to use, in this case we want to use the hosting
  4. Firebase CLI will ask you about which directory do you want to use as your public directory, in our case we'll just set it to: build 
  5. Depending on what kind of app are you building, single page or not, Firebase will ask you to chose, in my case I just choose no
  6. Firebase will prompt us that we already have an index.html file in our build directory, select "n" as we don't won't our file overridden
  7. Lastly just run Firebase deploy which will deploy our static assets and give us the live link where we will be able to see our app, and that's pretty much it!



Now that the setup is complete, any time you make any future updates to your app, all you need to do is to run two commands: npm run build and firebase deploy easy peasy! 

Comments

Popular posts from this blog

10 Tips for Designing Better Test Cases

TestRigor - Review

Testing an application you're unfamiliar with - where to begin?