Host on Netlify
Netlify runs the app as WebAssembly in a function, or in an edge function with --edge.
Build
rustup target add wasm32-unknown-unknown # once
wisp build --target netlify # dist/netlify
wisp build --target netlify --edge # edge function
In Netlify's CI a plain wisp build picks the target from NETLIFY.
Deploy
From dist/netlify:
npx netlify deploy --prod
wisp deploy init netlify writes a GitHub Actions workflow that builds and deploys on push to main. It reads the secrets NETLIFY_AUTH_TOKEN and NETLIFY_SITE_ID.
Environment
WISP_SECRETas an environment variable of the site, 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; the scheduled function sends it.- Environment variables.
Limits
- Per route:
const RUNTIME: wisp::Runtime = wisp::Runtime::Edge;puts a route on the edge; the rest stay on the function. See Edge runtime per route. - Edge functions have the edge limits (no
std::fs,std::thread,std::process,std::net, websockets); the build stops, naming the route, if an Edge route uses them. - WebSockets answer 501: Netlify's functions take no upgrade.
wisp build --target netlifywarns, naming each WebSocket route; useResponse::events(SSE) or a realtime service (Where there are no WebSockets). Streaming is live. - Netlify keeps the instance alive (
waitUntil) for started timers and fetches. - Cron:
wisp::cronbecomes a scheduled function,functions/wisp-cron-<n>.mjs, one per schedule. With--edgethere is no trigger to write: the build says so and stops. - Background functions (15 minutes) are not written: SvelteKit's and Next's Netlify adapters ship none either. Queue the work with
wisp::workinstead. - Netlify's own limits: a function answers within 10 s by default (26 s at most), with 6 MB of request or reply; scheduled functions run 30 s; edge functions have 50 ms of CPU a request and a bundle of at most 20 MB; the build warns when the edge function's
app.wasm.jsis over it. 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.
Files and Data
static/goes topublic, which Netlify serves; with--edgethe edge function skips it viaexcludedPath.netlify.tomlgives those files the headers the app's own server sends (X-Content-Type-Options: nosniff,Referrer-Policy: strict-origin-when-cross-origin); Netlify applies its header rules to static files only, so the app's replies keep their own.- The function is
functions/wisp/wisp.mjs(the edge functionnetlify/edge-functions/wisp/wisp.mjs), with itsbridge.mjsandapp.wasm.jsbeside it: Netlify makes a function of every top-level file of those folders, so the helpers sit inwisp/. The wasm is inlined as base64, since Netlify documents no.wasmimport for its functions or edge functions. Table::savedandRestare per-instance memory.WISP_STOREacceptslibsql://(Turso or any libSQL server, withWISP_STORE_TOKEN); see Saved tables.wisp::kvandwisp::blobsdefault to Netlify Blobs, the site store of the same name (WISP_KV_<NAME>=netlify-blobs). See Storage.
More
Edge and serverless targets, Deploying.
Is This Page Useful?