Capítulo 279 de 456

Output Types

Core Idea

Reference for every entry shape inside AdapterOutputs, the typed build-output arrays an adapter receives in onBuildComplete.

Key Concepts

  • outputs.pages: React pages from pages/ (type: 'PAGES').
  • outputs.pagesApi: API routes from pages/api/ (type: 'PAGES_API').
  • outputs.appPages: React pages from app/ (type: 'APP_PAGE'); pathname includes .rsc suffix for RSC routes.
  • outputs.appRoutes: API/metadata routes from app/ (type: 'APP_ROUTE').
  • outputs.prerenders: ISR-enabled routes and static prerenders (type: 'PRERENDER'), with routeType/response/compute classification.
  • outputs.staticFiles: static assets and auto-statically-optimized pages (type: 'STATIC_FILE'), carrying immutableHash when content-hashed.
  • outputs.middleware: the middleware.ts/proxy.ts function, if present (type: 'MIDDLEWARE').
  • config.output: 'export': when set, only outputs.staticFiles is populated; all other arrays are empty.

Code Examples

// Shared shape for pages / pagesApi / appPages / appRoutes / middleware
{
  type: 'PAGES' | 'PAGES_API' | 'APP_PAGE' | 'APP_ROUTE' | 'MIDDLEWARE'
  id: string
  filePath: string
  pathname: string
  sourcePage: string
  runtime: 'nodejs' | 'edge'
  assets: Record<string, string>       // relative repo path -> absolute path
  wasmAssets?: Record<string, string>
  edgeRuntime?: {
    modulePath: string
    entryKey: string
    handlerExport: string
  }
  config: {
    maxDuration?: number
    preferredRegion?: string | string[]  // deprecated
    env?: Record<string, string>          // edge runtime only
  }
}
// PRERENDER
{
  type: 'PRERENDER'
  id: string
  pathname: string
  parentOutputId: string
  groupId: number                 // shared groupId revalidates together
  route: string                   // e.g. /blog/[slug]
  routeType?: 'route' | 'fallback' | 'shell' | 'page'
  response?: 'empty' | 'initial' | 'complete'
  compute?: 'blocking' | 'resuming' | 'static'
  htmlSize?: number
  pprChain?: { headers: Record<string, string> }
  parentFallbackMode?: false | null | string
  fallback?: {
    filePath: string | undefined
    initialStatus?: number
    initialHeaders?: Record<string, string | string[]>
    initialExpiration?: number
    initialRevalidate?: number | false
    postponedState: string | undefined
  }
  config: {
    allowQuery?: string[]
    allowHeader?: string[]
    bypassFor?: RouteHas[]
    renderingMode?: 'STATIC' | 'PARTIALLY_STATIC'
    partialFallback?: boolean
    bypassToken?: string
  }
}
// STATIC_FILE
{
  type: 'STATIC_FILE'
  id: string
  filePath: string
  pathname: string
  immutableHash: string | undefined
}
  • O que demonstra: as três formas de saída mais distintas: o "shape" comum de rotas, o shape especializado de prerenders (com classificação PPR/ISR), e o shape simples de arquivos estáticos.

Reference Tables

routeTypeMeaning
routeNon-UI route (Route Handler)
pagePage with no missing prerenderable params
shellMost specific reusable page shell for a URL class
fallbackReusable response specialized by filling more params
responseMeaning
emptyNo initial page response can be served
initialInitial response servable, but not the completed UI (partially prerenderable)
completeResponse is complete (can be zero-byte, e.g. 204)
computeMeaning
blockingNo response before request-time compute starts; can stream once started
resumingInitial response served while postponed work resumes server-side
staticNo per-request server compute needed

Anti-patterns

  • Assuming all output types are populated with output: 'export': only staticFiles is populated in that mode; code iterating outputs.pages etc. must handle empty arrays gracefully.
  • Reading htmlSize/routeType/response/compute off related RSC/data/segment outputs: these fields exist only on the primary App Router HTML output within a prerender group.

Key Takeaways

  1. routeType + response + compute together classify exactly how much of a prerendered route can be served statically vs. requires request-time work.
  2. htmlSize: 0 specifically means an empty HTML shell, not "field absent" — check for undefined vs 0 explicitly.
  3. assets/wasmAssets maps give the adapter the full traced dependency graph per output, keyed by relative repo path.
  4. Static export mode collapses the whole output surface down to staticFiles only — a major branch point for adapter logic.

Connects To

  • ch276 implementing-ppr-in-an-adapter: consumes prerenders[].fallback fields directly.
  • ch282 supporting-immutable-static-assets: consumes staticFiles[].immutableHash.
  • ch278 invoking-entrypoints: consumes edgeRuntime metadata shown here.