Build Night

Have you ever wanted to build your very own space on the internet? What would you fill it with? Whatever you create, it will be an expression of you, as you are what brought it to life.

We started Build Night to encourage young students to build their ideas and share them with others. Cloudflare’s free tier is generous, and its developer platform lets you experiment with a 100 small ideas, for free, to discover the big idea among them. Today, we’ll give you two small ideas, to spark your next 10.

Software Engineering has a tradition. When using a new technology, you start with an introduction: “Hello, World!”. Think, how do you want to introduce yourself? The first part of Build Night will teach you how to use a Cloudflare Worker to create a web page introducing you to The Internet.

Once you’ve deployed an idea to cyberspace, we’ll ask you to do it again, to prove you know how. This is where you’ll get creative, and learn how some fancy new inventions can help us. The second part of Build Night is a choose-your-own adventure to build the website of your dreams.

So, lock in, let’s get into it.

Before You Begin Install Node.js, npm, and VS Code

Open your terminal and run node -v (version v22 or newer) and code -v. If both print version numbers, you are all set and can skip to Hello, Internet! below.

Visual Studio Code

Download and install VS Code from code.visualstudio.com. On macOS, open VS Code, press Cmd+Shift+P, and run Shell Command: Install 'code' command in PATH so you can open projects from your terminal with code . (on Windows, the installer adds code to your PATH automatically).

Node.js & npm (via nvm)

Install nvm (Node Version Manager), which installs Node.js and npm in your home directory so you never need sudo:

bash
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.8/install.sh | bash
exec $SHELL
nvm install --lts
Table of Contents

Hello, Internet!

In this first part of Build Night, we are going to build and deploy a live website by hand, with no AI coding agents yet. You will claim a free address on the internet, use the cf command-line tool to deploy a Cloudflare Worker from scratch, and then turn that Worker into your own personal website powered by EmDash (a modern content platform maintained by a Cloudflare intern). Along the way, you will learn how domain names route traffic to your code, what a Worker actually is under the hood, and how to wire up a database and inspect live traffic in the Cloudflare Dashboard.

Claiming Your Address in Cyberspace

Before you can introduce yourself to the internet, the internet needs to know where to find you. Every website has an easy to remember address called a domain name, like cloudflare.com or wikipedia.org. To get an address of your own, you have two options: you can buy a domain from a registrar (Check out Cloudflare’s), or you can borrow a piece of someone else’s domain for free. Tonight, Cloudflare is going to lend you a piece of workers.dev, giving your account its own <your-subdomain>.workers.dev zone.

Give Me the Deets How DNS and Subdomain Delegation Work

Under the hood, computers on the internet don’t actually route traffic using words; they use numerical IP addresses (like 104.16.132.229), just like the phone network dials a number rather than your friend’s name. DNS (the Domain Name System) is what translates a domain name into an IP address so your browser knows which server to connect to. Whoever owns a domain controls its DNS, and they can delegate a subdomain to someone else. Because Cloudflare owns workers.dev, it delegates <your-subdomain>.workers.dev to your account so every Worker you deploy automatically gets a live address at <worker-name>.<your-subdomain>.workers.dev.

Browser wikipedia.org my.buildnight.workers.dev hello-internet.<you>.workers.dev 198.35.26.96 104.16.132.229 172.67.142.88 . (DNS Root) Global Root Servers .org Top-Level Domain .dev Top-Level Domain wikipedia.org Wikimedia Domain Zone 198.35.26.96 workers.dev Cloudflare Zone (Delegates Subdomains) buildnight.workers.dev Neighbor's Subdomain Zone <you>.workers.dev Your Account's Zone my.buildnight.workers.dev Neighbor's Worker 104.16.132.229 hello-internet.<you>... Your Deployed Worker 172.67.142.88 DELEGATED ZONE YOUR DELEGATED ZONE

Connect to Cloudflare

First, create a free Cloudflare account if you do not have one yet (no credit card required). While you can manage your account by clicking around the web dashboard, engineers spend most of their time in the terminal, so we will control our account using cf, Cloudflare’s command-line interface (CLI). We install cf using npm (Node Package Manager):

bash
npm install -g cf@latest

Once cf is installed, link it to your Cloudflare account by running:

bash
cf auth login

This opens a browser window asking you to authorize cf to access your account. You do not need to enable Account API key provisioning; just click Allow, then verify that your terminal is connected by running cf auth whoami.

Give Me the Deets Open Software and Identity

npm (Node Package Manager) is the tool JavaScript developers use to download and share code packages. Modern software engineering runs on open-source software: instead of writing every tool from scratch, engineers publish reusable code to a public registry so anyone can download and build with it using a package manager. Normally, npm install downloads packages locally into a single project’s folder, but because we want the cf command available everywhere on our computer, we pass the -g (global) flag to install it system-wide.

Once cf is on your machine, it needs to prove who you are before Cloudflare will let it deploy code to your account. When you run cf auth login and click Allow in the browser, Cloudflare uses OAuth 2.0 to issue a scoped access token back to cf without your terminal ever seeing your password. cf encrypts and saves that token on your computer so you do not have to log in again on every command.

Run cf auth whoami and look at the authSource field to see the exact file path where your token lives:

