Capítulo 436 de 456

API Reference (Adapters)

Core Idea

Precise parameter reference for the two NextAdapter lifecycle hooks: modifyConfig and onBuildComplete.

Key Concepts

  • modifyConfig(config, context): called for any CLI command that loads next.config.js. Params: config (complete Next.js config object), context.phase (build phase), context.nextVersion, context.projectDir (absolute path). Returns modified config, sync or async.
  • onBuildComplete(context): called after build completes. Params include context.routing (routing phases/metadata), context.outputs (build outputs by type), context.projectDir, context.repoRoot, context.distDir, context.config (final config with modifyConfig applied), context.nextVersion, context.buildId.
  • context.routing fields: beforeMiddleware, beforeFiles, afterFiles, dynamicRoutes, onMatch, fallback, shouldNormalizeNextData, rsc.

Reference Tables

HookKey params
modifyConfigconfig, context.phase, context.nextVersion, context.projectDir
onBuildCompletecontext.routing, context.outputs, context.projectDir, context.repoRoot, context.distDir, context.config, context.nextVersion, context.buildId

Key Takeaways

  1. context.config em onBuildComplete já reflete as mudanças aplicadas por modifyConfig.
  2. routing.shouldNormalizeNextData indica se URLs /_next/data/<buildId>/... devem ser normalizadas durante o matching.
  3. routing.rsc carrega metadata de roteamento específica de React Server Components.

Connects To

  • Creating an Adapter (ch435): exemplo de uso desses hooks.
  • Routing Information (ch442): detalhamento de cada fase de routing.
  • Output Types (ch441): detalhamento de cada tipo em outputs.