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 inpxxl.toml:
pxxl.toml
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 inroot becomes a route under prefix:
- Extensions:
.js,.mjs,.cjs,.ts,.mts,.cts,.goand.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 asapi/_lib/db.ts),*.d.ts,*.test.*and*.spec.*, Go_test.gofiles, and Pythontest_*.py,*_test.pyandconftest.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
- TypeScript
- Go
- Python
Vercel-style, with a default export:Or web-standard, with one export per method:
api/hello.ts
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.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
FUNCTION_REWRITE_TARGET_MISSING). More in Redirects, rewrites and headers.
Cache responses
SendCache-Control with s-maxage and Pxxl caches the response at the function’s front door, for up to 1 hour:
- Only
GETandHEADrequests are cached, per path and query string. - Not cached:
privateorno-storeresponses, 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) or503withRetry-After: 1(too many requests at once).
pxxl.toml. Values above your plan’s limits are lowered to them. maxBodyBytes takes 1,024 to 16,777,216 bytes.
pxxl.toml
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.
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 yourapi/ 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.
