Wisp is in pre-release, self-hosted since GitHub suspended us. Install it, or see the changelog.

Wisp

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_SECRET as an environment variable of the site, for an app that signs cookies.
  • Read other values with wisp::env("KEY") (std::env::var sees nothing).
  • CRON_SECRET, if the app has wisp::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 netlify warns, naming each WebSocket route; use Response::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::cron becomes a scheduled function, functions/wisp-cron-<n>.mjs, one per schedule. With --edge there 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::work instead.
  • 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.js is over it.
  • wisp::every is not in the edge build. RateLimit counts in the memory of each instance, so each instance has its own count. wisp::channel reaches only the subscribers of its own instance.

Files and Data

  • static/ goes to public, which Netlify serves; with --edge the edge function skips it via excludedPath. netlify.toml gives 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 function netlify/edge-functions/wisp/wisp.mjs), with its bridge.mjs and app.wasm.js beside it: Netlify makes a function of every top-level file of those folders, so the helpers sit in wisp/. The wasm is inlined as base64, since Netlify documents no .wasm import for its functions or edge functions.
  • Table::saved and Rest are per-instance memory. WISP_STORE accepts libsql:// (Turso or any libSQL server, with WISP_STORE_TOKEN); see Saved tables.
  • wisp::kv and wisp::blobs default 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?

View This Page's Source

Type to search every docs page and heading.