problem_solving

How to fix a page not found on Netlify with react-router-dom

Have you tried to refresh your page after successfully deploying it on Netlify and you get “Page not found”?

Encountering a “Page Not Found” error on Netlify when using react-router-dom typically indicates an issue with your routing configuration or the deployment setup.

To fix this issue,  you need to create a netlify.toml file inside your public folder.

Netlify allows you to configure redirects and rewrites in a netlify.toml file. This can be useful if you’re facing issues with client-side routing. Create a file named netlify.toml in your project root and configure it like this:

[build]
     command = "npm run build"
     publish = "/build"
     base = "/"

[[redirects]]
     from = "/*"
     to = "/index.html"
     status = 200

How to fix a page not found on Netlify with react-router-dom :

Leave a Comment

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

Scroll to Top