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.
My understanding is that thanks to it, during the build phase (
next build) it will automatically generate an HTML file (for pages that qualify) which will be then served in future requests.
Now, what is preventing nextjs handler in the custom server from using already generated files from the
next build step and serving them just as the built-in server would?
I tested serving app with the built-in server (
next start) and with a custom server and I have not found any difference between them, even when it comes to the Automatic Static Optimization. In both cases, static HTML files were generated for a simple page with no
getInitialProps and it served the page without a problem.
Have I misunderstood what the Automatic Static Optimization is really doing? Or something else?