Skip to the workspace
Pebellslearn by building
R2 Storage and the Developer Toolchain  ›  Lesson

Wrangler and Miniflare — Build Locally, Ship Globally

Wrangler 12 minWrangler scaffolds, runs, deploys and observes Workers, and its local dev server uses Miniflare to simulate the runtime and bindings on your machine with separate local data.

cloudflare / Wrangler and Miniflare — Build Locally, Ship Globally

Explore each scene at your own pace.

01 · The rule

The rule

Wrangler and Miniflare — Build Locally, Ship Globally

Hoplink is about to grow a new feature: letting people attach files to short links. Before touching storage, you need a comfortable loop for writing, running and deploying code. Editing in the dashboard works for a demo, but real projects live in a folder, in Git, driven from the terminal.

The rule

Create, dev, deploy — local first, real network last.

Wrangler is Cloudflare's command-line tool. Four commands carry most of the load:

npm create cloudflare@latest hoplink   # scaffold a new project
npx wrangler dev                        # run it on your machine
npx wrangler deploy                     # publish to the whole network
npx wrangler tail                       # stream live logs from production
  • Create. The scaffolding tool writes wrangler.jsonc, a src/ entry file and package.json, and can set up TypeScript and a framework such as Hono.
  • Dev. wrangler dev serves your Worker at http://localhost:8787. It runs on Miniflare, a local simulator built on workerd, the same open-source runtime that powers production Workers. Your KV, R2, D1, Durable Objects and queues are simulated too, stored under .wrangler/state in the project folder. Nothing you do locally touches real data.
  • Deploy. wrangler deploy bundles your code, uploads it with the bindings from your config, and it is live worldwide within seconds.
  • Observe. wrangler tail shows console.log output and errors from real traffic; wrangler dev also offers a DevTools inspector for breakpoints.

Resources are created from the same tool: wrangler kv namespace create LINKS, wrangler r2 bucket create hop-files, wrangler d1 create hop-db. Each command prints the config snippet to paste into wrangler.jsonc.

In a team, wrangler deploy usually runs from CI rather than a laptop: a pipeline installs dependencies, runs tests, and deploys with an API token stored as a CI secret.

Scene 1 of 5
Hover to wake the cannons. Drag to move, or use arrow keys when focused. Press Enter to fire a shot.