DEV Community

Vishesh Mangla
Vishesh Mangla

Posted on • Edited on

Netilify deployment with react router

Recently tried to host a website on netlify whilst shifting from github-pages. Was a little bit of searching only after which it worked.

Steps:
1) Did the usual linking to github and getting a subdomain from
https://app.netlify.com

2) In package.json

  "homepage": "https://<your_website_name>.netlify.app",
  "scripts":{
  "predeploy": "npm run build",
  "deploy": "netlify deploy"
  } 
Enter fullscreen mode Exit fullscreen mode

3) Under public folder add a file _redirects with contents
/* /index.html 200.
4) In root directory add a file named netlify.toml with content as

[build]
  command = "npm run build"
  publish="/build"
  base = "" 
Enter fullscreen mode Exit fullscreen mode

5) Then follow the steps here https://www.netlify.com/blog/2016/07/22/deploy-react-apps-in-less-than-30-seconds/

Top comments (0)