Domdhi logoDOMDHI.OS
BACK_TO_COURSE

What a Worker Is, and What It Can't Do

A Worker Is a Function That Answers

No Server to Babysit

A normal web app runs on a computer you rent. You patch it, restart it, and pay for it at 3am when nobody is using it. A Worker is just code that wakes up when something happens, answers, and gets out of the way. Cloudflare runs it in its data centers around the world. You never see the machine.

Here is a whole one:

export default {
  async fetch(request, env, ctx) {
    const url = new URL(request.url);
    if (url.pathname === "/") return new Response("Hello from the edge");
    return new Response("Not found", { status: 404 });
  },
};

That's a working web app. Three things come in:

Input What it is
request What the visitor asked for
env Your database, files, cache and secrets, plugged in
ctx A way to finish small jobs after you answer

env is the part that matters. Anything your Worker can touch is a binding: you declare it in a file called wrangler.jsonc, and it shows up on env. That file is the map of your whole app. Want to know what an AI actually built? Read that file first.

What Can Wake It Up

  • fetch: a visitor or another program calls a URL
  • scheduled: the clock
  • queue: a job is waiting
  • email: mail arrives

domdhi.com is one Worker. The pages, the API, the scheduled posts and the incoming webhooks are all the same deploy.

INFO

New to git? Take GIT 101 first. You want every AI change saved as a commit, so you can see what it did and undo it.

QUIZ

You want to know what an AI-built Worker can touch. Where do you look first?

Sign in to track lesson progress and earn a certificate.SIGN IN TO SAVE PROGRESS