Search⌘ K
AI Features

Using a Custom Server

Explore how to integrate Next.js with custom servers such as Express.js and Fastify. Understand when custom servers are necessary, typical use cases including multitenancy and MVC architecture, and the trade-offs like Vercel deployment limitations. This lesson helps you determine if a custom server suits your Next.js project needs and how to implement it effectively.

As we’ve already seen, Next.js ships with its own server, so we don’t need to configure a custom one to get started with writing web applications with this framework. Still, there are some cases where we may want to serve a Next.js app from a custom web server, such as Express.js or Fastify, and the framework makes this possible by exposing some straightforward APIs that we’ll be looking into in just one moment. But before looking at the implementation, let’s answer an important question: do we really need a custom server?

The short answer is, most of the time, no. Next.js is such a ...