DEV Community

Cover image for Page Not Found on Netlify with React Router

Page Not Found on Netlify with React Router

Sung M. Kim on December 19, 2018

                                Photo by Hello I’m Nik on Unsplash If you are already using netlify.toml, check out this article, ...
Collapse
 
zhuangya profile image
zhuangya

awesome! you save my day :)

Collapse
 
dance2die profile image
Sung M. Kim

You're welcome & glad that it's saved someone's day (an exactly the purpose of sharing 🙂)

Collapse
 
halimarm profile image
Halim

if you use feature deploy on netlify

npm run build && echo "/* /index.html 200" > build/_redirects

Collapse
 
tranduclinh197 profile image
Trần Đức Lĩnh

Oh, thank you ^^, You know! I create project with (webpack+reactjs). The ways on the forum don't work until I see your instructions

Collapse
 
hjp profile image
Hermes J. Pappas • Edited

Hi Sung! Thank you for this post. I tried both your suggestion and Halim's suggestion underneath about how to solve this via custom Netlify build command, and neither worked. I'm new to React and Routing so if you could please have a look at my code and see if I could solve this I would appreciate it extremely.

Here is the site: hjp-world.netlify.app
And here is the github repo: github.com/hermesjpappas/react-cou...

If you click on a country and try to refresh the page, you either get a blank white page or a 404 error on Netlify. Again, any help would be appreciated immensely!

EDIT: I suspect it might have something to do with the fact that I am using generated paths using a variable (e.g. path="/:countryCode") along with the useParams hook on the target component. Still, if you have any ideas that'd be great!

Collapse
 
chalkedgoose profile image
Carlos Alba

Thanks my dude!

Collapse
 
dance2die profile image
Sung M. Kim

You're welcome ✋

Collapse
 
hemant profile image
Hemant Joshi

Wow, you saved my life been looking for this since a week and finally found

Collapse
 
dance2die profile image
Sung M. Kim

Thanks for letting me know it's still working well :)
and glad that it has helped

Collapse
 
ebereplenty profile image
NJOKU SAMSON EBERE

Thank you. Just fixed mine!

Collapse
 
dance2die profile image
Sung M. Kim

You're welcome, Njoku~

Collapse
 
imichaelowolabi profile image
Michael Owolabi

Once again, the community came to the rescue. Thank you Sung, the article saved me stress

Collapse
 
dance2die profile image
Sung M. Kim

Glad that it helped :)

Collapse
 
m121 profile image
Mateo Perez Salazar

Thanks a lot, it was so helpul

Collapse
 
danalves24com profile image
Daniel Rosel

Thanks man this really helped me

Collapse
 
danieldourado profile image
Daniel Dourado Fernandes

My man Sung M. Kim. Thank you.

Collapse
 
zikeron profile image
Alejandro Cortez

I tried to follow this tutorial but my project didn't work. Any ideas?

Collapse
 
dance2die profile image
Sung M. Kim

Hi Alejandro.

Would you post source/links/context/error messages etc to check out for me and others?