bash
cf auth whoami
{
"authenticated": true,
"authSource": "OAuth token from ~/.config/cloudflare/config/default.enc",
"tokenValid": true,
"email": "<your-email>",
...
}

Writing a Worker

When was the last time you wrote code? Let’s keep your streak going by writing a Worker from scratch.

bash
mkdir hello-internet hello-internet/src
cd hello-internet
npm init -y --init-type=module
npm install --save-dev @cloudflare/config
code .

You just (1) made a directory, (2) entered it, (3) started a javascript project, (4) installed open-source software, and (5) opened the project in VS Code.

A Cloudflare Worker is just a file that exports a fetch function. Whenever someone visits your website with their web browser, an HTTP Request is shot off to Cloudflare. Cloudflare quickly catches it, matches it to your Worker, and passes that HTTP Request right to its fetch function. Whatever HTTP Response your fetch function returns is what gets sent back and drawn on your visitor’s screen.

Give Me the Deets HTTP, Web Standards, and fetch

Every time you click a link or type an address into your browser, your computer and a server have a quick two-part conversation using HTTP (Hypertext Transfer Protocol). First, your browser sends an HTTP Request: a message that says what page it wants (like /), what action it is taking (like GET to read a page or POST to submit a form), and metadata called headers (like what browser you are using). The server reads that request and sends back an HTTP Response, which carries a status code (200 OK if everything worked, or 404 Not Found if the page is missing), its own headers, and the actual content (like "Hello, Internet!" or an HTML page) for your browser to display.

Browser https://hello-internet.../ Hello, Internet! Request GET Response 200 OK Worker fetch(request) new Response(...)

If you have written frontend JavaScript before, you may recognize fetch() as the browser function that sends an HTTP request and waits for a response. A Worker’s fetch(request) function is the exact mirror image on the server: it receives that same Request and returns a Response. Both sides speak the same language because fetch, Request, and Response are Web Standards, and Cloudflare runs your Worker on V8, the same JavaScript engine that powers Google Chrome.

Create a file at src/worker.ts with the following code:

TS src/worker.ts
export default {
async fetch(request: Request): Promise<Response> {
return new Response("Hello, Internet!");
},
};

Even though a Worker is just a file, that’s not enough to run it. A Worker has to be paired to a runtime, and the runtime it was made for is workerd. Our configuration file tells workerd how to treat our worker while its running!

Create a cloudflare.config.ts file directly inside your hello-internet folder (right next to package.json, outside of src):

TS cloudflare.config.ts
import { defineConfig, defineWorker } from "@cloudflare/config";
export default defineConfig({
worker: defineWorker({
name: "hello-internet",
compatibilityDate: "2026-06-16",
entrypoint: "./src/worker.ts",
observability: {
enabled: true,
},
}),
});
Give Me the Deets Workers SDK

When Cloudflare first introduced Workers in 2017, they only ran inside Cloudflare’s data centers. Today, the runtime that executes your Worker (workerd) is completely open source, along with the Workers SDK and Miniflare, the simulator that lets you run and test Cloudflare primitives locally on your laptop.

Your cloudflare.config.ts file tells the Workers SDK and workerd how to run your project:

  • defineConfig and defineWorker (from "@cloudflare/config") give your editor TypeScript autocomplete
  • name sets your Worker’s identifier and public URL (hello-internet.<your-subdomain>.workers.dev)
  • entrypoint points workerd to the file exporting your fetch function
  • observability records request logs and metrics so you can inspect live traffic in the dashboard
  • and compatibilityDate pins workerd’s runtime behavior to that date so future Cloudflare updates never unexpectedly break your deployed code.

Before deploying to the internet, test your Worker on your laptop:

bash
cf dev
No Cloudflare dev-server is installed in this project.
 
A project must declare exactly one of the following in its manifest:
 
@cloudflare/vite-plugin (Vite-based dev server (recommended for JavaScript/TypeScript))
install: npm install --save-dev @cloudflare/vite-plugin@beta
wrangler (Wrangler-based dev server (legacy Worker projects))
install: npm install --save-dev wrangler@latest
cloudflare-py-dev-server (Python dev server (Pyodide via workerd))
install: pip install cloudflare-py-dev-server (or: uv add --dev cloudflare-py-dev-server)
cloudflare-rs-dev-server (Rust dev server (wasm-bindgen + workerd))
install: cargo install cloudflare-rs-dev-server

Oh no! We’ve hit an error! Software can be temperamental, and we are still in the early days of the cf CLI. Even though we wrote our Worker and configured workerd, cf needs a local development server to bundle our TypeScript code and hand it to workerd. Thankfully, the error message tells us how to fix it.

Install Vite and Cloudflare’s Vite plugin:

bash
npm install --save-dev vite @cloudflare/vite-plugin@beta

Create a vite.config.ts file in your hello-internet folder to connect Vite to your Worker configuration:

TS vite.config.ts
import { cloudflare } from "@cloudflare/vite-plugin";
import { defineConfig } from "vite";
export default defineConfig({
plugins: [cloudflare()],
});
Give Me the Deets Vite and TypeScript

