Skip to content
AI Exercises
–points–day streak

What is a server function?

A server function is one small job that runs in the backend only when the app asks for it, like working out a delivery fee or sending an email.

In real life

It's like one recipe card in the kitchen: when an order for pancakes comes in, the cook follows that one card, and you only see the pancakes.

Try it yourself

The app (the frontend)

Press the button to call the server function.

Server function: calculate delivery fee

  1. 1Receive the distance from the app
  2. 2Read the secret price list (kept on the server only)
  3. 3Work it out: £2 base + £0.80 per km
  4. 4Send back just the answer

The function only runs when the app asks. It does one job, uses a secret the visitor can't see, and returns the answer.

Where you will use this

  • Track 2, lesson 11: Secrets and environment variablesComing soon
  • Track 3: Adding an AI step to a workflowComing soon

Quick check: Server function

Question 1 of 3

When does a server function run?

When does a server function run?