Lesson 4 of 6

Deploy on Cloudflare

About 15 minutesPut your folder on the internet with a real address.

Your site works on localhost, which means only on your computer. Deploying means putting it on computers that are always on, always online, and reachable by a name anyone can type. Cloudflare runs those computers all over the world, and a small site costs nothing.

Two ways to go live

Press play to follow one visit to your site, step by step. Switch between the two ways.

A · Upload your files (Workers)B · Open a tunnel to your computer
What goes onlineA copy of your folderThe server running on your machine
Your computer can sleep?YesNo: if it's off, the site is off
Good forWebsites, almost alwaysShowing a work-in-progress, home servers, apps that need your machine
Toolnpx wrangler deploycloudflared tunnel

Way A: deploy a folder with Wrangler

This is the one to use for your site. You need a free Cloudflare account (sign up at dash.cloudflare.com) and Node from lesson 2.

1. Lay out the folder

Put everything the browser should see into a public folder. Your index.html is the home page.

Terminal
$ cd ~/hello
$ mkdir public
$ ls
hello.js    package.json    public
public/index.html
<!doctype html>
<title>hello</title>
<h1>hello, internet</h1>
<p>I made this with a terminal.</p>

2. Tell Cloudflare what to upload

Create one small settings file, wrangler.jsonc, next to public (not inside it):

wrangler.jsonc
{
  "name": "hello",                       // becomes part of your web address
  "compatibility_date": "2026-10-28",    // use today's date
  "assets": {
    "directory": "./public"              // upload this folder, nothing else
  }
}

Notice what this means: only the files in public go online. Your scripts, notes and node_modules stay on your computer. That's the paths from the Preliminaries doing real work.

3. Sign in, preview, deploy

Terminal
$ npx wrangler login
$ npx wrangler dev
# preview at http://localhost:8787, Ctrl C to stop
$ npx wrangler deploy
Deployed hello
  https://hello.your-name.workers.dev

login opens your browser once to connect your account. dev shows you exactly what will go live. deploy uploads the folder and prints your public address. Send it to a friend: it works on their phone, anywhere.

To update the site, change your files and run npx wrangler deploy again. That's the whole publishing workflow.

4. Your own domain (optional)

The workers.dev address is free and permanent. To use a name like yourname.com, buy or move the domain into Cloudflare, then in the dashboard open Workers & Pages → your project → Settings → Domains & Routes → Add → Custom domain. Cloudflare sets up the address and the padlock (HTTPS) for you.

Way B: a tunnel to your own computer

Sometimes the thing you built isn't a folder of files but a server that runs on your machine, like server.js from lesson 2. Wrangler can't upload a running program. For that, Cloudflare can open a tunnel from the internet straight to your laptop. That's the whole of the next lesson, so here it's enough to know it exists and how it differs from Way A (press B · Tunnel in the diagram above).

Let the AI do it, now that you know what it's doing

Everything above is something an agent from lesson 3 can do for you. The difference is that now you can check its work.

Inside your project
$ claude
> Get this site ready for Cloudflare Workers static assets: everything public goes in public/, add a wrangler.jsonc with today's compatibility date, and tell me the commands to preview and deploy. Don't deploy until I say so.

Then read what it made: is index.html inside public? Does wrangler.jsonc point at ./public? Run npx wrangler dev, look, and deploy when you're happy.

You deploy with Way A and close your laptop. What happens to the site?

Way A copies your public folder onto Cloudflare's computers. Your laptop isn't involved after deploy. A tunnel (Way B) is the one that needs your computer on.

After deploying, your page shows but the picture is missing. It's at ~/hello/cat.jpg. Why?

"directory": "./public" means exactly that folder. Move the file in, make sure the HTML says <img src="cat.jpg">, and deploy again.

Your folder is on the internet

Files are named bytes in folders. The terminal walks those folders. Node runs the files that are programs. AI agents write and run those files for you. Cloudflare puts a folder of them on the internet. For most websites, that is the whole job.

Next: pick something small you'd actually use, a page for a club, a menu for a café, make a folder for it, and start an agent in there. And when what you build is a server that has to run, not just files to serve, lesson 5 puts it online straight from your laptop with a tunnel.

Remember
  • Deploy = copy your folder to computers that are always on. Way A: npx wrangler deploy.
  • wrangler.jsonc says which folder to upload: only public/ goes online.
  • npx wrangler dev previews; deploy again after every change.
  • A tunnel (Way B, next lesson) shares a server running on your own computer, but only while it's on.