Q20: When and why would you use a Custom Server (server.js) with Pages Router?
A custom Node.js server (using Express or Fastify) was traditionally used to integrate custom backend routing or legacy HTTP proxies. Warning: Custom servers disable Automatic Static Optimization and cannot be deployed to serverless environments like Vercel.
Key Takeaways
- Integrates custom Node.js frameworks (Express) with Next.js page rendering.
- Disables Vercel serverless deployments and static optimization.
Knowledge Check
What primary feature is lost when using a custom Express server.js file with Next.js?