{"record":{"id":"fa31a3879ee269d5","repo":"remix-run/react-router","slug":"invalid-payload-type","errorCode":null,"errorMessage":"Invalid payload type","messagePattern":"Invalid payload type","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"packages/react-router/lib/rsc/browser.tsx","lineNumber":276,"sourceCode":"  payload,\n}: {\n  payload: RSCPayload;\n  createFromReadableStream: BrowserCreateFromReadableStreamFunction;\n  fetchImplementation: (request: Request) => Promise<Response>;\n  getContext: RouterInit[\"getContext\"] | undefined;\n}): {\n  router: DataRouter;\n  routeModules: RouteModules;\n} {\n  const globalVar = window as WindowWithRouterGlobals;\n\n  if (globalVar.__reactRouterDataRouter && globalVar.__reactRouterRouteModules)\n    return {\n      router: globalVar.__reactRouterDataRouter,\n      routeModules: globalVar.__reactRouterRouteModules,\n    };\n\n  if (payload.type !== \"render\") throw new Error(\"Invalid payload type\");\n\n  let { clientVersion } = payload;\n\n  globalVar.__reactRouterRouteModules =\n    globalVar.__reactRouterRouteModules ?? {};\n  populateRSCRouteModules(globalVar.__reactRouterRouteModules, payload.matches);\n\n  let routes = payload.matches.reduceRight((previous, match) => {\n    const route: DataRouteObject = createRouteFromServerManifest(\n      match,\n      payload,\n    );\n    if (previous.length > 0) {\n      route.children = previous;\n    } else if (!route.index) {\n      route.children = [];\n    }\n    return [route];","sourceCodeStart":258,"sourceCodeEnd":294,"githubUrl":"https://github.com/remix-run/react-router/blob/7aea711dd1ae2bc5a076d13ff17291829690fa74/packages/react-router/lib/rsc/browser.tsx#L258-L294","documentation":"`createRouterFromPayload` bootstraps the client-side DataRouter from the initial RSC stream and only knows how to build a router from a payload of `type: \"render\"`. If the payload handed to it is any other type (action, redirect, manifest), it throws immediately. The render payload is normally produced by the framework's server entry; seeing this error means the initial payload was generated or routed incorrectly.","triggerScenarios":"Passing a non-render payload (e.g., a manifest or action response captured from another request) into the hydration path via a custom `RSCHydratedRouter`/`createRouterFromPayload` usage; a custom server answering the initial document request with a redirect/action payload instead of the render stream; test harnesses reusing a stale payload fixture.","commonSituations":"Writing custom RSC server entries or playgrounds that fetch the wrong endpoint for hydration; integration tests hydrating from a recorded action response; edge workers that cache an RSC payload of the wrong type for the document URL.","solutions":["Ensure the initial hydration request is served the framework's render payload (same URL, `React-Router-Resource`/RSC negotiation intact).","If you cache RSC payloads at the edge, key them by request type so render, manifest, and action payloads are never interchanged.","In custom entries, pass the payload received for the document request directly to `RSCHydratedRouter`, not one from an action/manifest fetch.","Regenerate any recorded payload fixtures with the current version."],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":"if (payload.type !== \"render\") {\n  throw new Error(\"Cannot hydrate: expected render payload\");\n}\nconst { router } = createRouterFromPayload({ payload, ... });","typeGuard":"type RenderPayload = Extract<RSCPayload, { type: \"render\" }>;\nconst isRenderPayload = (p: RSCPayload): p is RenderPayload => p.type === \"render\";","tryCatchPattern":null,"preventionTips":["Hydrate only from the payload of the initial document request.","Cache RSC payloads keyed by request kind (render/manifest/action) at the edge.","Refresh recorded payload fixtures on every React Router upgrade."],"tags":["rsc","hydration","payload-type","custom-server"],"backgroundTag":"unexpected-response-type","analyzedSha":"7aea711dd1ae2bc5a076d13ff17291829690fa74","analyzedAt":"2026-08-18T18:04:14.938Z","contentChangedAt":"2026-08-18T18:04:14.938Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}