ISR - `pageProps` in the `_app` is empty
See original GitHub issueVerify canary release
- I verified that the issue exists in Next.js canary release
Provide environment information
Operating System: Platform: win32 Arch: x64 Version: Windows 10 Binaries: Node: 12.22.8 npm: N/A Yarn: N/A pnpm: N/A Relevant packages: next: 12.1.7-canary.3 react: 18.1.0 react-dom: 18.1.0
What browser are you using? (if relevant)
firefox 100.0 (64-bit)
How are you deploying your application? (if relevant)
next start
Describe the Bug
pageProps
is absent on the _app
for ISR pages.
Expected Behavior
pageProps
being there.
To Reproduce
git clone https://github.com/GabenGar/repros.git repros
cd repros/nextjs/isr-build-page-props
npm install
npm build
Ignore errors related to _error
pages, the point is pages/page/[id]
doesn’t have pageProps
despite it being passed in getStaticProps()
(uncomment the logging line to confirm it does in fact return the props
with values).
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:8 (4 by maintainers)
Top Results From Across the Web
pageProps are empty when page is wrapped with ... - GitHub
Describe the problem pageProps supplied via getServerSideProps object is empty when using withPageAuthRequired.
Read more >next.js - _app pageProps from getInitialProps is empty object ...
The issue I am facing is, _app pageProps and thus my response data from getInitialProps is empty object on all routes except home...
Read more >Incremental Static Regeneration with Next.js - LogRocket Blog
Next.js v9.5 introduces Incremental Static Regeneration, a hybrid version of SSG and SSR, which can regenerate static pages during runtime.
Read more >Override the Default App Component in Next.js | egghead.io
[2:35] We are logging out an object, but it's empty. The page props object represents the props for each page. To demonstrate that,...
Read more >Data Fetching: getStaticProps - Next.js
Note: Next.js 13 introduces the app/ directory (beta). ... The cache status of a page leveraging ISR can be determined by reading the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi,
Sorry for this opening, but this is expected behavior.
In
pages/page/[id]
changegetStaticPaths
to usefallback: "blocking"
, and the error goes away.Why would that be though?
When we use
fallback: true
, the server sends a loading page to the user agent, and that page is also generated during build time. If you want to have fallbacktrue
, do this change (or similar):Since ISR pages are generated from next/link, for most cases, the fallback page won’t be shown. Most of the time, only to those who come to a page that has not been generated yet. see the fallback, for a very short time.
Unfortunately, TypeScript can’t really tell that props might undefined, unless isFallback is false, and also check whether the fallback is set to true/“blocking”.
Relevant docs: https://nextjs.org/docs/api-reference/data-fetching/get-static-paths#fallback-pages
I need to pass some props for SEO (which also have to be calculated server-side) and doing it at page level means destructuring props at every page and passing them to SEO module. Which is as far from DRY as it can get. To be honest ISR should’ve been a separate function, it has way too many gotchas to be just an option of static generation.