What’s a backend
Your app has two sides. The frontend is what users see: pages and screens, running in the browser or on a phone. The backend is code that runs in the cloud. It talks to your database, calls other services, processes data, sends emails. Your backend is made of “functions” (also called “API routes”). A function takes some input, does some work, and returns output. It’s called an API route because your frontend calls it at a URL, like/api/leads or /api/payments.
The work can be simple: give it a user ID, it finds them in the database and returns their info. Or complex: give it a piece of text, it calls another API, uses AI to transform the text, stores the result in the database, and returns what it did so your page can display it.
You don’t usually see functions in the builder. The agent creates them when it needs to. You’ll see them in two places:
- Publish menu — when you publish, it lists all your functions and their routes
- Code view — functions live in
web/api/. Each function is a file named after its route, likeweb/api/leads/route.ts
What you can do with them
You describe what you need and the agent creates the function.Publishing
When you publish your app, your functions go live alongside your pages. They get their own URLs:yourdomain.com/api/function-name. Your frontend calls these URLs to talk to your backend. External services can call them too (see Webhooks).
Secrets
Functions can connect to external services like Twilio, HubSpot, or any API. Store your API keys in Secrets (found in Project Settings) so they stay secure and out of your code.Advanced
Security
Functions are public by default. Anyone who knows the URL can call them, which is fine for things like a public contact form. If a function should only work for logged-in users, tell the agent.External APIs
When you tell the agent to connect to an external service, it creates a function that calls that API from the cloud. This matters because API keys need to stay on the server. If they were in your page code, anyone could see them in the browser.Anything has built-in integrations for popular services like Stripe, Resend, and OpenAI. You don’t need to set those up manually. The external API pattern above is for services Anything doesn’t have built in yet.
Webhooks
Sometimes you need an external service to send data to your app. Stripe tells you when a payment goes through. A form tool tells you when someone submits. These are called webhooks. It’s just a URL on your app that another service can send data to. Tell the agent what service you’re expecting data from and what to do with it./api/webhooks/stripe. Give that URL to the external service and it sends data there.
Scaling
Functions are serverless. That just means they run in the cloud and scale with your traffic automatically. If ten people hit your app at once or ten thousand, it handles it. You don’t configure anything. Each request can run for up to 5 minutes.Scheduled tasks
Built-in scheduled tasks are coming soon. In the meantime, you can use an external service to call one of your functions on a schedule.- Create a function that does the work you want to run on a schedule
- Use a service like cron-job.org or Zapier to call your function’s URL on a schedule
- If the task is sensitive, add a secret token the external service includes in the request, and have your function check for it