Deploy
Deploy to Vercel
Put a White.js site on Vercel with white-plugin-vercel: static files on the CDN, the app as one function.
white-plugin-vercel builds a Build Output API bundle from your project. Static files from app/public go to Vercel's CDN, and the whole app (routes, views, plugins) runs as one function. You do not write an api/ folder or copy any config.
#Quick start
white plugin add vercel
npx white-vercel init
npx white-vercel deploy # a preview
npx white-vercel deploy --prod # productionwhite plugin add vercelinstallswhite-plugin-vercelas a dependency and adds it topluginsinwhite.config.js.white-vercel initcreatesvercel.jsonand adds.vercelto.gitignore.white-vercel deploybuilds.vercel/outputand runsvercel deploy --prebuilt. The first run asks you to sign in and link the project.
#Deploy from Git
After white-vercel init, push the repository and import it in Vercel. The generated vercel.json makes Vercel run npx white-vercel build and deploy its output:
{
"framework": null,
"installCommand": "npm install",
"buildCommand": "npx white-vercel build"
}#What the build writes
.vercel/output/
config.json static files first, everything else to the function
static/ contents of app/public, served by the CDN
functions/_white.func/
index.cjs entry called by Vercel
server/ app/ your code and views
node_modules/ production dependencies only- Files requested with a content hash (
it.w.asset('/css/base.css')gives?v=…) are sent withCache-Control: public, max-age=31536000, immutable, likewhite rundoes. .envfiles,.gitandnode_modulesof your project are never copied into the function. Set secrets in the Vercel project settings.- The app is built once per instance on the first request and reused.
start()is never called, because Vercel owns the socket.
#Options
Pass options to the plugin in white.config.js, or use the flags of white-vercel build and deploy. Flags win.
export default {
plugins: [
['white-plugin-vercel', {
include: ['content'], // extra folders or files the function needs
runtime: 'nodejs24.x', // default: from engines.node, else nodejs24.x
maxDuration: 30, // seconds
memory: 1024, // MB
trustProxy: 1, // proxies in front of the function (Vercel is one)
}],
],
};| Option | Flag | Default | What it does |
|---|---|---|---|
include |
--include <path> |
[] |
Folders outside dirs.* that the app reads at run time (Markdown content, data files) |
runtime |
--runtime |
from engines.node |
nodejs22.x, nodejs24.x or nodejs26.x |
maxDuration |
--max-duration |
Vercel default | Function timeout in seconds |
memory |
--memory |
Vercel default | Function memory in MB |
regions |
Vercel default | List of Vercel regions | |
trustProxy |
1 |
Value of trust proxy on Vercel |
|
install |
--no-install |
true |
Run npm ci in the function folder |
The top-level folders of dirs.routes, dirs.views, dirs.public, dirs.meta and dirs.migrations are always included. Anything else your code reads from disk must be listed in include.
#What the plugin changes at run time
On Vercel (the VERCEL environment variable is set) the plugin:
- sets
trust proxyto1, soreq.ip,req.protocol, rate limits and the CSRF origin check see the visitor and not the proxy; - exposes
ctx.vercelandit.vercelin views:{ env, region, url, productionUrl, deploymentId, commit }; - logs a warning if
meshis configured, see below.
Off Vercel it does nothing, so it can stay in white.config.js while you develop.
#Limits to know
- Memory is per instance.
ctx.cache, rate limits and mesh replay protection are not shared between instances, and instances come and go. Use Vercel Firewall for a limit that holds everywhere, and an external store for shared state. - The file system is read-only except
/tmp. - Mesh (signed calls between services) works between deployments over HTTPS, but pass a shared
noncesstore when more than one instance can receive calls./readyis not used for load balancing on Vercel. - No live reload and no
white run. Usewhite run devlocally andvercel devis not needed.
#Use your own function
If you prefer to own the entry, export the handler from your own api/index.js and route everything to it in vercel.json:
// api/index.js
import { createHandler } from 'white-plugin-vercel/handler';
export default createHandler();{ "rewrites": [{ "source": "/(.*)", "destination": "/api" }] }#Troubleshooting
| Message | Cause and fix |
|---|---|
white-plugin-vercel must be in "dependencies" |
It is loaded inside the function. Run white plugin add vercel, not npm i -D. |
npm ci … failed |
package-lock.json is out of sync with package.json. Run npm install and commit the lock file. |
| Page works locally but is empty or 500 on Vercel | A folder the code reads is missing from the function. Add it to include. |
Unsupported runtime |
Vercel offers Node 22, 24 and 26. Set engines.node or --runtime. |