Building this site on Cloudflare, in plain language

What a Worker, a database and an Access policy actually are, written for someone who designs for a living.

Laptop showing code on a tidy desk
Laptop showing code on a tidy desk Photo: Daniil Komov

I am a designer, and until this month I had never run a server. This is what I learned building this site, in the words I would have wanted at the start.

The three pieces

A Worker is a small program that wakes up when someone visits a page, builds that page, and goes back to sleep. You do not rent a computer; you rent a few milliseconds of one.

A database (here, Cloudflare D1) is a set of tables, like spreadsheets, that the Worker reads from. My blog posts are rows in a table called posts.

An Access policy is a lock on a door. It sits in front of the admin area and says: only this email address gets in.

What the code looks like

The part that fetches the latest posts is shorter than you would think:

TypeScript
const posts = await env.DB
  .prepare("SELECT title, slug FROM posts WHERE status = ? ORDER BY published_at DESC LIMIT 5")
  .bind("published")
  .all();

That is the whole idea: ask the database a question, get rows back, turn them into a page.

What surprised me

  • It is free at my scale, with room to spare.
  • Writing in Markdown is calmer than any editor I have used.
  • Most of the time went on design decisions, not technology.

If you design for a living and the word “server” makes you nervous, it should not. It is a very small program that makes pages.

Calm sea between mountains

Filtered mountains in pink light

BeforeAfter
Calm sea between mountainsCalm sea between mountains Photo: Francesco Ungaro