Documentation Sign in to the Console

Xenkloud Functions

Server code that runs on request, from the api/ folder of your site. No servers to manage, and it scales to zero when idle.

Functions let a static site do things that need a server: call an API with a secret key, check a payment, save to a database. Each file in your site's api/ folder answers at /api/... on the site's own addresses and domains.

js
// api/quote.js  →  https://www.example.ca/api/quote
export default async (request, context) => {
  const { service } = await request.json();
  return Response.json({ service, price: 75, currency: "CAD" });
};

How it works

  • Deploy the api/ folder with the site, from GitHub or in a zip. There's nothing else to set up.
  • The site's functions run in their own sandboxed container, started on the first request and stopped after 10 idle minutes.
  • Settings and secrets from the site's Functions tab arrive as process.env.
  • console.log goes to the logs on the site's Functions tab.
  • /api/... is never served as files, so your code stays private.

Limits

Limit Value
Time per request 10 seconds
Memory 128 MB
Request body 1 MB
Requests per month Depends on your plan; see Quotas

Next step

Writing functions