Newsletter
Join the Community
Subscribe to our newsletter for the latest news and updates
A template project for building high-performance, portable, and safe serverless functions in Vercel.
Vercel Wasm Runtime is a Next.js boilerplate for deploying WebAssembly-powered serverless functions to Vercel, using Rust compiled to wasm32-wasi and executed by the WasmEdge runtime.
Vercel Wasm Runtime is a template project created by Second State that demonstrates how to build serverless functions running WebAssembly on Vercel. The main branch implements an image processing function: it receives a PNG file, passes the image data as stdin to a spawned child process running the WasmEdge CLI, and returns the grayscaled result. The tensorflow branch replaces that with an AI inference function, also written in Rust. The project is scaffolded with create-next-app and is designed to deploy to the Vercel platform.
api/hello.js to satisfy Vercel's serverless function requirement; it spawns a child process and pipes stdin to the WasmEdge command.api/pre.sh script downloads the WasmEdge CLI version 0.8.1 during Vercel builds so the runtime is available when the function invokes it.api/functions/image-grayscale/src/main.rs and compiles to a grayscale.wasm binary using cargo with --target wasm32-wasi.main branch shows image processing; the tensorflow branch shows TensorFlow inference, expanding from image processing to AI workloads.create-next-app, the repo includes the standard Next.js structure for pages and API routes, and the README links to the official Next.js documentation and deployment guide.The repository defines a custom build step in api/pre.sh that downloads the WasmEdge CLI. The serverless function in api/hello.js receives a PNG, spawns a child process running WasmEdge with the compiled grayscale.wasm, and passes the image bytes over stdin. For local development, you move the endpoint into pages/api/ and adjust it, since the README notes this is required outside Vercel.
The README states that for local development you must move api/hello.js into pages/api/ and make changes, because the project is structured to meet Vercel's serverless function requirement rather than Next.js's default API layout.
The function receives a PNG file, which it pipes to the WasmEdge child process as stdin. The output is the grayscaled version of that image.
The tensorflow branch demonstrates an AI inference serverless function, also written in Rust and running on WasmEdge. It offers a second reference example beyond image processing.
