One file, one address
A function is a module with a fetch method: it gets a Request and returns a Response. Write it in the dashboard editor, deploy, and it answers at its own address a moment later.
Use one for a webhook receiver, a small JSON API, a redirect service or a form handler, without a project, a build or a server to look after.
In front of your app
Route a function onto paths of a project, like /api/* or /admin. It sees each request first and either answers it or lets it through to your app with env.next(), so checks like API keys, redirects or header changes live outside the app.
Built to stay fast and contained
- Each workspace’s functions run in their own sandbox, separate from every other workspace, with the same isolation as your apps.
- Functions stay warm, so there is no cold start to wait for.
- Every request has a CPU time budget, 128 MB of memory and 30 seconds to answer. A function past a limit is stopped and the visitor gets a clear error.
- Variables and secrets, encrypted at rest, reach the code as env.NAME.
See what it does
- Console output and the last 100 requests with status, time and CPU time.
- Requests, errors, p50 and p95 for today and the last 14 days.
- The last 10 versions, each one a click from being live again.
Questions
Can I use npm packages?
Not yet. A function is one file for now; Request, Response, fetch, crypto and the node: built-ins are available.
What happens past the included requests?
With pay as you go on, extra requests cost $1 per million from your points. With it off, or with no points left, requests get a 429 with a JSON body that says why until the next cycle.
Does CPU time include waiting on a database or fetch?
No. Only time your code spends working counts.
