Nextjs Fundamentals · Deployment & Operations

Adapters

the Deployment Adapter API

Adapters

A platform may not run a plain next start server. The Deployment Adapter API lets it customise how a Next.js app is built and deployed for its own infrastructure. Point Next.js at the adapter in next.config.js:

// next.config.js
module.exports = {
  adapterPath: require.resolve('./my-adapter.js'),
};

An adapter is a module that exports an object with two hooks. modifyConfig runs whenever the config is loaded and can adjust it. onBuildComplete runs after the build and receives the routes and the outputs, grouped by type — pages, app pages, app routes, prerenders, static files, and Proxy:

const adapter = {
  name: 'my-adapter',
  async modifyConfig(config, { phase }) {
    return config;
  },
  async onBuildComplete({ routing, outputs, buildId }) {
    // Emit platform-specific output from `outputs`.
  },
};

The adapter declares which output types it can serve. One adapter may handle only static files; another may support dynamic rendering by running routes on a Node runtime. The same public API powers every platform, and an adapter that passes the compatibility test suite is a verified adapter.

You are about to answer a short quiz on the Deployment Adapter API.

  1. The Deployment Adapter API lets a platform customise how a Next.js app is built and deployed.
  2. You point Next.js at an adapter with the ___ option in next.config.js.
  3. An adapter's onBuildComplete hook receives the build outputs grouped by type.
  4. An adapter's ___ hook runs when the config is loaded and can modify it.
  5. An adapter declares which output types it can serve, such as static files or dynamic Node routes.
  6. Each platform needs its own private API to build an adapter.