question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Wrong warning "You have opted-out of Automatic Static Optimization due to `getInitialProps` in `pages/_app`"

See original GitHub issue

Bug report

Describe the bug

Warning: You have opted-out of Automatic Static Optimization due to getInitialProps in pages/_app. This does not opt-out pages with getStaticProps

image

My _app contains a commented/disabled getInitialProps.

// static async getInitialProps(props: AppInitialProps): Promise<AppRenderProps> {

To Reproduce

Use a commented getInitialProps in _app

Expected behavior

Warning shouldn’t appear when getInitialProps isn’t actually used

Screenshots

Video (1mn): https://youtu.be/4J6kxF8igIc

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
ijjkcommented, May 4, 2020

@Vadorequest it’s being added by the withApollo HOC from the next-with-apollo package. As mentioned in the project’s docs if you pass the getDataFromTree config it will add getInitialProps and opt the pages out of the automatic static optimization

0reactions
balazsorban44commented, Jan 30, 2022

This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

Read more comments on GitHub >

github_iconTop Results From Across the Web

You have opted-out of Automatic Static Optimization due to ...
Pages with getInitialProps are run on demand. If that happens next.js is not able to perform Automatic Static Optimization.
Read more >
opt-out-auto-static-optimization | Next.js
You are using getInitialProps in your Custom <App> . This causes all non-getStaticProps pages to be executed on the server -- disabling Automatic...
Read more >
errors/opt-out-auto-static-optimization.md - Next.js - Fossies
Opt-out of Automatic Static Optimization. Why This Warning Occurred. You are using getInitialProps in your Custom <App> . This causes all non-getStaticProps ...
Read more >
Query menu with getInitialProps best practice? - Prismic People
When you website is deployed, does vercel need to know which pages are changed from the webhook to use Automatic Static Optimization? because ......
Read more >
NextJS - How to Retrieve Values for Meta Tags - Sanity.io
if you just need one set of meta tags, doing this in the _app or _document ... will disable Automatic Static Optimization in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found