Capítulo 273 de 456

API Reference

Core Idea

Field-by-field reference for the two NextAdapter lifecycle functions: modifyConfig and onBuildComplete.

Key Concepts

  • async modifyConfig(config, context): called for any CLI command that loads next.config.js, to let the adapter mutate the config.
  • async onBuildComplete(context): called once the build finishes, with detailed routing and output data.

Reference Tables

modifyConfig paramMeaning
configComplete Next.js configuration object
context.phaseCurrent build phase
context.nextVersionNext.js version in use
context.projectDirAbsolute path to project dir
ReturnsModified config object (may be async)
onBuildComplete paramMeaning
context.routing.beforeMiddlewareRoutes executed before middleware (headers/redirects)
context.routing.beforeFilesRewrites checked before filesystem matching
context.routing.afterFilesRewrites checked after filesystem matching
context.routing.dynamicRoutesDynamic route matching table
context.routing.onMatchRoutes applied after a successful match (e.g. immutable cache headers)
context.routing.fallbackFinal rewrite fallback routes
context.routing.shouldNormalizeNextDataWhether /_next/data/<buildId>/... URLs are normalized during matching
context.routing.rscRoute metadata for RSC routing behavior
context.outputsBuild outputs organized by type (see Output Types)
context.projectDirAbsolute path to project dir
context.repoRootAbsolute path to detected repository root
context.distDirAbsolute path to build output dir
context.configFinal config, with modifyConfig applied
context.nextVersionNext.js version in use
context.buildIdUnique identifier for the current build

Key Takeaways

  1. modifyConfig operates on the raw config before build; onBuildComplete operates on the finished artifact graph.
  2. context.config inside onBuildComplete already reflects any changes modifyConfig made.
  3. routing.rsc and routing.shouldNormalizeNextData are the fields most relevant to adapters that need to mimic Next.js's own RSC/data-URL matching.

Connects To

  • ch272 creating-an-adapter: the interface these hooks belong to.
  • ch280 routing-information: deeper reference on the routing phases listed here.