You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Allow hybrid App Router / Pages Router applications to explicitly choose pages/404.tsx as the global 404 page.
Make it possible to migrate routes to the App Router independently from migrating the existing 404 page.
Non-Goals
Change the current App Router-first 404 behavior by default.
Change how notFound() or nested not-found.tsx boundaries work within App Router routes.
Change the behavior of applications that use only the App Router or only the Pages Router.
Background
Currently, when an application contains actual App Router routes, the App Router /_not-found takes precedence over Pages Router /404.
If app/not-found.tsx does not exist, Next.js uses its built-in Not Found page instead of an existing pages/404.tsx.
This is problematic during an incremental migration from the Pages Router to the App Router. Adding even a small number of App Router routes can cause the existing pages/404.tsx to stop being used globally.
As a result, the 404 UI must also be migrated to app/not-found.tsx or shared between both routers, even when that work is unrelated to the routes currently being migrated. This can require additional work when the existing 404 page depends on Pages Router-specific layouts, providers, CSS, or other infrastructure.
The current App Router-first precedence is understood. This request is specifically about providing an opt-in migration path rather than changing the existing default behavior.
Proposal
Add an option to explicitly choose the global 404 behavior when the App Router and Pages Router coexist.
For example:
constnextConfig={// Naming is only an examplenotFoundPreference: 'pages',}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Goals
Non-Goals
notFound()or nestednot-found.tsxboundaries work within App Router routes.Background
Currently, when an application contains actual App Router routes, the App Router
/_not-foundtakes precedence over Pages Router/404.If
app/not-found.tsxdoes not exist, Next.js uses its built-in Not Found page instead of an existingpages/404.tsx.This is problematic during an incremental migration from the Pages Router to the App Router. Adding even a small number of App Router routes can cause the existing
pages/404.tsxto stop being used globally.As a result, the 404 UI must also be migrated to
app/not-found.tsxor shared between both routers, even when that work is unrelated to the routes currently being migrated. This can require additional work when the existing 404 page depends on Pages Router-specific layouts, providers, CSS, or other infrastructure.The current App Router-first precedence is understood. This request is specifically about providing an opt-in migration path rather than changing the existing default behavior.
Proposal
Add an option to explicitly choose the global 404 behavior when the App Router and Pages Router coexist.
For example:
or:
When enabled,
pages/404.tsxwould be used as the global 404 page even when App Router routes exist.All reactions