JavaScript is the programming language that V8 and workerd actually execute. Because JavaScript was originally designed for quick scripts in web browsers, it does not ask you what type of data a variable holds before running your code. That flexibility is great until you make a typo and only find out when your program crashes in front of a user. TypeScript solves this by letting you add type labels like request: Request and Promise<Response> in src/worker.ts so VS Code can catch mistakes and autocomplete methods while you type. There is just one catch: V8 and workerd still only speak plain JavaScript, so if you hand raw TypeScript to workerd, it will choke on the very first colon.

TS src/worker.ts fetch(req : Request ) A .astro # .css npm {} .json .ts Vite fetch(req : Request : Request ) TS vite.config.ts .js workerd JS index.js fetch(req) TS cloudflare.config.ts

That is where Vite comes in. Vite is a compiler and bundler: right now, it strips away your TypeScript labels and stitches any imported npm packages into a single, compact JavaScript file that workerd can run. Adding cloudflare() (from "@cloudflare/vite-plugin") in vite.config.ts connects Vite to your cloudflare.config.ts so every time you save a file in VS Code, Vite recompiles your code in milliseconds and reloads it inside workerd. Even better, Vite is not limited to TypeScript: later tonight, when we upgrade this Worker into a full website, this same Vite pipeline will also compile .astro pages, CSS stylesheets, and JSON data right into your Worker.

Re-run cf dev to start the local development server:

bash
cf dev
│ Delegating to npx vite
 
VITE v8.3.4 ready in 350 ms
 
➜ Local: http://localhost:5173/
➜ Network: use --host to expose
➜ Debug: http://localhost:5173/__debug

Voila! Your Worker is running locally. Copy the http://localhost:5173/ local server address from your terminal and visit it in your web browser.

Once you see "Hello, Internet!" on your screen, stop the server in your terminal (press the keys Ctrl+C).

Now, deploy your Worker to The Internet.

bash
cf deploy
├ Build
│ Delegating to npx vite build
vite v8.3.4 building ssr environment for production...
✓ 4 modules transformed.
.cloudflare/output/v0/workers/default/bundle/.vite/manifest.json 0.15 kB │ gzip: 0.11 kB
.cloudflare/output/v0/workers/default/bundle/index.js 0.24 kB │ gzip: 0.19 kB │ map: 0.31 kB
✓ built in 9ms
◆ Build complete
│
├ Deploy
│ Total Upload: 0.24 KiB / gzip: 0.19 KiB
│ Worker Startup Time: 0 ms
│ Uploaded hello-internet (1.24 sec)
│ Deployed hello-internet triggers (0.41 sec)
│ https://hello-internet.<your-subdomain>.workers.dev
│ Current Version ID: 8f3a1c2e-4b7d-4e9a-b1c3-7d8e9f0a1b2c
◆ Deploy complete

If this is the first Worker on your account, cf deploy will ask you to pick your <your-subdomain>.workers.dev name right in the terminal.

Now, visit your website! (You may have to wait a minute to load your site as DNS records propagate in the background)

https://hello-internet.<your-subdomain>.workers.dev
Hello, Internet!

Notice the address in the browser bar: https://hello-internet.<your-subdomain>.workers.dev is built from hello-internet (the Worker name you set in cloudflare.config.ts) and the <your-subdomain>.workers.dev piece of workers.dev you configured for your account. Send that link to the person sitting next to you: your code is now live on the internet.

Big Ideas What Is a Cloudflare Worker?
Cloudflare Worker PoP DFW PoP Airport Code Internet Backbone & Routing Hub Single-Region VM N. Virginia VM Cloud Region Global User (Worker vs. VM Latency)

On a traditional cloud provider, deploying a backend is like renting a whole apartment in one specific city (usually Northern Virginia) 24/7 just to make a cup of coffee when a guest stops by. A V8 Isolate is like stepping up to a neighborhood espresso machine that is already hot: one shared engine stays running, your code steps up for a few milliseconds to handle the request in its own clean cup, and steps right back out when it finishes. Under the hood, V8 Isolates are the same lightweight sandboxes that Google Chrome uses to keep browser tabs walled off from each other. Even better, the runtime powering this (workerd) is open source: it is what just ran on your laptop during cf dev, and you can self-host it on your own hardware.

Because isolates are so lightweight, Cloudflare Workers is a remarkably fast serverless platform, and you never have to pick a single data center region. When you ran cf deploy, Cloudflare shipped your Worker to data centers in more than 330 cities worldwide at once. Why does that matter? Because you cannot bribe the laws of physics: light traveling through a fiber-optic cable only moves so fast, so at a certain point, the only way to make a website feel instant is to move the computer answering the request closer to the human asking for it. Whether someone visits your link from across the table or across the Pacific, the Cloudflare data center closest to them runs your Worker right in their backyard.

Knock, Knock

Who is it? You’re now broadcasting "Hello, Internet!" globally. Just wait, someone’s going to come knocking at your door. How do you think you’ll hear them?

Of course, we’re not talking about sound, we’re talking about Internet Traffic. Cloudflare records all the traffic going to your Worker, and you can see it by visiting the Cloudflare Dashboard.

https://dash.cloudflare.com/?to=/:account/workers-and-pages
Cloudflare Dashboard Workers & Pages list showing the hello-internet Worker and account usage

