handlePublicFiles
Copies files from thepublic directory to the Vercel output static directory.
Signature
Parameters
Absolute path to the Next.js
public folder.Absolute path to the Vercel output directory (e.g.,
.next/output).Next.js configuration object, used to apply
basePath to static files.Behavior
- Reads top-level items from the public folder
- Copies each item to
{vercelOutputDir}/static/{basePath}/{item} - Uses a semaphore to limit concurrent file operations to 16
- Silently continues if the public folder doesn’t exist
handleStaticOutputs
Processes static file outputs (HTML, assets) from the Next.js build.Signature
Parameters
Array of static file outputs from Next.js build.
Next.js configuration object.
Vercel configuration object to modify with overrides.
Absolute path to the Vercel output directory.
Behavior
- Copies static files to the output directory
- For HTML files: adds content-type override and path without extension
- Creates a
not-found.txtfile for 404 responses on_next/staticresources - Uses a semaphore to limit concurrent operations
Example
handleNodeOutputs
Processes Node.js runtime outputs (pages, API routes) into serverless functions.Signature
Parameters
Array of Node.js function outputs. Can include pages, API routes, app pages, and app routes.
Next.js configuration object.
Absolute path to the
.next directory.Absolute path to repository root.
Absolute path to Next.js project directory.
Next.js version string.
Whether this is middleware (uses Web API instead of Node.js API).
Map of prerender paths with
fallback: false.Absolute path to Vercel output directory.
Behavior
- Creates a
.funcdirectory for each function - Generates a launcher file (
___next_launcher.cjs) - Creates a
.vc-config.jsonwith function configuration - Includes 404/error handlers in function assets
- Supports workflow step and workflow configurations
- Handles deterministic routes manifest
Function configuration
The generated.vc-config.json includes:
runtime: Node.js runtime versionhandler: Path to launcher filefilePathMap: All required filesmaxDuration: Execution timeoutoperationType: “PAGE” or “API”framework:{ slug: "nextjs", version: "..." }supportsResponseStreaming: trueuseWebApi: true for middleware
handleEdgeOutputs
Processes Edge runtime outputs into Edge Functions.Signature
Parameters
Similar tohandleNodeOutputs, but for Edge runtime outputs.
Array of Edge runtime outputs.
Behavior
- Separates JavaScript and non-JavaScript assets
- Generates Edge Function wrapper source
- Handles WASM assets
- Creates
index.jsentry point - Creates
.vc-config.jsonwith Edge Function configuration
Edge function configuration
The generated.vc-config.json includes:
runtime: “edge”entrypoint: Path to index.jsfilePathMap: JS filesassets: Non-JS filesdeploymentTarget: “v8-worker”environment: Environment variablesregions: Deployment regions
handlePrerenderOutputs
Processes prerendered outputs for ISR and SSG pages.Signature
Parameters
Array of prerender outputs.
Whether the build includes App Router entries.
Map of parent function outputs by ID.
Content-Type header for RSC responses.
Vary header value for App Router.
Behavior
- Creates symbolic links from prerender paths to parent functions
- Generates
.prerender-config.jsonfiles with ISR configuration - Handles fallback files with postponed state for PPR
- Sets proper content-type headers for RSC and HTML
- Configures revalidation and bypass tokens
Prerender configuration
The generated.prerender-config.json includes:
group: Revalidation group IDexpiration: Revalidate time in secondsstaleExpiration: Stale-while-revalidate timesourcePath: Path to parent functionpassQuery: trueallowQuery: Allowed query parametersallowHeader: Allowed headers for cache variancebypassToken: ISR bypass tokenexperimentalBypassFor: Bypass configurationinitialHeaders: Headers from fallbackinitialStatus: Status code from fallbackfallback: Path to fallback filechain: PPR chain configuration
handleMiddleware
Processes middleware output and generates middleware routes.Signature
Parameters
Middleware output with runtime and matcher configuration.
Return value
Returns an array of middleware routes. Each route includes:src: Source regex from matcherhas/missing: ConditionsmiddlewarePath: Path to middleware functionmiddlewareRawSrc: Original source patternscontinue: trueoverride: true
Behavior
- Delegates to
handleNodeOutputsorhandleEdgeOutputsbased on runtime - Generates routes for each matcher in the middleware config
- Routes include middleware path for execution