You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Before deciding to use a custom server please keep in mind that it should only be used when the integrated router of Next.js can't meet your app requirements. A custom server will remove important performance optimizations, like serverless functions and Automatic Static Optimization.
After reading this, my assumption is that automatic static optimization is not being used if we use a custom server. However, the following excerpt from the blog announcing Next.js 9 seems to contradict this:
This heuristic allows Next.js to emit hybrid applications that contain both server-rendered and statically generated pages.
The built-in Next.js server (next start) and programmatic API (app.getRequestHandler()) both support this build output transparently. There is no configuration or special handling required.
I was a bit confused so I did some tests and it seems that even when using a custom server pages not including any data fetching requirements (i.e. getInitialProps, getServerSideProps, etc.) are being generated as static pages. Furthermore, pages including getStaticProps are being generated using SSG (static HTML + JSON). This seems to verify what the second excerpt above states.
Another thing I noticed though is that the first excerpt referenced above says that "A custom server will remove important performance optimizations". So could it be that the files are automatically statically optimized but using a custom server would cancel this optimization?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Hey 👋
According to the docs:
After reading this, my assumption is that automatic static optimization is not being used if we use a custom server. However, the following excerpt from the blog announcing Next.js 9 seems to contradict this:
I was a bit confused so I did some tests and it seems that even when using a custom server pages not including any data fetching requirements (i.e.
getInitialProps
,getServerSideProps
, etc.) are being generated as static pages. Furthermore, pages includinggetStaticProps
are being generated using SSG (static HTML + JSON). This seems to verify what the second excerpt above states.Another thing I noticed though is that the first excerpt referenced above says that "A custom server will remove important performance optimizations". So could it be that the files are automatically statically optimized but using a custom server would cancel this optimization?
Can anyone clarify this?
Beta Was this translation helpful? Give feedback.
All reactions