Skip to content

React: build for relative paths

  • React

If it’s not a real production build, you probably test your React Apps in a sub folder at your hosting space. The information on this is scattered and explained way too difficult. There’s nothing to it:

  1. Open package.json in uour App root folder
  2. Find the parameter “homepage” or add it (image above)
  3. Give the parameter the value of the complete path where your app will be hosted (image above)
  4. Save the package.json file
  5. Build the React app using npm start build
  6. Upload the production build (folder build) to your hosting provider
  7. And done!

And when you are building the React App using npm run build, it should confirm the subfolder:

Leave a Reply

Your email address will not be published. Required fields are marked *