Skip to main content
Functions turn the files in a folder, api/ by default, into HTTP endpoints next to your static frontend. Pxxl builds them with your site and serves both from one deployment and one domain, so your frontend calls /api/... without CORS. Existing Vercel api/ handlers in JavaScript, TypeScript, Go and Python usually work without changes. Functions are on every plan, Free included. They run on your project’s compute and aren’t billed per request.

When to use Functions

Functions are for static sites only. A project with a server entry file, a start command, a server framework or a Dockerfile can’t have them (FUNCTIONS_SERVER_CONFLICT).

Turn them on

Functions are off until you enable them in pxxl.toml:
pxxl.toml
Commit pxxl.toml and your handler files, then deploy. An api/ folder alone does nothing. The one exception: a repository with a vercel.json, a go.mod and only Go or Python files in api/ gets Functions turned on automatically, so a Vercel Go or Python project deploys as is.

File to URL

Each file in root becomes a route under prefix:
  • Extensions: .js, .mjs, .cjs, .ts, .mts, .cts, .go and .py.
  • One language per project. All your routes must be JavaScript/TypeScript, or all Go, or all Python (FUNCTIONS_MIXED_LANGUAGES).
  • Helpers aren’t routes: files and folders starting with _ (such as api/_lib/db.ts), *.d.ts, *.test.* and *.spec.*, Go _test.go files, and Python test_*.py, *_test.py and conftest.py.
  • Dynamic segments like [id] work in JavaScript and TypeScript only, not yet in Go or Python.
  • Up to 8 folder levels deep.

Write a handler

Vercel-style, with a default export:
api/hello.ts
Or web-standard, with one export per method:
api/users/[id].ts
req has query, cookies and a parsed JSON body. res has status(), json(), send(), redirect(), setHeader(), getHeader(), write() and end(). Named exports like GET and POST win over the default export. Dependencies come from your package.json.
Read secrets from the environment (process.env, os.Getenv, os.environ). Set them in environment variables. Each function also gets PXXL_FUNCTION_TIMEOUT_SECONDS, PXXL_FUNCTION_CONCURRENCY, PXXL_FUNCTION_MAX_BODY_BYTES and PXXL_DEPLOYMENT_ID.

Route a page to a function

A rewrite can send page requests to a function. The browser keeps the original URL:
pxxl.toml
A rewrite into the prefix must point at a function that exists, or the deploy fails (FUNCTION_REWRITE_TARGET_MISSING). More in Redirects, rewrites and headers.

Cache responses

Send Cache-Control with s-maxage and Pxxl caches the response at the function’s front door, for up to 1 hour:
  • Only GET and HEAD requests are cached, per path and query string.
  • Not cached: private or no-store responses, responses that set a cookie, error statuses, and bodies over 1 MB.
  • A new deployment starts with an empty cache.

Limits

  • On Free, a site with Functions uses your one web service slot.
  • When a limit is hit, callers get 413 (body too large), 504 (timed out) or 503 with Retry-After: 1 (too many requests at once).
You can set lower limits, for all routes or per route, in pxxl.toml. Values above your plan’s limits are lowered to them. maxBodyBytes takes 1,024 to 16,777,216 bytes.
pxxl.toml
Every key: pxxl.toml reference.

The Functions tab

The project’s Functions tab lists your routes with their limits, requests and errors, their logs, and a console to send a test request.
The Functions tab of a Pxxl project, listing routes with their requests, errors and limits.
Errors inside a handler go to Live Logs; callers get a generic error.

When the deploy fails

Your current deployment stays live. The build log names the problem: Go builds also fail if a route file is in package main, has no handler or more than one, or there’s no go.mod.

Coming from Vercel

Keep your api/ folder and handlers. Add the [functions] block above (Go and Python projects with a vercel.json don’t need it). Move routing from vercel.json to pxxl.toml, or keep vercel.json for routing only. See Migrate from Vercel.