Skip to content

Ship a Worker you already have

ship deploys a Worker all or nothing. It doesn’t need Effective Cloud’s declarations, or Effect: it deploys any Worker described the way Cloudflare’s own tools describe one. If you have a Worker already, plain TypeScript, Hono, a Vite app, you can ship it with a version tested before it takes traffic, smoke tests that check which version answered, and an undo for everything (How a rollout stays safe has the details). It’s also what infra ship deploys each Worker of an app with.

Here’s a Worker’s config, as Cloudflare’s cf CLI reads it:

packages/ship/fixtures/hello/cloudflare.config.ts
import { bindings, defineConfig } from '@cloudflare/config';
import * as entrypoint from './src/worker.ts' with { type: 'cf-worker' };
export default defineConfig((ctx) => ({
worker: {
name: process.env['SHIP_NAME'] ?? 'ship-hello',
entrypoint,
compatibilityDate: '2026-10-01',
env: {
GREETING: bindings.text(process.env['SHIP_GREETING'] ?? 'hello from ship'),
BROKEN: bindings.text(ctx.mode === 'broken' ? 'yes' : 'no'),
CACHE: bindings.kv(),
DB: bindings.d1(),
VERSION: bindings.versionMetadata(),
},
},
}));

Ask ship what it would do, with no requests at all:

$ pnpm ship fixtures/hello --dry-run
would ship ship-hello from …/packages/ship/fixtures/hello/cloudflare.config.ts
1 module (0.8 KB), main worker.js
binds GREETING (plain_text)
binds BROKEN (plain_text)
binds VERSION (version_metadata)
provisions CACHE: kv ship-hello-cache, unless it exists
provisions DB: d1 ship-hello-db, unless it exists
rolls out 100%, smoke-testing /

CACHE and DB name no existing namespace or database, so ship makes them, named after the Worker and the binding. Then, for real:

0.00s shipping ship-hello
0.02s ✓ bundled 0.8 KB
1.07s ✓ created KV namespace ship-hello-cache
1.33s ✓ created D1 database ship-hello-db
2.74s ✓ created Worker ship-hello, live
64.89s ✓ smoke test passed: 3 × GET /
65.44s ✓ shipped ship-hello: https://ship-hello.<account>.workers.dev

(That smoke test waited out a minute of a brand new workers.dev URL warming up. They’re usually quicker.)

From packages/ship, with CLOUDFLARE_API_TOKEN set:

Terminal window
pnpm ship path/to/cloudflare.config.ts # bundles it with esbuild, and ships
pnpm ship path/to/project --prebuilt # what `cf build` or Vite built
pnpm ship plan path/to/project # what a ship would do, read from the account
pnpm ship destroy path/to/project --yes # the Worker, and what ship made for it
# (--allow-data-loss for a KV, D1 or R2 one)

The project is a cloudflare.config.ts or its folder.

  • With a config, ship loads it with Cloudflare’s own loader (@cloudflare/config), evaluated for --mode, and bundles the entrypoint with esbuild into one module, as workerd loads it. Static files come from public/ beside it, or --assets <dir>.
  • With --prebuilt, it deploys the Build Output that cf build and Cloudflare’s Vite plugin write to .cloudflare/output/, as cf deploy would: the Worker’s modules by their manifest, and its assets. It refuses an output built in another mode, one with a symlink anywhere, or a module outside its bundle, so a deploy never uploads a file from elsewhere.

It never uses Wrangler’s deploy code. Every call goes through an Effect SDK generated from Cloudflare’s API.

  • Provisioning. A KV, D1, R2 or queue binding that names no resource gets one. One that exists already is used as it is.
  • A version before traffic. An existing Worker gets a new version with no traffic, smoke-tested on its own preview URL before any user sees it; none at all if its code, assets, config and bindings are the deployed version’s (--force makes one anyway), and ship plan says which of those change.
  • All at once, or in steps: a version that passed its test takes the traffic at once; --steps 10,50,100 moves it a step at a time, each smoke-tested, pinned to the new version.
  • Smoke tests that check who answered, with a small probe module in front of your Worker’s, as How a rollout stays safe explains.
  • Static assets, content-hashed, uploaded before the Worker, only those Cloudflare lacks.
  • Durable Objects, as Cloudflare’s declarative exports. A version that changes them needs --atomic.
  • Routes and custom domains, attached once it’s live. One that serves another Worker stops the ship before anything is made, unless you pass --take-routes, which takes Email Routing addresses too. Queue consumers, set once it’s live, and removed when the config stops naming them.
  • Secrets, with --secret NAME, set from the environment variable NAME, never from an argument.
  • All or nothing. On a failure or Ctrl-C, everything is undone in reverse; resources that existed before are never touched.

