Files
vercel__next.js/docs/01-app/03-api-reference/07-adapters/03-api-reference.mdx
Eddy (Frontend Engineer) 24f975677e docs(adapters): document assetsHashes and routing.middlewareMatchers (#96536)
While writing an adapter against `16.3.0-canary.107` I noticed the
adapter docs are missing two fields that the shipped `NextAdapter` types
already have.

**`assetsHashes`** — every `PAGES` / `PAGES_API` / `APP_PAGE` /
`APP_ROUTE` / `MIDDLEWARE` output carries it right next to `assets`, and
it's declared with a doc comment in `build-complete.d.ts`, but none of
the five shapes in Output Types mention it.

**`routing.middlewareMatchers`** — dumping the `routing` object from a
real `onBuildComplete` call gives:

```
afterFiles, beforeFiles, beforeMiddleware, dynamicRoutes, fallback,
middlewareMatchers, onMatch, rsc, shouldNormalizeNextData
```

but the docs list eight of those nine, everywhere the interface appears:
the Creating an Adapter snippet (which says "The interface is defined as
follows"), the API Reference parameter list, and Routing Information.
This one feels worth fixing soon — an adapter that does its own request
matching from the documented fields alone has no way to decide when
middleware should run. My guess for why nobody has hit it: if you pass
`routes: routing` wholesale into `resolveRoutes` from `@next/routing`,
everything works without ever looking at the field.

The wording I added comes from the doc comments in the shipped types,
not my own descriptions. `middlewareMatchers` is inserted where the type
puts it (right after `beforeMiddleware`).

For what it's worth: I checked the rest of the section against the same
build while I was at it — the `output: 'export'` behavior, the prerender
classification fields, `pprChain.headers`, the fallback fields, the
immutable-assets flow, and the `@next/routing` params/result — and
everything else matched the docs. These two were the only gaps I found.
2026-08-24 11:37:53 +02:00

42 lines
2.2 KiB
Plaintext

---
title: API Reference
description: Reference for `modifyConfig` and `onBuildComplete` in the `NextAdapter` interface.
---
## `async modifyConfig(config, context)`
Called for any CLI command that loads the `next.config.js` file to allow modification of the configuration.
**Parameters:**
- `config`: The complete Next.js configuration object
- `context.phase`: The current build phase (see [phases](/docs/app/api-reference/config/next-config-js#phase))
- `context.nextVersion`: Version of Next.js being used
- `context.projectDir`: Absolute path to the Next.js project directory
**Returns:** The modified configuration object (can be async)
## `async onBuildComplete(context)`
Called after the build process completes with detailed information about routes and outputs.
**Parameters:**
- `context.routing`: Object containing Next.js routing phases and metadata
- `routing.beforeMiddleware`: Routes executed before middleware (includes header and redirect handling)
- `routing.middlewareMatchers`: Middleware matcher definitions for this build, used to decide whether middleware should be invoked for a given request
- `routing.beforeFiles`: Rewrite routes checked before filesystem route matching
- `routing.afterFiles`: Rewrite routes checked after filesystem route matching
- `routing.dynamicRoutes`: Dynamic route matching table
- `routing.onMatch`: Routes applied after a successful match (for example immutable static asset cache headers)
- `routing.fallback`: Final rewrite fallback routes
- `routing.shouldNormalizeNextData`: Whether `/_next/data/<buildId>/...` URLs should be normalized during matching
- `routing.rsc`: Route metadata used for React Server Components routing behavior
- `context.outputs`: Detailed information about all build outputs organized by type
- `context.projectDir`: Absolute path to the Next.js project directory
- `context.repoRoot`: Absolute path to the detected repository root
- `context.distDir`: Absolute path to the build output directory
- `context.config`: The final Next.js configuration (with `modifyConfig` applied)
- `context.nextVersion`: Version of Next.js being used
- `context.buildId`: Unique identifier for the current build