Host on Vercel
Vercel runs the app as WebAssembly in a Node function, or on its Edge runtime.
Build
rustup target add wasm32-unknown-unknown # once
wisp build --target vercel # .vercel/output
wisp build --target vercel --edge # every route on the Edge runtime
In Vercel's CI a plain wisp build picks the target from VERCEL and writes to .vercel/output.
Deploy
npx vercel deploy --prebuilt
wisp deploy init vercel writes a GitHub Actions workflow that builds and deploys on push to main. It reads the secrets VERCEL_TOKEN, VERCEL_ORG_ID and VERCEL_PROJECT_ID.
WebSockets
Vercel's Node functions take WebSockets in beta (Vercel docs): they need Fluid compute, a connection stays on the instance that took it, and it closes at the function's maximum duration. Wisp's support for them waits on a deploy test, so for now a WebSocket route answers 501 on Vercel, and wisp build --target vercel (or wisp check --target vercel) warns, naming each one. Use Response::events (SSE) or a realtime service there (Where there are no WebSockets).
The Edge runtime takes no upgrades. With --edge a WebSocket route answers 501 and the build warns; a route with RUNTIME = Edge that upgrades stops the build, naming the line.
Environment
WISP_SECRETas an environment variable of the project, for an app that signs cookies.- Read other values with
wisp::env("KEY")(std::env::varsees nothing). CRON_SECRET, if the app haswisp::cron: set it too; Vercel's cron sends it.- Environment variables.
Limits
- Per route:
const RUNTIME: wisp::Runtime = wisp::Runtime::Edge;in a+page.rsor+server.rsputs that route on the Edge runtime and the rest stay on the Node function. See Edge runtime per route. - The build stops, naming the route, if an Edge route uses what WebAssembly lacks (
std::fs,std::thread,std::process,std::net, websockets). - WebSockets answer 501 for now (above). Streaming is live.
- Both the Edge runtime and the Node function keep what the app starts past its reply (
wisp::spawn,wisp::sleep) alive through Vercel'swaitUntil, until it is done. - The client's address: Vercel's proxy is the function's peer, so the Node function's
.vc-config.jsonsetsWISP_CLIENT_IP_HEADER=x-real-ip, a header Vercel sets itself and overwrites, andcx.client_ip()is the client's. The Edge runtime reads the same header. - Cron:
wisp::cronbecomescronsinconfig.json(Hobby plan: daily only). Vercel counts the weekday 0 (Sunday) to 6 and takes no names, so the build converts a 7 to 0. Vercel takes a day of the month or of the week, not both: the build stops with an error for a schedule that restricts both. - Vercel's own limits: 4.5 MB of request or reply body on a function; 300 s by default with Fluid compute (
max_durationbelow); an Edge function must start its reply within 25 s and is at most 1 MB gzipped on Hobby (2 MB Pro, 4 MB Enterprise); the build warns when its wasm gzips past 1 MB. wisp::everyis not in the edge build.RateLimitcounts in the memory of each instance, so each instance has its own count.wisp::channelreaches only the subscribers of its own instance.
Function settings
The functions' region, longest run and memory come from [package.metadata.wisp.vercel] in the app's Cargo.toml, written into each .vc-config.json:
[package.metadata.wisp.vercel]
regions = ["iad1"] # near the database; both runtimes
max_duration = 60 # seconds, or "max" (the plan's); the Node function
memory = 1024 # MB, 128 to 10240; the Node function
A key it does not know, or a value out of range, stops the build before it compiles. See Configuration.
Files and Data
static/goes to.vercel/output/staticand stays the CDN's.config.jsongives those files the headers the app's own server sends (x-content-type-options: nosniff,referrer-policy: strict-origin-when-cross-origin), matched by their paths, so the function's replies keep the app's own.Table::savedandRestare per-instance memory.WISP_STOREacceptslibsql://(Turso or any libSQL server, withWISP_STORE_TOKEN); see Saved tables.wisp::kvandwisp::blobsneed a driver:WISP_KV_<NAME>=upstash(Vercel KV and Marketplace Redis setKV_REST_API_URL),WISP_BLOB_<NAME>=vercel-blob(withBLOB_READ_WRITE_TOKEN). See Storage.
More
Edge and serverless targets, Deploying.
Is This Page Useful?