A Vite app built with Cloudflare’s plugin, from its Build Output. Its first ship failed, rightly:

4.73s ✓ created Worker ship-vite, live
18.69s ↩ deleted Worker ship-vite
19.07s ↩ deleted KV namespace ship-vite-visits
failed: smoke test of https://ship-vite.<account>.workers.dev/ failed: the probe got no version back, so the new Worker didn't answer

The app’s assets answered the probe’s path with the single-page app’s index.html, so the smoke test couldn’t tell which version it reached, and ship undid everything: the Worker, and the namespace it had made. A smoke test that only checked for a 200 would have passed. ship now routes the probe’s path to the Worker ahead of the assets, and the next try went through:

0.00s ✓ 0.4 KB of modules, 2 asset files
1.03s ✓ created KV namespace ship-vite-visits
3.69s ✓ uploaded 2 of 2 asset files (1.0 KB)
4.73s ✓ created Worker ship-vite, live
31.42s ✓ smoke test passed: 3 × GET /, answered by the new Worker
31.43s ✓ shipped ship-vite: https://ship-vite.<account>.workers.dev
Default
--prebuilt deploy the Build Output rather than bundling the config
--worker <name> the default the Build Output Worker to deploy
--mode <mode> the config’s ctx.mode; a Build Output must be built in it
--steps 10,50,100 100 percentages of traffic, ending at 100
--interval 5s 5s how long each step lasts before its smoke test
--canary 10,50 steps judged on Workers Analytics’ error rates, rolled back if worse
--bake 60s 60s how long each canary step serves before it’s judged
--canary-strict a canary step too quiet to judge fails
--smoke /path / the path the smoke test requests
--requests 3 3 successes in a row that pass a smoke test
--no-smoke no smoke tests, such as for a Worker with no HTTP
--no-verify smoke tests that don’t check which version answered
--assets <dir> public/ a config’s static files
--atomic a version that changes exports, live before its smoke test
--force a new version even when the deployed one is the same
--take-routes take routes, domains and Email Routing addresses another Worker serves
--secret NAME set a declared secret from the environment variable NAME
--message <text> annotate the version and deployments
--via <url> ship through a deployer Worker, with an Access service token it lets in (or its key, in SHIP_DEPLOY_KEY)
--json ship plan as JSON
--dry-run load, bundle and describe, with no requests

The token needs Workers Scripts Edit, plus Workers KV Storage Edit, D1 Edit, R2 Edit or Queues Edit for what it provisions. The account is the config’s accountId, or CLOUDFLARE_ACCOUNT_ID, or the token’s first account.

ship destroy deletes the Worker, then the resources ship would have provisioned for it, found by their names, but only those the Worker is bound to. A resource that merely has such a name is left alone, as is one the config names by id. If any of those holds data (all but a queue), it deletes nothing unless you pass --allow-data-loss.

  • infra if your app is declared in Effect: it reads the declarations, checks them, ships every Worker of the app together, keeps state, and does environments.
  • ship for one Worker that already has a cloudflare.config.ts or a Build Output. It has no state of its own: it reads the account each time.

ship is also a library, @forge-effect/ship, with no Node APIs in its core: ship(deployable, options), planShip and destroy. That’s how infra uses it, and how it runs inside a Worker.

The deployer is a Worker that runs ship’s core, so the machine that ships holds no Cloudflare token: --via <url> sends the Worker to it, and it ships from inside Cloudflare, streaming the log back.

  • Bindings it deploys: KV, D1, R2, queues (producers and consumers), service bindings, Durable Objects, workflows, assets, text, JSON, secrets, Secrets Store secrets, version metadata, Workers AI, AI Search and its namespaces, Vectorize, Hyperdrive, Analytics Engine, Browser Rendering, Images, Media, rate limits, send email, mTLS certificates, dispatch namespaces, Worker loaders, VPC services and networks, Pipelines, Flagship, Artifacts and K2 streams. Any other fails before a request is made.
  • Custom domains and assets-only Workers, checked live through infra: this guide is an assets-only Worker (one with no code, which can’t have bindings or runWorkerFirst) on a custom domain. Routes on a zone are tested against a fake Cloudflare only.
  • The probe adds a module, and a version metadata binding named __SHIP_VERSION if the Worker has none. --no-verify or --no-smoke leaves the Worker exactly as it is.
  • --message writes the workers/message annotation, which Void also uses for its own deploy state, so don’t use both on one Worker.
  • @cloudflare/config says it isn’t stable yet, so ship pins it (0.26.0).