{"record":{"id":"764a18b37345feb1","repo":"vercel/next.js","slug":"router-and-component-can-not-be-returned-in-ge","errorCode":null,"errorMessage":"'router' and 'Component' can not be returned in getInitialProps from _app.js https://nextjs.org/docs/messages/cant-override-next-props","messagePattern":"'router' and 'Component' can not be returned in getInitialProps from _app\\.js https://nextjs\\.org/docs/messages/cant-override-next-props","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/next/src/server/render.tsx","lineNumber":1319,"sourceCode":"        if (ctx.err && ErrorDebug) {\n          // Always start rendering the shell even if there's an error.\n          if (renderShell) {\n            renderShell(App, Component)\n          }\n\n          const html = await renderToString(\n            <Body>\n              <ErrorDebug />\n            </Body>\n          )\n          return { html, head }\n        }\n\n        if (\n          process.env.__NEXT_DEV_SERVER &&\n          (props.router || props.Component)\n        ) {\n          throw new Error(\n            `'router' and 'Component' can not be returned in getInitialProps from _app.js https://nextjs.org/docs/messages/cant-override-next-props`\n          )\n        }\n\n        const { App: EnhancedApp, Component: EnhancedComponent } =\n          enhanceComponents(options, App, Component)\n\n        const stream = await renderShell(EnhancedApp, EnhancedComponent)\n        await stream.allReady\n        const html = await streamToString(stream)\n\n        return { html, head }\n      }\n      const documentCtx = { ...ctx, renderPage }\n      const docProps: DocumentInitialProps = await loadGetInitialProps(\n        Document,\n        documentCtx\n      )","sourceCodeStart":1301,"sourceCodeEnd":1337,"githubUrl":"https://github.com/vercel/next.js/blob/89d017eac43ebf4742ed2b58d3c1373b70283b69/packages/next/src/server/render.tsx#L1301-L1337","documentation":"Development-server guard in renderToHTMLImpl: after calling _app's getInitialProps the returned props are checked for router or Component keys. Those are framework-provided props that Next.js itself injects; returning them from _app.js would override framework values, so the dev server rejects the response shape.","triggerScenarios":"Thrown at packages/next/src/server/render.tsx:1321 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Remove `router` and `Component` keys from the object returned by `getInitialProps` in pages/_app.js; Next.js sets these itself."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"89d017eac43ebf4742ed2b58d3c1373b70283b69","analyzedAt":"2026-08-19T02:10:13.922Z","contentChangedAt":"2026-08-19T02:10:13.922Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}