In Workers & Pages, click on your hello-internet Worker to open its Overview page, then switch to the Metrics tab to watch your requests climb as people visit your website.

By the way, do you know everyone who is greeting you? Some of those knocks are from you and your neighbor, but on the public internet, it does not take long before strangers show up too. Automated web crawlers and opportunistic bots constantly sweep across the internet knocking on every new door they can find. Sometimes a knock turns into a mob trying to kick the door down all at once, known as a DDoS (Distributed Denial of Service) attack. Security matters the moment your code goes live, and an ounce of prevention is worth a pound of cure. Fending off attacks like these for websites is actually how Cloudflare got started. On top of that, Cloudflare’s Free plan puts a hard ceiling on your account usage, so uninvited strangers won’t stick you with a surprise bill.

Give Me the Deets Anycast and How the Internet Works

Notice how we call it The Internet, short for interconnected networks? There is no single company or central router running the whole thing. Instead, the internet is a massive web of thousands of independent computer networks called Autonomous Systems (run by internet service providers, universities, cloud platforms, and companies like Cloudflare). These networks physically plug into one another at shared hubs to trade traffic directly (a practice called peering), and they use a routing protocol called BGP (Border Gateway Protocol) to broadcast which IP addresses can be reached through which network.

On most of the web, one IP address belongs to one server in one building (called Unicast), so every visitor on Earth has to cross oceans to reach that single room. Cloudflare flips this around with Anycast: it announces the exact same IP address over BGP from data centers in more than 330 cities at once, and BGP hands each visitor to whichever one is closest. That same trick is what makes a DDoS survivable. A botnet is spread across the globe, so its flood gets split up too: each bot lands at its own nearby Cloudflare data center, where the junk gets thrown out on the spot. Only clean requests travel on to your server, which never even notices the mob.

Try it out below: A live DDoS attack is in progress, and you can stop it by clicking the orange cloud and putting a proxy in front of your server.

Live: DDoS attack in progress
Legitimate visitor Botnet attacker Cloudflare PoP (blocks attacks) Your origin server (us-east-1)
⚠ 503 Service Unavailable. Your DNS record points straight at one server (198.51.100.1). Every bot and every real visitor crosses the globe to the same machine, and it buckles. 🛡️ 200 OK. Cloudflare announces one Anycast IP (104.16.132.229) from 330+ cities. Bots are blocked at the PoP nearest to them, and only clean visitor traffic reaches your origin.

Upgrading to EmDash

Broadcasting "Hello, Internet!" proved your Worker is alive, but a single line of plain text in an empty browser window is a tough place to express yourself. You could try typing raw HTML and CSS straight into new Response("<h1>Hi!</h1>"), but cramming an entire multi-page website into src/worker.ts gets miserable fast. Real websites need layouts, stylesheets, images, and a way to publish new writing without editing code every time you fix a typo. Instead of building all of that from scratch, we are going to upgrade the Worker we already have with Astro and EmDash.

Astro is a web framework that lets you build a website out of separate pages, layouts, and stylesheets, and uses Vite to bundle all of them right into your Worker. EmDash plugs into Astro to give your site a content management system (CMS): a private administrator dashboard where you can write posts, edit pages, and publish updates straight from your browser. Let’s pull the Build Night starter portfolio into your hello-internet folder:

bash
npx giget@latest gh:couetilc/buildnight/portfolio . --force
npm install

You just (1) unpacked our starter EmDash portfolio into your current folder (.), and (2) installed Astro, EmDash, and their Cloudflare packages.

Give Me the Deets Web Frameworks and Bundlers

In the early days of the web, building a site meant writing separate .html, .css, and .js files by hand and hoping your <script> tags loaded in the right order. As websites grew into full applications, engineers built module bundlers (Browserify, Gulp, Webpack, and Rollup) to stitch thousands of separate code files and npm packages into clean bundles a browser or server could run. Vite is the next generation.

Astro sits on top of Vite. Instead of forcing you to cram HTML strings inside src/worker.ts, Astro lets you write each page and UI component in its own .astro or React file. When you run cf dev or cf deploy, Astro and Cloudflare’s Vite plugin compile all of your pages, styles, and EmDash CMS routes down into a Worker handler that workerd executes directly.

Right now, our Worker has amnesia: an isolate spins up to answer a request and forgets everything the millisecond it finishes. For EmDash to remember the posts and projects you write in /_emdash/admin, our Worker needs a database. On Cloudflare, you connect a Worker to resources like D1 (a serverless SQLite database) by declaring bindings in cloudflare.config.ts.

Update your cloudflare.config.ts with the highlighted lines below:

TS cloudflare.config.ts
import { defineConfig, defineWorker } from "@cloudflare/config";
import { bindings, defineConfig, defineWorker, triggers } from "@cloudflare/config";
export default defineConfig({
worker: defineWorker({
name: "hello-internet",
compatibilityDate: "2026-06-16",
compatibilityFlags: ["nodejs_compat"],
entrypoint: "./src/worker.ts",
observability: {
enabled: true,
},
env: {
DB: bindings.d1({ name: "hello-internet-db" }),
},
triggers: [triggers.scheduled({ schedule: "* * * * *" })],
}),
});
Give Me the Deets Bindings, Node.js, and Cron Triggers

