I created my react app with create-react-app and I built it with the yarn build
. Then I am using Express js server to render the static react app. My react app is using react router. When I try navigate to the url, it gives me 404. Also refresh gives me the same result. It makes sense the build react app does not have the "paths", i.e. there is no "hello" folder for "/hello". How do I resolve this?
This is how I serve the static react app in Express js. app.use(express.static('public'));
`
2
Answers
React Router DOM
React handles its own routing system
react-router-dom
you won’t need express.And checkout newest documentation if you’re using latest package version.
documentation
In your terminal, use npm to install the package:
or yarn
you need to use this
React Router Dom
you can also check my personal wireframe it is still under process but you get the idea
REPO
Live Link