remix-run/react-router · error · Error

Invalid response found for routeId "${routeId}"

Error message

Invalid response found for routeId "${routeId}"

What it means

After confirming a route result exists, the single-fetch client expects it to be a discriminated object with either an `error` or a `data` key. This invariant throws when the value is present but has neither shape (e.g., a bare string, number, or `{}`). It indicates the `.data` payload was produced by something other than React Router's own encoder.

Source

Thrown at packages/react-router/lib/dom/ssr/single-fetch.tsx:761

        // Three R's of redirecting (lol Veep)
        ...(revalidate ? { "X-Remix-Revalidate": "yes" } : null),
        ...(reload ? { "X-Remix-Reload-Document": "yes" } : null),
        ...(replace ? { "X-Remix-Replace": "yes" } : null),
      },
    });
  }

  let routeResult = result.routes[routeId];
  if (routeResult == null) {
    throw new SingleFetchNoResultError(
      `No result found for routeId "${routeId}"`,
    );
  } else if ("error" in routeResult) {
    throw routeResult.error;
  } else if ("data" in routeResult) {
    return routeResult.data;
  } else {
    throw new Error(`Invalid response found for routeId "${routeId}"`);
  }
}

function createDeferred<T = unknown>() {
  let resolve: (val: T) => Promise<void>;
  let reject: (error: unknown) => Promise<void>;
  let promise = new Promise<T>((res, rej) => {
    resolve = async (val: T) => {
      res(val);
      try {
        await promise;
      } catch {}
    };
    reject = async (error?: unknown) => {
      rej(error);
      try {
        await promise;
      } catch {}

View on GitHub (pinned to 6beaca3952)

Solutions

  1. Regenerate the prerendered `.data` files with the same React Router version as the client and redeploy them unmodified.
  2. Remove any response-transforming middleware/edge worker for `.data` requests.
  3. Inspect the failing `.data` response body in the network tab and confirm each route value is `{ data: ... }` or `{ error: ... }`.
  4. Align server and client package versions, then hard reload.
Defensive patterns

Strategy: try-catch

Try / catch

export function ErrorBoundary() {
  const error = useRouteError();
  if (error instanceof Error && /Invalid response found for routeId/.test(error.message)) {
    return <button onClick={() => window.location.reload()}>Stale data — reload</button>;
  }
  throw error;
}

Prevention

When it happens

Trigger: Hand-crafted or hand-edited `.data` files on statically hosted prerendered sites; a proxy/middleware that transforms the JSON-ish turbo-stream body and leaves route values in a wrong shape; server code returning raw values instead of going through the framework's single-fetch response builder; stale prerendered output from an older package version being served by a new client.

Common situations: Editing or generating prerendered `.data` assets in a deploy pipeline; post-processing responses in a CDN worker; version skew between the version that prerendered the files and the running client.

Related errors


AI-assisted analysis of remix-run/react-router@6beaca3952 (2026-08-18). Data as JSON: /api/errors/86c951c337ccf335. Report an issue: GitHub.