DEV Community

Emily Feng
Emily Feng

Posted on

How to Host React Webpages on Github Pages

GitHub Pages does not support JSX or modern ES6 modules directly.
If deploying to GitHub Pages, don't forget to build first.
Here are some useful tutorials I followed to solve this problem. (Huge thanks to the authors)

Note: deploy pages from gh-pages branch, some vites when running npm run build change build to dist, to account for this do "deploy": "gh-pages -d dist".

Deploying a React App

  1. https://github.com/gitname/react-gh-pages

For Single Page Apps (Fixing Refresh 404 Problems)

  1. https://github.com/rafgraph/spa-github-pages

Top comments (0)

The Most Contextual AI Development Assistant

Pieces.app image

Our centralized storage agent works on-device, unifying various developer tools to proactively capture and enrich useful materials, streamline collaboration, and solve complex problems through a contextual understanding of your unique workflow.

👥 Ideal for solo developers, teams, and cross-company projects

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay