All Articles

Netlify and React Router

Netlify is a really easy way to deploy your React apps. All you have to do is just to execute “netlify deploy — dir=./build” and your app will be deployed. There is just one problem you have to handle, if you want to use react-router. Because react-router and netlify don’t work together out of the box.

Gladly, the solution is pretty simple. You just have to add a file called “_redirects” to your “public” folder, or the folder you have specified where your index.html file is located. In this file you just have to paste the following code:

For the frontend I use netlify to deploy my create-react-app app. So it’s really straightforward with the following lines:

/*    /index.html   200

And that’s it. After you have redeployed your app, everything should work as expected.