rsnext/errors/opt-out-automatic-prerendering.md
Joe Haddad 319bc463e7
Mention Custom App GIP in UPGRADING (#8647)
This tells the user to check their custom <App> for `getInitialProps` if they previously copied the example.

This should help them leverage automatic static optimization!
2019-09-05 22:37:22 -04:00

1,023 B

Opt-out of Automatic Prerendering

Why This Warning Occurred

You are using getInitialProps in your Custom <App>.

This causes all pages to be executed on the server -- disabling Automatic Prerendering.

Possible Ways to Fix It

Be sure you meant to use getInitialProps in pages/_app! There are some valid use cases for this, but it is often better to handle getInitialProps on a per-page basis.

If you previously copied the Custom <App> example, you may be able to remove your getInitialProps.

The following getInitialProps does nothing and may be removed:

class MyApp extends App {
  // Remove me, I do nothing!
  static async getInitialProps({ Component, ctx }) {
    let pageProps = {}

    if (Component.getInitialProps) {
      pageProps = await Component.getInitialProps(ctx)
    }

    return { pageProps }
  }

  render() {
    // ...
  }
}