Cloudflare Pages Breaks React Router Without a `_redirects` File
Deploying a React SPA to Cloudflare Pages without a `_redirects` file causes 404 errors on any route other than the homepage.
By Contributor · published 5/30/2026
In plain English
Stop your website from showing "not found" errors when users refresh a page or click a direct link. By adding one simple configuration file, you ensure your app always loads correctly instead of crashing when someone visits a specific page.
When a React single-page application (SPA) is served from Cloudflare Pages, navigating directly to any route other than `/` (e.g., `/dashboard`, `/settings`) results in a 404 error from Cloudflare. This is because Cloudflare is looking for a file at that path — but the app uses client-side routing, so only `index.html` exists.
**The fix:** Add a `_redirects` file to your `public/` folder with one line:
```
/* /index.html 200
```
This tells Cloudflare Pages to serve `index.html` for any path, returning a 200 (not a redirect), so React Router can handle the routing on the client.
Per [Cloudflare Pages documentation](https://developers.cloudflare.com/pages/configuration/redirects/), the `_redirects` file supports up to 2,100 rules (2,000 static + 100 dynamic). For most SPAs, the single catch-all rule above is all you need.
An alternative approach documented in the community uses Cloudflare Transform Rules for more granular path matching when you have both a static site and a SPA within the same domain.
## Why it matters
A SPA that 404s on every deep link or page refresh is functionally broken for users who share URLs, bookmark pages, or return via a link in an email. This is one of the most common deployment issues for Lovable-built apps moving to Cloudflare Pages.
## Suggested next action
Add a `_redirects` file to your `public/` directory before your next Cloudflare Pages deployment. Verify by navigating directly to an inner route in your deployed app.