Hello, edge
Which Cloudflare data center just served you? A tiny server route running on Workers, poked by a React island.
- live
- #cloudflare
- #workers
- #react
This answer was served by
···
Asking the nearest Cloudflare data center…
- You’re in
- ···
- Round trip
- ···
- Protocol
- ···
- Time zone
- ···
How I built it
This page is static, but the card above asks a server route where you are.
- The page itself is prerendered, so it’s free to serve. The card is a React island that hydrates when it scrolls into view (
client:visible). - It calls
/lab/hello-edge/api, an on-demand route (export const prerender = false) that runs inside a Cloudflare Worker, in whichever data center is closest to you. - The Worker reads
request.cf(the data center’s airport code and your rough country) and returns it as JSON. Nothing is stored.
This is the template for any project that needs a backend. Add a binding (KV, D1, R2, Durable Objects…) to wrangler.jsonc, run pnpm cf-typegen, and read it with import { env } from "cloudflare:workers".