Sandbox
Run code in an isolated cloud machine on Vercel or Cloudflare, and get the result in your route.
Deploys on
server/sandbox-tasks/pixels/index.tsSame on every host
type ImageSize = { width: number, height: number }
// This runs in its own isolated machine.
// It is a normal function, with no special imports.
export default async function count(
{ width, height }: ImageSize,
) {
return { pixels: width * height }
}Deploy on
Vercel: Vercel Sandbox
A folder is a Sandbox Task
Put a
package.json and index.ts in a folder under server/sandbox-tasks. The folder name is the task name.Plain code and npm packages
The entry point is a standard async function. Its dependencies install in the Sandbox, not in your app.
Call it from a route
runSandboxTask() sends the input and returns [error, data]. Your function sets the input and result types.