Deploying a React App to Netlify
· One min read
To deploy a React app to Netlify, follow the instructions below:
- Some Pre-requisites
- For deploying to netlify make a
_redirects
file in the public folder - Enter
/* /index.html 200
in the _redirects file. This is for client side routing. - There should be no unused variables or imports in the code as it causes netlify build to fail.
- All tags in index.html should be closed (example unclosed
<br>
tag works in normal html but breaks on netlify).
- For deploying to netlify make a
- Login to Netlify
- Select New site from Git
- Choose Github
- Configure the Netlify app on GitHub and choose the repository you wish to publish then select save.
- Select the repository on netlify and click on Deploy Site. Netlify will now deploy the site for you.
- You can change the domain that the site is hosted on by changing the name in Domain Settings.
- Stopping Auto Publish under the Deploys option helps save build time.
ALTERNATIVELY: If you don't want to connect GitHub to Netlify, you can just drag and drop the build
folder to the Netlify Site Drop