Deploying my React app to Netlify
Tags: netlify, deploy, react
Published: 2021-05-08 19:31:34

I stumbled upon a quick way to deploy a React app to Netlify! This might not be new but someone that's a code newbie like me might find this helpful!

I originally have this project as an HTML/CSS practice app of mine that is currently hosted/deployed on Firebase. I was trying to experiment if I can deploy this to Netlify while also building a react version on the same repo. I probably could've googled the answer to that but I thought, heck, if it doesn't work out, at least I tried and probably will google then. 

So from my current directory, I created a react app and followed these steps: 

|Follow steps line by line|
---------------------------
|* npm install -g create-react-app |
|* create-react-app [app name]|
|* cd [app name] |
|* npm run build. <-- * the generated build file will automatically be on `.gitignore` (so if you link your github for auto-deploy, it won't link it properly).*|
|* I suggest commit your work and push to the branch you want to deploy|
|* npm install netlify-cli -g <-- *can be skipped if you want to process deployment via the link below*|
|* netlify deploy <-- click [here](#deploy) for the next steps if you chose to go with the CLI route.|
------------------------------

##OR 

Utilize this guided way by Netlify. Click [here](https://app.netlify.com/start/deploy?repository=https://github.com/netlify/create-react-app-lambda&_gl=1*1oyd247*_gcl_aw*R0NMLjE2MjAyNTYyODIuQ2p3S0NBandoTW1FQmhCd0Vpd0FYd0ZvRVFnODRETWV1MHdFSVBZRE9wNEZCcFVzb3dlTVRKSlRwbFZLSHF2TXBHU2s4NFdqZ1UzVXN4b0M4dWtRQXZEX0J3RQ..&_ga=2.91913938.993177454.1620453773-1155204282.1620256283&_gac=1.247144950.1620256283.CjwKCAjwhMmEBhBwEiwAXwFoEQg84DMeu0wEIPYDOp4FBpUsoweMTJJTplVKHqvMpGSk84WjgU3UsxoC8ukQAvD_BwE)(This is a free resource from Netlify Support but I do prefer using the CLI to see what is going on behind the scenes.)

##NETLIFY DEPLOY THRU CLI <a name="deploy"></a>
So at this step, you should be prompted with options in tailoring your deployment. It was just literally two lines of commands and I did mines like this; 

![CLI Prompt](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/23fieiwzbjr8hfb45ypr.png)( *And yes I named my mock react app as `please-deploy` haha - so much trial and error that I just had to.*)

###Updating your work on manual deployment?
If you did the steps above with me and didn't link your GitHub on the deployment, that means we're currently on manual deployment for our React app. To double-check, you can look at your 'Deploys' tab on Netlify and click the app we just deployed, and you will see that we don't have a Github repo linked;

![Netlify page](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hid4hn14qav99veb5ban.png)

While on continuous deployment, you will see what Github link you connected;
![Continuous Deploy](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lxml7y9ppe9q28l2ww7q.png)


If you prefer **manual deploys**(GitHub disconnected from Netlify) over **continuous deployment**(means every git push will launch deploy automatically), you would have to run 
* `npm run build`  <-- *updating your build file*
* `netlify deploy` <-- *to push up updated build to be deployed*

You would have to run these commands each time you want to update your deployment. Since your build file is on `.gitignore`, linking your repo on Netlify would not deploy it properly unless you remove/comment-out "/build" on `.gitignore` and push it to your main/master branch.

TADA! And that's all there is to it! Check out my deployed react app if you like! It's bare right now but I added a few things to check if it's working. 

##[WILL-IT-DEPLOY-APP](https://will-it-deploy.netlify.app/)

Let me know if I missed anything or if you've tried these steps too! Until the next one!


References:
--> *A shorter version of the deployment instruction is [here] (https://www.netlify.com/blog/2016/07/22/deploy-react-apps-in-less-than-30-seconds/?_gl=1*eoho3w*_gcl_aw*R0NMLjE2MjAyNTYyODIuQ2p3S0NBandoTW1FQmhCd0Vpd0FYd0ZvRVFnODRETWV1MHdFSVBZRE9wNEZCcFVzb3dlTVRKSlRwbFZLSHF2TXBHU2s4NFdqZ1UzVXN4b0M4dWtRQXZEX0J3RQ..&_ga=2.121454528.993177454.1620453773-1155204282.1620256283&_gac=1.217647844.1620256283.CjwKCAjwhMmEBhBwEiwAXwFoEQg84DMeu0wEIPYDOp4FBpUsoweMTJJTplVKHqvMpGSk84WjgU3UsxoC8ukQAvD_BwE) written by Brian Douglas & David Wells*
--> *Looking for more towards continuous deploy? Gene Campbell III wrote a [blog](https://levelup.gitconnected.com/how-to-deploy-a-react-app-with-netlify-set-up-continuous-deployment-via-github-53859dcdaf40) about it!*