Traditionally, connecting a backend to a database meant creating a database password, pasting a connection URL into a secret file, and hoping you never accidentally leaked it. On Cloudflare, a binding wires your Worker directly to a resource in your account and passes a ready-to-use client into fetch(request, env) on the env object (env.DB), with no passwords or connection strings to manage. Here, bindings.d1 attaches a D1 database (which gives you 5 GB of SQL storage on the free tier).

The other two additions unlock the rest of EmDash’s backend:

Start your local server to take your upgraded Worker for a spin:

bash
cf dev
...
astro v7.4.1 ready in 820 ms
 
┃ Local http://localhost:4321/
┃ Network use --host to expose

And now for the test drive! That dev server will show you what your portfolio looks like before anyone else can see it. Visit the local address in your web browser to see the Build Night starter portfolio, then stop the dev server (Ctrl+C).

Your laptop’s test database stays on your computer, so before deploying to the internet, create your production D1 database in your Cloudflare account and set up its tables with a database migration:

bash
cf d1 create --name hello-internet-db
{
"uuid": "<your-database-id>",
"name": "hello-internet-db",
...
}
cf d1 migrations apply <your-database-id>
? About to apply 1 migration(s)
Your database may not be available to serve requests during the migration, continue? › Yes
[
{
"name": "0001_emdash_baseline.sql",
"status": "✅"
}
]

Copy the "uuid" from cf d1 create --name hello-internet-db and pass it to cf d1 migrations apply <your-database-id> to run the SQL setup file (migrations/0001_emdash_baseline.sql) included in our starter portfolio. Once you see "✅", deploy your upgraded Worker to The Internet:

bash
cf deploy
...
│ Deployed hello-internet triggers (0.62 sec)
│ https://hello-internet.<your-subdomain>.workers.dev
│ schedule: * * * * *
◆ Deploy complete

When you run cf deploy, cf sees "hello-internet-db" in your cloudflare.config.ts and connects your Worker straight to the database you just prepared.

Extra Credit Turn your Worker into a proxy

When we unpacked the Build Night starter portfolio earlier, it updated src/worker.ts so its fetch function passes every incoming request straight to EmDash (handler.fetch). To prove that your Worker is still the front door in charge of every request, open src/worker.ts and add an if condition that checks the request’s pathname for "/hello" before handing the rest of your traffic to EmDash:

TS src/worker.ts
import handler, { createScheduledHandler, PluginBridge } from "@emdash-cms/cloudflare/worker";
export { PluginBridge };
export default {
async fetch(request, env, ctx) {
if (new URL(request.url).pathname === "/hello") {
return new Response("Hello again, Internet!");
}
return handler.fetch(request, env, ctx);
},
scheduled: createScheduledHandler(),
}

Test it locally with cf dev by visiting http://localhost:4321/hello to see "Hello again, Internet!", then run cf deploy and change the path on your live .workers.dev address to /hello to see your custom greeting on the global network.

https://hello-internet.<your-subdomain>.workers.dev
The live Build Night starter portfolio homepage showing the What's Your Vibe hero and Rothko color fields

