Capítulo 442 de 456
Schema for the routing object passed to onBuildComplete, describing the ordered phases Next.js uses to match a request to a route, with pre-processed patterns ready for platform deployment.
routing.beforeMiddleware: routes applied before middleware execution, including generated header/redirect behavior.routing.beforeFiles: rewrite routes checked before filesystem route matching.routing.afterFiles: rewrite routes checked after filesystem route matching.routing.dynamicRoutes: dynamic matchers from segments like [slug] and catch-alls.routing.onMatch: routes applied after a successful match (e.g. immutable cache headers for hashed static assets).routing.fallback: final rewrite routes checked when earlier phases found no match.source?, sourceRegex, destination?, headers?, has?, missing?, status?, priority?.beforeMiddleware → beforeFiles → filesystem match → afterFiles → dynamicRoutes → onMatch/fallback) definem a ordem exata de matching que um adapter precisa reproduzir.onMatch é o lugar certo pra aplicar headers de cache imutável em assets com hash.sourceRegex pré-compilado, evitando reimplementar a compilação de padrões no adapter.resolveRoutes() consome exatamente este objeto routing.context.routing é formalmente definido como parâmetro de onBuildComplete.