2023-07-05 15:11:16 +02:00
---
title: Opt-out of Automatic Static Optimization
---
2019-07-05 17:57:16 +02:00
#### Why This Warning Occurred
2023-07-05 15:11:16 +02:00
You are using `getInitialProps` in your [Custom `<App>`](/docs/pages/building-your-application/routing/custom-app).
2019-07-05 17:57:16 +02:00
2023-07-05 15:11:16 +02:00
This causes **all pages** to be executed on the server -- disabling [Automatic Static Optimization](/docs/pages/building-your-application/rendering/automatic-static-optimization).
2019-07-05 17:57:16 +02:00
2023-07-05 15:11:16 +02:00
## Possible Ways to Fix It
2019-07-05 17:57:16 +02:00
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.
2023-07-05 15:11:16 +02:00
If you previously copied the [Custom `<App>`](/docs/pages/building-your-application/routing/custom-app) example, you may be able to remove your `getInitialProps`.
2019-07-05 17:57:16 +02:00
The following `getInitialProps` does nothing and may be removed:
2023-07-05 15:11:16 +02:00
```js filename="pages/_app.js"
2019-07-05 17:57:16 +02:00
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() {
// ...
}
}
```