Recently, I have created a Single Page Application (SPA) in React and published it on Github Pages. One limitation I observed was that I had to replace BrowserRoute
with HashRoute
, as Github isn’t able to work with the BrowserRoute.
Now, for a couple of reasons, I want to update the infrastructure of my website to make it MPA (Multi Page Application). Can Github Pages host such application?
2
Answers
Yes, it is possible to host a multi-page React application on GitHub Pages. GitHub Pages can serve static files for any type of web application, including a multi-page application. However, you need to ensure that the routing for your application is set up correctly, as GitHub Pages uses the URL structure to serve files. This typically means you will have to manage your routes either by using hash-based routing (using HashRouter) or configure your application to handle routing properly in a way that aligns with how GitHub Pages serves the files. Make sure that your build process generates a unique HTML file for each route in your MPA.
Yes, GitHub Pages will allow you to host such an application.
Only to use React you will need to set up multiple entry points and possibly modify the build.
In general, you need to change its structure and page transitions correctly to avoid using the limitations associated with dynamic routes.