remix-run/react-router · error · Error
Unable to prerender path because it does not match any route
Error message
Unable to prerender path because it does not match any routes: ${path} What it means
Thrown by `assertPrerenderPathsMatchRoutes` (also via the invariant in the prerendered-routes loop). For each string in `prerender`, React Router wraps it in slashes (`/${path}/`, collapsed) and runs `matchRoutes` against the route manifest. If no route matches, the path cannot be prerendered because there is no handler to render it, and the build aborts with the offending path.
Source
Thrown at packages/react-router-dev/vite/plugin.ts:3782
return arr as unknown[] as AsyncFlatten<T>;
}
type PrerenderMetadata = {
type: "data" | "resource" | "html" | "spa";
path: string;
isResourceRoute?: boolean;
};
function assertPrerenderPathsMatchRoutes(
config: ResolvedReactRouterConfig,
prerenderPaths: string[],
): void {
let routes = createPrerenderRoutes(config.routes);
for (let path of prerenderPaths) {
let matches = matchRoutes(routes, `/${path}/`.replace(/^\/\/+/, "/"));
if (!matches) {
throw new Error(
`Unable to prerender path because it does not match any routes: ${path}`,
);
}
}
}
function getPrerenderConcurrencyConfig(
reactRouterConfig: ResolvedReactRouterConfig,
): number {
let concurrency = 1;
let { prerender } = reactRouterConfig;
if (typeof prerender === "object" && "concurrency" in prerender) {
concurrency = prerender.concurrency ?? 1;
}
return concurrency;
}
function createDataRequest(View on GitHub (pinned to 1fd704a7da)
Solutions
- Cross-check each `prerender` entry against your `routes.ts`/`flatRoutes()` output.
- For dynamic slugs, ensure the `prerender` callback only returns slugs that exist as route params.
- Verify `basename` matches the path prefix you are prerendering.
- Drop or fix the failing path; the error names it exactly.
Example fix
// before: prerender includes a path with no route export const prerender = ["/", "/about", "/old-page"]; // after export const prerender = ["/", "/about"];
Defensive patterns
Strategy: validation
Validate before calling
import { matchRoutes } from "react-router";
const assertAllPrerenderRoutable = (routes, paths: string[]) => {
for (const p of paths) {
if (!matchRoutes(routes, `/${p}/`.replace(/^\/\/+/, "/"))) {
throw new Error(`prerender path has no route: ${p}`);
}
}
}; Prevention
- Generate `prerender` lists from the same source as routes to avoid drift.
- Verify `basename` matches the prerendered prefix.
- Drop stale entries when routes are renamed/removed.
When it happens
Trigger: A `prerender` entry that has no corresponding route (typo, stale entry, route removed but `prerender` not updated); a path with parameters that doesn't match a dynamic route pattern; `prerender` paths computed from a data source out of sync with routes; wrong `basename` so matching fails.
Common situations: Static list of `prerender` paths that drifts as routes are renamed; generating `prerender` from a CMS whose entries include unpublished/removed slugs; trailing-slash mismatches between path and route.
Related errors
- Custom Vite manifest paths are not supported
- The "serverBundles" function must return a string
- Unable to define routes with duplicate route id: "${id}"
- React Router Vite plugin not found in Vite config
- No handlers were found for the request: ${url.pathname}${url
AI-assisted analysis of remix-run/react-router@1fd704a7da (2026-08-12).
Data as JSON: /api/errors/b08abf2376273f28.
Report an issue: GitHub.