vercel/next.js · error
'router' and 'Component' can not be returned in getInitialPr
Error message
'router' and 'Component' can not be returned in getInitialProps from _app.js https://nextjs.org/docs/messages/cant-override-next-props
What it means
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.
Source
Thrown at packages/next/src/server/render.tsx:1319
if (ctx.err && ErrorDebug) {
// Always start rendering the shell even if there's an error.
if (renderShell) {
renderShell(App, Component)
}
const html = await renderToString(
<Body>
<ErrorDebug />
</Body>
)
return { html, head }
}
if (
process.env.__NEXT_DEV_SERVER &&
(props.router || props.Component)
) {
throw new Error(
`'router' and 'Component' can not be returned in getInitialProps from _app.js https://nextjs.org/docs/messages/cant-override-next-props`
)
}
const { App: EnhancedApp, Component: EnhancedComponent } =
enhanceComponents(options, App, Component)
const stream = await renderShell(EnhancedApp, EnhancedComponent)
await stream.allReady
const html = await streamToString(stream)
return { html, head }
}
const documentCtx = { ...ctx, renderPage }
const docProps: DocumentInitialProps = await loadGetInitialProps(
Document,
documentCtx
)View on GitHub (pinned to 89d017eac4)
Solutions
- Remove `router` and `Component` keys from the object returned by `getInitialProps` in pages/_app.js; Next.js sets these itself.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at packages/next/src/server/render.tsx:1321 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of vercel/next.js@89d017eac4 (2026-08-19).
Data as JSON: /api/errors/764a18b37345feb1.
Report an issue: GitHub.