
Fixing React Router 7 (or remix) Edge 404s on Netlify
Fixing React Router 7 Edge 404s on Netlify
If you deploy a React Router 7 app to Netlify Edge Functions, you may run intoan annoying production-only error:
No routes matched location "/test/route"
It only happens on client-side navigation, not when you visit the URLdirectly. Dev works fine. Production breaks. Sound familiar?
Below is the short version of what actually fixed it for us.
The Symptoms
- Internal navigation to nested routes (two or more `/` segments) throws`No routes matched location`.
- Directly visiting the same URL works.
- Netlify Edge logs show successful `__manifest` requests, but the response does not include all routes (for example, `/test/route`).
This points to a route manifest discovery problem, not a routing problem.
The Root Cause (for us)
React Router’s lazy route discovery is enabled by default. That means the client receives a partial manifest and discovers more routes by fetching /__manifest on demand. If that request is incomplete (or cached incorrectly) the client simply does not know about some routes, even though the server does.
Result: the client says “No routes matched location” even though the server could render it.
The Fix
Disable lazy route discovery so all routes are included in the initial manifest. This avoids flaky or incomplete edge manifest responses.
In `react-router.config.ts`:
```tsimporttype { Config } from"@react-router/dev/config";
exportdefault {ssr: true,future: {v8_splitRouteModules: false, },routeDiscovery: {mode:"initial", },} satisfiesConfig;```
That single change fixed the client-side navigation 404s in production.
Optional Reinforcements
We also added explicit edge function routing for data/manifest requests to makesure they always hit the React Router edge handler:
```toml[[edge_functions]]path = "/__data"function = "react-router"
[[edge_functions]]path = "/__data/*"function = "react-router"
[[edge_functions]]path = "/__manifest"function = "react-router"
[[edge_functions]]path = "/__manifest/*"function = "react-router"```
Why This Works
By switching `routeDiscovery` to `initial`, the client no longer depends onruntime `__manifest` fetches to discover routes. Every route is already knownafter the first load, so client-side navigation can never fail due to missingroutes.
Final Notes
If you are seeing this only in production, and only on internal navigation,don’t waste time on redirects or SPA fallbacks. Check your React Routermanifest behavior first.
This fix is simple, safe, and easy to reverse if you want lazy discovery backlater.




