Overview
Server functions let you run backend logic inside your Canvas app. Write TypeScript or JavaScript handlers that execute server-side with access to environment variables, a built-in KV store, andfetch — without managing infrastructure.
How it works
- Include server function source files in your deploy’s
source_filesmap - Files under
api/become HTTP endpoints at/functions/ - Canvas transpiles TypeScript → JavaScript via esbuild and executes your handler in a sandboxed async context
Writing a server function
Export a default function that receives a context object and returns a response:Context object
Your handler receives actx object with:
Return value
Return an object with:Key-value store
Every app has a built-in Redis-backed KV store, accessible in server functions viactx.kv:
Calling the Mixpeek API
Usefetch to call the Mixpeek API through the Canvas proxy — credentials are injected automatically:
Deploying with source files
Include your server functions in thesource_files field when deploying:
Runtime logging
console.log, console.warn, console.error, and console.info calls in server functions are captured and sent to the runtime logs system. View them in Studio or query via API.
Limitations
- Execution timeout: 30 seconds per request
- Request body size: 1 MB max
- No filesystem access: Server functions run in a sandboxed context
- No npm imports: Only
fetchand thectxAPIs are available in the execution context - TypeScript only:
.tsand.jsfiles are supported (transpiled via esbuild)

