Skip to content

fix: AppType generic parameter applies to props, not pageProps#92963

Open
Jah-yee wants to merge 1 commit intovercel:canaryfrom
Jah-yee:fix/apptype-generic-parameter
Open

fix: AppType generic parameter applies to props, not pageProps#92963
Jah-yee wants to merge 1 commit intovercel:canaryfrom
Jah-yee:fix/apptype-generic-parameter

Conversation

@Jah-yee
Copy link
Copy Markdown

@Jah-yee Jah-yee commented Apr 18, 2026

Fix: AppType generic parameter misuse (closes #42846)

Problem

Prop types defined by the generic parameter on AppType were incorrectly applied to MyApp's props.pageProps instead of MyApp's props.

Example from issue:

type MyInitialProps = { foo: string };
type MyAppType = AppType<MyInitialProps>;
const MyApp: MyAppType = ({ Component, foo, pageProps }) => {
  // foo should be in props, NOT pageProps.foo
  return <Component {...pageProps} />;
}

Error: Property 'foo' does not exist on type 'AppPropsType<any, MyInitialProps>'

Root Cause

In AppPropsType<Router, PageProps>, the PageProps type was nested inside AppInitialProps<PageProps> which wraps it as { pageProps: PageProps }. This caused custom props to end up inside pageProps rather than on the root props object.

Fix

Changed AppPropsType to merge PageProps directly onto the root props object:

- export type AppPropsType<...> = AppInitialProps<PageProps> & {
+ export type AppPropsType<...> = PageProps & {
+   pageProps: PageProps

This ensures:

  1. Custom props (e.g., foo) are directly on props
  2. pageProps field still exists with the same type for backwards compatibility

Breaking Changes

None — pageProps is still accessible, just also exposes custom props at the root level (which is the expected behavior based on how _app actually works at runtime).

The generic parameter P passed to AppType<P> was incorrectly placed
inside pageProps by AppPropsType. With this change, P is merged
directly onto the props object, so custom props are accessible directly
(e.g., foo) rather than only via pageProps.foo.

Fixes vercel#42846
@nextjs-bot
Copy link
Copy Markdown
Collaborator

Allow CI Workflow Run

  • approve CI run for commit: dd08dd0

Note: this should only be enabled once the PR is ready to go and can only be enabled by a maintainer

1 similar comment
@nextjs-bot
Copy link
Copy Markdown
Collaborator

Allow CI Workflow Run

  • approve CI run for commit: dd08dd0

Note: this should only be enabled once the PR is ready to go and can only be enabled by a maintainer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Parameter on AppType is used incorrectly

2 participants