Vercel
The build writes .vercel/output/: static/ for the files, one Node function for everything else, and config.json with routes. Immutable headers, headers and noindex rules become routes of config.json; the function applies every rule itself too. redirect rules are answered by the function, not by config.json, because a route there cannot keep the request query: /old/x?a=1 under "/old/**": { redirect: "/new/**" } goes to /new/x?a=1. Deploy the prebuilt output.
Reference
| Preset | vercel |
| Runs on | Vercel |
event.runtime.name | vercel |
| Server target | node |
| Lifetime, startup | request, request |
Output
.vercel/output/ Build Output API v3
config.json routes: immutable headers, headers and noindex rules, proxy rewrites
static/ the public files
functions/
__hamur.func/ one function for everything else (.vc-config.json, index.mjs)
Config keys
| Key | Default | What it does |
|---|---|---|
vercel.runtime | "node" | "node", "bun" (Bun's runtime on Vercel) or "edge" (an Edge Function) |
vercel.functions | {} | merged into the function's .vc-config.json: maxDuration, memory, regions |
cdnPurge.vercel | unset | purges tags through Vercel for non-ISR answers; see Caching and ISR |
Skew protection
When the build runs with VERCEL_SKEW_PROTECTION_ENABLED=1 and VERCEL_DEPLOYMENT_ID set (Vercel sets both once skew protection is on for the project), a page is pinned to its deploy. ?dpl=<id> is added to the URLs of the import map, the entry script and the modulepreload and stylesheet links, in server-rendered and prerendered pages and in links the client adds on a navigation; x-deployment-id: <id> is sent on Hamur's own requests (server functions, islands, server components, payload files, route manifest and fixed-params files). The version file, document loads and sw.js carry neither, so they reach the newest deploy. A URL inside a CSS or JavaScript file and the public files are not pinned. Without the two variables the output is the same as without this feature. Hamur's own 409 compares build ids and never reads the deployment id.
Detection
The build selects it when VERCEL is set, unless --preset, preset or HAMUR_PRESET names another. It is a row of the one table of markers in Choosing a preset.
Deploy command
hamur deploy builds, then runs vercel deploy --prebuilt --prod; with --preview it runs vercel deploy --prebuilt. See hamur deploy. The preview command of the preset, which hamur preview runs or prints, is vercel deploy --prebuilt.
Limits
- Runs: streamed answers, private
app/env.tsentries read at run time. - Does not run: WebSockets and
server.syncedState,server.pubsub,server.metrics, image transforms at run time, Durable Object classes. - Platform image service:
vercel(whatprovider: "auto"picks). scheduledTasksbecome Vercel Cron Jobs and needCRON_SECRET;tasks.queueuses Vercel Queues (beta);tasks.runOnStartdoes not run. The request body limit is 4.5 MB.- With
vercel.runtime: "edge", private env entries are experimental and storage drivers that need Node or Bun fail the build; with"bun",server.pubsubandtasks.queueare refused.
The levels are the features of the preset: hamur build warns or fails when the app uses a feature the preset does not run (see Preset features).
vercel.functions in the config is merged into the function's .vc-config.json, for example vercel: { functions: { maxDuration: 800, regions: ["fra1"] } }. runtime, handler, launcherType, shouldAddHelpers and supportsResponseStreaming stay Hamur's. A value that is not an object fails when the config loads. getRequestIP(event) returns the first x-real-ip value, which Vercel sets to the client address.
vercel.runtime: "bun" runs the function on Vercel's Bun runtime (Beta) instead of Node (the default, "node"). The server is built for the bun target, the function module calls Bun.serve() once when it loads, which is how Vercel detects a Bun function, and .vc-config.json gets runtime: "bun1.x" and bunVersion: "1.x". The redis and sqlite storage drivers then run on the preset; argon2id stays refused. server.pubsub and tasks.queue fail the build: a function ends with its response, and the queue consumer is a Node function. The vercel workflow deploys a Bun fixture as a preview to check that Vercel accepts the output.
vercel.runtime: "edge" runs the whole app in a Vercel Edge Function. The server is built for the browser target (no node: module, as on cloudflare), .vc-config.json is { "runtime": "edge", "entrypoint": "index.mjs" } (plus regions when vercel.functions.regions is set), and the function default-exports (request, context) => Response; context.waitUntil is Vercel's and getRequestIP(event) is the first x-real-ip value. Storage drivers that need Bun or Node (fs, sqlite, redis) fail the build: Storage mount "data" uses the "sqlite" driver, which the "vercel-edge" preset cannot run (it runs on: bun, static); tasks.queue and isr rules fail it too. A function rule with runtime: "edge" runs only its paths in an Edge Function (a second bundle of the same app in .output/server-edge/, copied to functions/__hamur-<hash>.func) and leaves the rest on the Node function, so the storage check applies for both. The vercel workflow deploys an edge fixture as a preview.
A function route rule runs the paths of its pattern in a function of their own: "/api/export/**": { function: { maxDuration: 300 } } writes functions/__hamur-<hash>.func, a copy of __hamur.func whose .vc-config.json is the main one with maxDuration: 300 over it (vercel.functions and vercel.runtime apply as they do there), and a config.json route ^/api/export(?:/(.*))?$ to it after the static files and the isr routes and before the catch-all. Rules with the same setting share one function; where patterns overlap, the most specific is routed first. See Route rules.
vercel.config.images in the config is merged into the images of config.json, for example vercel: { config: { images: { minimumCacheTTL: 3600 } } }. @hamur/image writes images there for its vercel provider and its keys win. vercel.config that is not an object fails when the config loads.
hamur build --preset vercel
vercel deploy --prebuilt
ISR on Vercel
What isr and revalidation do on each preset is in Caching and ISR.
Each isr route rule becomes a Vercel ISR function with its prerender-config.json. Vercel revalidates the page in the background after isr seconds, and on demand when a request carries the build's bypass token.
- Set
HAMUR_ISR_BYPASS_TOKENat build to a secret of at least 32 characters. A shorter one fails the build:HAMUR_ISR_BYPASS_TOKEN must be at least 32 characters (got 12). Unset, the build makes one and warns:HAMUR_ISR_BYPASS_TOKEN is not set; this build generated one, so only its own functions can revalidate its ISR pages. The token goes into the server bundle, never into the client. Set at run time,HAMUR_ISR_BYPASS_TOKENwins over the build's. revalidatePath("/blog/hello")andinvalidateRouteCache(url)for a path under anisrrule also sendHEAD https://$VERCEL_URL/blog/hellowithx-prerender-revalidate: <token>, so Vercel renders the page again. A path under noisrrule sends nothing. A failed request is logged as a cache error. With Deployment Protection on, enable Protection Bypass for Automation: Vercel then setsVERCEL_AUTOMATION_BYPASS_SECRETand the request sends it asx-vercel-protection-bypass. Without it the request answers 401 and the function warns once, naming that variable.- A query string is not part of the ISR cache key:
/blog/hello?ref=xis the same page as/blog/hello, unless the rule lists names incache.allowQuery. revalidatePath("/blog/[slug]", "page"),"layout"andrevalidateTagreach Vercel's ISR cache only through the tag purge ofserver.cdnPurge.verceland theHEADabove. The first suchrevalidatePathcall warns once:revalidatePath("/blog/[slug]", "page") reaches Vercel's ISR cache only with server.cdnPurge.vercel. Vercel reads no header of an ISR answer, so anisranswer carries no cache tags and the purge does not reach Vercel's ISR copies either; only a concrete path revalidates there, through theHEADabove.- A pattern with a regex constraint, a method key or a condition cannot be routed by
config.json, so its paths are answered by the main function without Vercel's ISR cache.