remix-run/react-router · error
Unable to prerender path because it does not match any…
Error message
Unable to prerender path because it does not match any routes: ${path} What it means
Before prerendering, React Router builds a route matcher from the config and asserts every requested path matches at least one route (`/${path}/` with leading-slash normalization). A path that matches nothing means the static file would be unreachable dead output, so the build fails with the offending path named. This validation runs for explicitly listed and generated prerender paths.
Solutions
- Fix the path in the `prerender` config to match the actual route pattern (check app/routes.ts / file naming)
- If paths come from `getStaticPaths()` or a CMS, filter them against known route patterns before returning
- Add the missing route if the path is supposed to exist
- Remember paths are matched without origin and with trailing-slash normalization — omit the domain and leading duplication
Example fix
// before (react-router.config.ts) — '/about-us' route doesn't exist
export default { prerender: ['/about-us'] };
// after
export default { prerender: ['/about'] }; Defensive patterns
Strategy: validation
Validate before calling
// Validate prerender paths against the route config before building
import { matchRoutes } from 'react-router';
import routes from './app/routes'; // RouteConfig objects
const valid = PRERENDER_PATHS.filter((p) =>
matchRoutes(routes as any, p.replace(/\/*$/, '/')),
);
if (valid.length !== PRERENDER_PATHS.length) {
throw new Error(`Unknown prerender paths: ${PRERENDER_PATHS.filter((p) => !valid.includes(p))}`);
} Try / catch
try {
await build();
} catch (e) {
if (e instanceof Error && e.message.includes('does not match any routes')) {
// the message names the bad path — fix or remove it from prerender config
}
} Prevention
- Derive prerender paths from `getStaticPaths()` or the route manifest instead of hardcoding
- Add a CI check that diffs CMS-provided paths against route patterns
- Keep paths origin-less and consistently slashed
When it happens
Trigger: `prerender: ['/about-us']` when the route is `/about` (typo or rename); paths returned by `getStaticPaths()` or a custom `prerender` function that no longer correspond to routes after a route refactor; index-route confusion (`/blog` vs `/blog/`) where normalization still finds no match; splat params misspelled.
Common situations: CMS-driven path lists drifting out of sync with routes; renaming routes without updating a hardcoded prerender array; copying path lists between projects.
Related errors
- ⚠️ Paths with dynamic/splat params cannot be prerendered…
- Prerender (data): Received a
- Prerender: Failed to start Vite preview server
- Prerender (html): Received a
- Prerender: Request failed for
AI-assisted analysis of remix-run/react-router@6beaca3952 (2026-08-18).
Data as JSON: /api/errors/b08abf2376273f28.
Report an issue: GitHub.
Appendix: 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 6beaca3952)