Every web address in your browser bar is made of two parts: the origin (https://hello-internet.<your-subdomain>.workers.dev), which tells the browser which server to connect to, and the path (everything starting from the / at the end, like /_emdash/admin), which asks that server for a specific page:

  1. Open your live .workers.dev address to see your portfolio homepage (the root path /), then click Admin in the top navigation bar (or change the path in your browser bar to /_emdash/admin) to open EmDash’s setup screen.
  2. Keep Sample content selected so EmDash fills your site with our 12 starter vibes instead of starting from a blank page, enter your name and email, and create a passkey using your laptop’s fingerprint reader, face unlock, or PIN (no password to remember or leak).
  3. Once you land inside the EmDash dashboard, click around Pages, Projects, and Settings to edit the starter content, publish your own writing, and make the page yours.
Extra Credit You want to upload images, don't ya?

SQL databases like D1 love neat rows of text, numbers, and timestamps, but they hate it when you try to cram a 10-megabyte JPEG into a table column. To handle photos and videos, web apps pair their database with object storage like Cloudflare R2 (a giant digital warehouse for raw files) and Cloudflare Images (which resizes and compresses those photos on the fly so your pages load fast). Even though R2 gives you 10 GB of storage a month for free, turning it on in your Cloudflare account asks for a payment method on file. We left image uploads turned off so nobody at Build Night had to reach for a wallet, but if you do not mind adding a card to your account, you can switch them on in a minute.

First, open the R2 page in the Cloudflare Dashboard and follow the prompt to activate R2 on your account. Once R2 is enabled, create a bucket (a folder in object storage) for your site’s media from your terminal:

bash
cf r2 buckets create --name hello-internet-media

Next, connect your Worker to both your new R2 bucket and Cloudflare Images by adding MEDIA and IMAGES bindings in cloudflare.config.ts:

TS cloudflare.config.ts
import { bindings, defineConfig, defineWorker, triggers } from "@cloudflare/config";
export default defineConfig({
worker: defineWorker({
name: "hello-internet",
compatibilityDate: "2026-06-16",
compatibilityFlags: ["nodejs_compat"],
entrypoint: "./src/worker.ts",
observability: {
enabled: true,
},
env: {
DB: bindings.d1({ name: "hello-internet-db" }),
MEDIA: bindings.r2({ name: "hello-internet-media" }),
IMAGES: bindings.images(),
},
triggers: [triggers.scheduled({ schedule: "* * * * *" })],
}),
});

Finally, open astro.config.mjs to tell Astro and EmDash to stop bypassing image processing and start storing uploads in your "MEDIA" bucket:

JS astro.config.mjs
import cloudflare from "@astrojs/cloudflare";
import react from "@astrojs/react";
import { d1 } from "@emdash-cms/cloudflare";
import { d1, r2 } from "@emdash-cms/cloudflare";
import { defineConfig, fontProviders } from "astro/config";
import emdash from "emdash/astro";
export default defineConfig({
output: "server",
adapter: cloudflare({
imageService: "passthrough",
}),
adapter: cloudflare(),
image: {
layout: "constrained",
responsiveStyles: true,
},
integrations: [
react(),
emdash({
database: d1({ binding: "DB", session: "auto", coalesce: true }),
images: false,
storage: r2({ binding: "MEDIA" }),
}),
],

Run cf deploy to push your new configuration live, then head back to /_emdash/admin to upload photos straight into your portfolio.

Choose Your Own App-venture!

AI is curious, isn’t it? You have these creative, spinning machines you talk to in a human language, and they’re amazing at translating that into computer instructions. They’re also hungry, whose “life” demands an energy of its own, electricity. They possess knowledge, they’ve been trained, and you can harness their power for pennies a thought. But my oh my, how many thoughts they have, how disorderly they come, and at what expense!

We’re going to harness the AI and ride its wave of thought as affordably as possible to our destination of a cool portfolio. It’s an App-venture! That means you get to build whatever you want, and we’ll help guide you with design thinking and tool choices. To take full advantage of this part, you’ll want to use a coding agent, we have a $0, $10, and $20 options below.

Before You Begin Set Up an AI Coding Agent

Already have a coding agent set up on your laptop? You're all set—skip ahead. Otherwise, pick one below:

Gemini CLI

$0 1,000 requests/day
Official Setup Guide ↗
bash
npm install -g @google/gemini-cli
gemini
Heads Up

Use a personal @gmail.com account, not your .edu email. University accounts are managed by campus IT and require a paid Google Cloud project.

First, you’ll give your agent instructions that will help it work purposefully and make fewer mistakes inside your codebase. Once its ready, you’ll redesign your portfolio site by having your agent interview you about your taste. Finally, you’ll build and deploy a second Worker, to show off your skills on your portfolio!

Put Your Agent on the Rails

Your coding agent is a newcomer to your project, and left to its own devices, it will immediately start guessing. Luckily, because you wired up this site by hand in Part 1, you already know how your codebase works.

Hand your agent the ground rules by picking how you want it to collaborate with you and creating an AGENTS.md file in the root of your project:

How should your agent work with you?
≡ AGENTS.md
# Project Guidelines
## How to Work with Me
- Take small steps and do not rush ahead. Stay by my side until we agree on a plan.
- Before writing or changing code, explain what you plan to touch and why.
- After each change, point out the files you edited so I can read and understand them.
## Stack & Structure
- Personal portfolio and blog built with **Astro** and **EmDash** (`emdash`), running on **Cloudflare Workers** (`src/worker.ts`).
- Styling lives in `src/styles/tokens.css` (colors, fonts, spacing) and `src/styles/theme.css`.
## Cloudflare CLI & Configuration
- Always use the `cf` CLI, **never** `wrangler`.
- Run `cf dev` for local development and `cf deploy` to deploy.
- Configure Workers, bindings, and triggers in `cloudflare.config.ts` using `@cloudflare/config` (`defineConfig`, `defineWorker`, `bindings`, `triggers`). Never create `wrangler.toml` or `wrangler.jsonc`.
- Discover CLI commands with `cf cli search "<task>"` and search official Cloudflare docs with `cf docs search "<question>"`.
- Keep every resource within Cloudflare's Free Tier.
Give Me the Deets Training Cutoffs and AGENTS.md

Since the 1970s, programmers have placed a README file in the root of their projects so any human opening the folder knows how to build and run the code. When AI coding agents arrived, every tool initially invented its own hidden instruction file (.cursorrules, CLAUDE.md, .github/copilot-instructions.md), until the open-source community converged on AGENTS.md: a single, plain-Markdown onboarding manual for robots that your coding agent reads automatically at the start of every conversation.

Why does a smart AI model need an onboarding manual in the first place? Because Large Language Models (LLMs) are trained on massive snapshots of the public internet frozen at a training cutoff date. Their instincts always lag behind newer tools like cf, cloudflare.config.ts, and EmDash.

Each section in your AGENTS.md keeps the agent from wandering off track:

  • How to Work with Me sets the pace of your collaboration, whether you want a patient co-pilot that explains each step or an autopilot that builds end-to-end.
  • Stack & Structure points the agent straight to src/worker.ts, src/styles/tokens.css, and src/styles/theme.css so it does not burn time and tokens hunting through your folders.
  • wrangler warns it not to use Cloudflare’s older CLI or invent wrangler.toml and wrangler.jsonc files, which AI models have memorized from years of older tutorials on the web.
  • cf dev, cf deploy, and cloudflare.config.ts lock in the exact workflow you used by hand in Part 1.
  • cf cli search and cf docs search teach the agent to use cf’s built-in search commands to look up real CLI flags and live Cloudflare documentation instead of making things up.

While AGENTS.md covers the basics of your project, you can also equip your coding agent with Agent Skills for Cloudflare and EmDash:

bash
npx -y skills add cloudflare/skills --skill cf-cli cloudflare workers-best-practices durable-objects -y
npx -y skills add emdash-cms/emdash --skill building-emdash-site emdash-cli -y

You just (1) installed Cloudflare’s platform and Workers skills, and (2) installed EmDash’s site-building and CLI skills into .agents/skills/.

Give Me the Deets Agent Skills and the Context Window

Every AI model has a context window: a strict limit on how much text (measured in tokens, roughly three-quarters of a word) it can hold in its working memory during a conversation. If you pasted every page of Cloudflare and EmDash documentation straight into AGENTS.md, your agent would have to re-read thousands of tokens on every single message, burning through your daily quota and drowning out the actual code you are working on.

Agent Skills solve this by working like a bookshelf in .agents/skills/ instead of a textbook taped to the agent’s forehead. At the start of a chat, your coding agent only reads the one-sentence title and description of each skill. When your task actually calls for one (like styling your EmDash theme with building-emdash-site or wiring up a Cloudflare resource with cf-cli), the agent pulls just that SKILL.md guide off the shelf on demand. And because we installed them into your project folder instead of globally (-g), they stay neatly self-contained inside hello-internet.

Find Your Vibe

Right now, your live portfolio is still wearing our starter template. If you just tell an AI agent “make my website look cool,” it will hand you the same generic purple-gradient landing page it gives everyone else. To get a design that actually feels like you, flip the script: tell your coding agent to interview you about your taste first, and only touch the code after you agree on a direction.

Start your coding agent in your hello-internet folder and send it this prompt:

Prompt Design Interview
I want to redesign my personal EmDash portfolio in this repo so it feels like me instead of the starter template.
 
Do not write or edit any code yet. First:
1. Read AGENTS.md, src/pages/index.astro, src/layouts/Base.astro, src/styles/tokens.css, and src/styles/theme.css.
2. Interview me to uncover my aesthetic across four areas:
- Inspiration: Outside of websites, what is an album cover, game menu, poster, book, or physical object whose look I love (or which archetype in public/vibes/ caught my eye)?
- Colors: If my site were a place or time of day, what is the mood and palette (warm paper and ink, sun-bleached pastels, bold primaries, or a glowing late-night terminal)?
- Form & Grid: Should the layout feel dense and structured like a blueprint or newspaper, bold and poster-like with oversized type, or calm and spacious like a gallery?
- My Voice: How would I introduce myself at a party in one sentence (without sounding like a resume), and what 2 or 3 interests or rabbit holes should the homepage spotlight?
3. Synthesize my answers into a concrete design direction (palette, typography, layout grid, and hero concept) and wait for my feedback before editing any files.

Answer your agent’s questions in your own words, push back on anything that sounds generic, and give it the green light once the plan sounds like you. As your agent works, keep cf dev running and your homepage open in your browser so you can watch the changes happen live. Go back and forth until you love how it looks, then publish your new design to The Internet with cf deploy.

A Second Worker for Your First Project

Your portfolio finally looks like you, so now let’s build your first interactive web app to feature on it. You could cram a game or a chat room straight into your EmDash Worker (src/worker.ts), but your portfolio is your home base: if an experiment has a bug, you do not want it taking down your front page. Instead, we are going to spin up a second Worker in the same project to act as a dedicated workshop for your app.

Send your coding agent this prompt to wire up a second Worker (hello-app) and connect it to your portfolio at /app:

Prompt Wire Up a Second Worker
Set up a second Cloudflare Worker in this repo for my first portfolio project and mount it at /app:
 
1. Create src/app-worker.ts exporting a basic fetch handler that returns new Response("Welcome to my workshop!").
2. In cloudflare.config.ts, extract a shared compatibilityDate constant, export const appWorker = defineWorker({ name: "hello-app", compatibilityDate, entrypoint: "./src/app-worker.ts" }), and add APP: bindings.worker({ worker: appWorker }) to the hello-internet Worker's env.
3. In astro.config.mjs, import { appWorker } from "./cloudflare.config.ts" and pass auxiliaryWorkers: [{ config: appWorker }] inside cloudflare({ ... }) so cf dev runs both Workers together.
4. In src/worker.ts, route any request whose pathname is /app or starts with /app/ to return env.APP.fetch(request).
5. Document src/app-worker.ts and deploying both Workers (cf deploy --worker hello-app followed by cf deploy) in AGENTS.md.

Once your agent finishes, take a peek at the two most important pieces it just wired up. First, in cloudflare.config.ts, both Workers now share compatibilityDate, and your portfolio Worker connects to appWorker through a Service Binding (bindings.worker):

TS cloudflare.config.ts
import { bindings, defineConfig, defineWorker, triggers } from "@cloudflare/config";
const compatibilityDate = "2026-06-16";
export const appWorker = defineWorker({
name: "hello-app",
compatibilityDate,
entrypoint: "./src/app-worker.ts",
});
export default defineConfig({
worker: defineWorker({
name: "hello-internet",
compatibilityDate: "2026-06-16",
compatibilityDate,
compatibilityFlags: ["nodejs_compat"],
entrypoint: "./src/worker.ts",
observability: {
enabled: true,
},
env: {
DB: bindings.d1({ name: "hello-internet-db" }),
APP: bindings.worker({ worker: appWorker }),
},
triggers: [triggers.scheduled({ schedule: "* * * * *" })],
}),
});

Second, in src/worker.ts, the /hello detour from Part 1 has grown up: any visitor who opens /app is handed straight across to your second Worker with env.APP.fetch(request):

TS src/worker.ts
import handler, { createScheduledHandler, PluginBridge } from "@emdash-cms/cloudflare/worker";
export { PluginBridge };
export default {
async fetch(request, env, ctx) {
const url = new URL(request.url);
if (url.pathname === "/hello") {
return new Response("Hello, Internet! Still the same Worker under the hood.");
}
if (url.pathname === "/app" || url.pathname.startsWith("/app/")) {
return env.APP.fetch(request);
}
return handler.fetch(request, env, ctx);
},
scheduled: createScheduledHandler(),
} satisfies ExportedHandler<Env>;
Give Me the Deets Service Bindings and Multi-Worker Architecture

As web applications grow, teams often split a single giant codebase into smaller, independent services (an architecture called microservices). Traditionally, splitting your app in two comes with a tax: for Service A to talk to Service B, it has to send an HTTP request back out over the network, wait on DNS and TLS handshakes, and pay for the extra round trip.

A Cloudflare Service Binding (bindings.worker) skips the network completely. When hello-internet calls env.APP.fetch(request), workerd spins up the hello-app isolate on the exact same machine (and often inside the same operating-system thread) and hands the Request straight across in memory with zero network latency. And because your agent added auxiliaryWorkers to astro.config.mjs, a single cf dev command boots both Workers together on your laptop so you never have to juggle two local servers.

Open http://localhost:5173/app in your browser to see "Welcome to my workshop!" served by your second Worker through your portfolio, then deploy both Workers live:

bash
cf deploy --worker hello-app
cf deploy

Pick Your Track

Your second Worker is live at /app, wired into your portfolio, and waiting for an actual application to run inside it. You can build any idea you have been daydreaming about tonight, or pick one of our three blueprints below if you want a running start. Each blueprint teaches a different set of Cloudflare primitives, and each prompt tells your coding agent to brainstorm the theme and rules with you before writing the code:

Which blueprint do you want to build?
Prompt Track A: Shared AI Group Chat (Any Coding Model)
I want to build a live multiplayer AI group chat at /app where friends at my table can chat with each other and a shared AI character in the same room.
 
Do not write code yet. First:
1. Read AGENTS.md, cloudflare.config.ts, and src/app-worker.ts.
2. Ask me 3 short questions to design the room: what is the setting or vibe, who is the AI persona in the chat (and when should it chime in), and what fun twist or command should the room have?
3. Once we agree on the plan, build the app in src/app-worker.ts (under /app and /app/*):
- Export a DurableObject room class from src/app-worker.ts with exports.durableObject({ storage: "sqlite" }) on appWorker in cloudflare.config.ts (so it stays on the Free Tier), and bind it plus AI: bindings.ai() to appWorker.env.
- Sync live messages and history over WebSockets + Durable Object SQLite storage, and call env.AI.run("@cf/meta/llama-3.1-8b-instruct-fast", ...) when the AI character replies.
- Link /app from my EmDash portfolio homepage so visitors can jump right in.

Once you and your coding agent finish building your app and testing it locally at http://localhost:5173/app, deploy both Workers one more time with cf deploy --worker hello-app and cf deploy. Then share your https://hello-internet.<your-subdomain>.workers.dev link with the people at your table and open your Cloudflare Dashboard Metrics to watch the live traffic roll in!

Give Me the Deets Surviving and Thriving on Cloudflare's Free Tier

Everything you deployed tonight runs on Cloudflare’s Free plan. Here is what your account includes every day for $0, and what those numbers mean in real human traffic:

  • Workers (100,000 requests/day & 10 ms CPU time/invocation): Enough for thousands of visitors a day. Note that CPU time only counts the milliseconds your JavaScript is actively crunching numbers, not the time your Worker spends waiting on network calls, D1 queries, or AI responses.
  • D1 SQL Database (5 GB storage, 5 million rows read/day, 100,000 rows written/day): Plenty of room for years of blog posts, game leaderboards, and app state.
  • SQLite Durable Objects & KV: Included on the Free Tier for real-time WebSocket rooms, multiplayer state, and key-value caching.
  • Workers AI (10,000 Neurons/day): Built-in GPU inference for open-weight language, embedding, and image models via AI: bindings.ai().