Capítulo 271 de 456

Configuration

Core Idea

Wire a custom deployment adapter into a Next.js project by pointing next.config.js (or an env var) at the adapter module.

Key Concepts

  • adapterPath: next.config.js option set to require.resolve('./my-adapter.js'), the path to your adapter module.
  • NEXT_ADAPTER_PATH: environment variable alternative that enables zero-config adapter usage on deployment platforms (no next.config.js edit needed).

Code Examples

/** @type {import('next').NextConfig} */
const nextConfig = {
  adapterPath: require.resolve('./my-adapter.js'),
}

module.exports = nextConfig
  • O que demonstra: forma canônica de registrar um adapter custom via config.

Anti-patterns

  • Hardcoding a relative string instead of require.resolve: breaks when the config is loaded from a different working directory; require.resolve guarantees an absolute, resolvable path.

Key Takeaways

  1. Two equivalent activation paths exist: adapterPath in config, or NEXT_ADAPTER_PATH env var for platform-level zero-config wiring.
  2. This is the entry point that makes Next.js call into the adapter's modifyConfig/onBuildComplete hooks (see ch272).

Connects To

  • ch272 creating-an-adapter: defines the NextAdapter interface this path points to.