Back to Field notes

All field notes

How to

Moving a Deno Deploy app to Cloudflare Workers: what maps, what does not, and a checklist

Site and app migrations / 12 min read /

You can move most of a Deno Deploy app to Cloudflare Workers, and the parts that do not map cleanly are few and easy to name. Deno.serve becomes a Worker fetch handler, oak routes become Hono routes, Deno.cron becomes a Cron Trigger and Deno.env becomes Worker bindings. Deno KV is the hard part: it maps well to a SQLite-backed Durable Object, but queues, watch, filesystem access, several listeners and Fresh need a person to decide. Deno says Deno Deploy will be sunset in April 2027 (Deno, Deploy docs), so there is time to do it carefully.

Why move a Deno Deploy app now?

Because Deno has said Deno Deploy is ending. Deno's documentation carries a notice that Deno Deploy will be sunset in April 2027 and that existing applications keep running until then (Deno, Deploy docs). Deno's announcement of 9 October 2026 says its team is joining Cloudflare and that Deno Deploy will continue operating for six months before shutting down. It gives no exact shutdown date, and it does not mention Deploy Classic or Deno KV (Deno, announcement). We have not relied on any date that is not in those two pages, so check them before you plan around a deadline.

What maps cleanly from Deno to Workers?

The request handler, the router, scheduled jobs and environment variables. They have direct equivalents, and each can be converted mechanically.

Deno DeployCloudflare WorkersEffort
Deno.serve(handler)export default { fetch }Mechanical
oak Application and RouterHono app, exported as the defaultMechanical for routes, check middleware
Deno.cron(name, schedule, handler)triggers.crons plus a scheduled handlerMechanical, schedules run in UTC
Deno.env.get("X")env.X from the Worker's bindingsMechanical, secrets set separately
Deno.openKv() get, set, list, deleteA SQLite-backed Durable ObjectNeeds an adapter
kv.atomic()A synchronous SQLite transaction inside the Durable ObjectNeeds an adapter, test it
kv.enqueue and kv.listenQueueNo direct equivalent in the adapterManual
kv.watchNo direct equivalent in the adapterManual
Deno.readFile, Deno.writeFileR2, KV or bundled assetsManual
Several Deno.serve listenersOne fetch handler that routes by host or pathManual
Fresh appA Workers build of the framework, or a rewriteManual

How does Deno.serve with oak look on Workers?

The routes keep their shape and the server start-up goes away. A Worker exports its handler instead of opening a port. Hono's guide for Workers shows an app exported as the default with Wrangler for local development and deploys (Hono, Cloudflare Workers). Here is a small before and after.

// Before: Deno Deploy with oak
import { Application, Router } from "jsr:@oak/oak";

const router = new Router();
router.get("/hello/:name", (ctx) => {
  ctx.response.body = { hello: ctx.params.name };
});

const app = new Application();
app.use(router.routes());
Deno.serve(app.handle);
// After: Cloudflare Worker with Hono
import { Hono } from "hono";

const app = new Hono();
app.get("/hello/:name", (c) => c.json({ hello: c.req.param("name") }));

export default app;

Plain routes convert well. Middleware that reads or writes the oak context in unusual ways is where a human should look, because Hono's context object is not the same shape.

How do Deno.cron and Deno.env change?

A cron becomes a schedule in your Wrangler config plus a scheduled handler, and environment variables become bindings on env. Deno.cron takes a name, a schedule and a handler (Deno, cron). On Workers you add a crons array under triggers in wrangler.jsonc and export a scheduled handler that receives the controller, env and ctx. Cloudflare evaluates cron expressions in UTC, changes can take up to 15 minutes to propagate, and each deploy replaces the previous schedules (Cloudflare, Cron Triggers). If your Deno schedules assumed another time zone, convert them.

// Before
Deno.cron("nightly cleanup", "0 3 * * *", async () => {
  await cleanup(Deno.env.get("DATABASE_URL")!);
});
// After: src/index.ts
export default {
  async fetch(request, env, ctx) { /* routes */ },
  async scheduled(controller, env, ctx) {
    ctx.waitUntil(cleanup(env.DATABASE_URL));
  },
};
// wrangler.jsonc
{
  "name": "my-app",
  "main": "src/index.ts",
  "compatibility_date": "2026-11-01",
  "triggers": { "crons": ["0 3 * * *"] }
}

Deno's cron also skips overlapping runs and retries on exceptions, as its docs describe. Do not assume Cron Triggers behave the same way: make each job safe to run twice, or take a lock.

How does Deno KV move to a Durable Object with SQLite?

Store each KV entry as a row in a SQLite table inside one Durable Object, and run every operation through that object. Cloudflare recommends SQLite-backed Durable Objects for new namespaces, created with a new_sqlite_classes migration (Cloudflare, Durable Objects storage). The object's SQL API is synchronous, and its transactionSync method runs a callback in a transaction that rolls back if the callback throws (Cloudflare, SQLite storage API). Our Deno KV adapter is built on this design. The sketch below shows the general technique and is not the adapter's output.

// Illustration of the technique, not generated code
export class KvObject extends DurableObject {
  constructor(ctx, env) {
    super(ctx, env);
    ctx.storage.sql.exec(`CREATE TABLE IF NOT EXISTS kv (
      k BLOB PRIMARY KEY, v BLOB NOT NULL, version INTEGER NOT NULL
    ) WITHOUT ROWID`);
  }
}

How are Deno KV key ordering and atomic semantics preserved?

Ordering comes from encoding keys so that byte order equals Deno's order, and atomic() comes from checking versions and writing inside one synchronous transaction. Deno orders key parts first by type (Uint8Array, then string, then number, then bigint, then boolean), and within a type by byte order, numeric order or false before true (Deno, key space). SQLite compares BLOB values with memcmp (SQLite, datatypes), so a key encoding that puts a type tag first and writes each value in a byte-comparable form makes ORDER BY on the key column match Deno's list order. Prefix and range listing become range scans on that column.

For transactions, Deno KV uses optimistic concurrency. Each read returns a versionstamp, and an atomic operation commits only if every checked key still has the version you read. Limits include 100 checks and 1,000 mutations per operation (Deno, transactions). In a Durable Object the same check-then-write runs inside transactionSync. Cloudflare says JavaScript is single-threaded and that input gates stop other events from interleaving during storage operations (Cloudflare, SQLite storage API), so no other request can change a row between the check and the write. If any check fails, the callback returns without writing and reports a failed commit, which is the ok: false result your code already handles.

// Illustration of an atomic commit inside the object
atomic(checks, mutations) {
  return this.ctx.storage.transactionSync(() => {
    for (const { key, version } of checks) {
      const row = this.ctx.storage.sql
        .exec("SELECT version FROM kv WHERE k = ?", key).toArray()[0];
      if ((row?.version ?? null) !== version) return { ok: false };
    }
    const v = this.nextVersion();
    for (const m of mutations) { /* INSERT OR REPLACE or DELETE */ }
    return { ok: true, version: v };
  });
}

Two things to test whatever adapter you use. First, versionstamps: Deno's are strings, so a replacement needs its own version number that only goes up. Second, cursors held across an await: Cloudflare warns that a cursor kept across an await has no snapshot isolation, so read results fully with toArray() before awaiting.

What does not map cleanly?

Queues, watch, filesystem access, several listeners and Fresh. These need a decision from you, and a migration tool should mark them rather than guess.

  • KV queues. Deno.Kv has enqueue, which delivers a value to a listener with optional delay and retry settings, and listenQueue, which receives each value and retries on failure (Deno, Deno.Kv API). Rebuild this on Cloudflare Queues, or on Durable Object alarms if the volume is small. Decide the retry and ordering rules on purpose.
  • kv.watch. Deno's watch emits new values for the keys you name (Deno, KV). Push-style updates on Workers usually mean a Durable Object holding WebSocket connections, so this is a design change.
  • Filesystem APIs. Workers have no persistent disk. Reads of files bundled with the app can become static assets, and writes need R2, KV or the database.
  • Several listeners. An app that starts more than one Deno.serve listener has to become one fetch handler that routes by host or path.
  • Fresh. Deno describes Fresh as its most popular web framework, with server rendering and small client-side islands (Deno, web development). A Fresh app is a framework, not a handler, so check the framework's own Workers support or plan a port.

Anything our migrator cannot convert safely is left in place with a TODO(redcenter-migrator) marker and listed in the report. That list is your manual review, and it also caps the readiness score, so the score reflects what actually converted. Also unsupported: native database drivers (SQLite over FFI, Postgres over Deno.connect; D1 is a good target for SQLite data), and Fresh apps are refused for paid tiers before any credit is used.

How is the converted output verified?

In an isolated container with no network access. Every migration is checked by a verifier container on Cloudflare Containers. It runs a TypeScript type check, a wrangler deploy dry-run bundle and two boot checks: a simulated runtime, and real workerd answering a request. A Worker that only runs on a schedule has scheduled() run instead. The result appears in the workbench a few seconds to about half a minute after the migration. A pass means the project type-checks, bundles and boots. It does not replace your own tests on your own data.

What should I know about limits before I move Deno KV data?

Plan around the object, not just the database. Each Durable Object is single-threaded with a soft limit of about 1,000 requests per second, and storage per object is capped (check the current figure on the limits page, since Cloudflare's own page shows 10 GB on Workers Paid and a different number in its FAQ) (Cloudflare, Durable Objects limits). A busy app may need its data split across several objects, for example by key prefix, which changes how a cross-prefix atomic() works. Deno's limits are 64 KiB per value and 2 KiB per key (Deno, transactions), well inside Cloudflare's 8 MB combined key and value limit, so values that fit in Deno will fit on the Durable Object.

How faithful is a live Deno KV export?

Faithful for keys and values, with two honest differences. We tested the live export (Pro and Agency) against Deno's open-source denokv server. Every key and value type, pagination and the SHA-256 checksum matched after syncing into the migrated Durable Object, and key order matches Deno KV. Remaining TTLs are not carried over, because the KV Connect protocol does not expose expiry, so re-apply expiry for entries that had one. Versionstamps are reassigned by the Durable Object, so do not store old versionstamps anywhere.

What is a safe checklist for the move?

Inventory, convert, test against a copy of your data, then switch traffic.

  1. List every Deno API your app uses: serve, oak, cron, env, openKv, enqueue, listenQueue, watch, file access, Fresh.
  2. Run the whole migration free, with its build and boot check, on the Deno Deploy migrator, or run the free open-source deno-audit CLI (MIT, run it with npx @redcenterstudio/deno-audit .) for a local static readiness scan. You pay only if the check passes, and the code unlocks straight after payment.
  3. Fix every TODO(redcenter-migrator) marker by hand, starting with queues and watch.
  4. Convert cron schedules to UTC and make each job safe to run twice.
  5. Set secrets with Wrangler, never in the config file.
  6. Export your Deno KV data and verify it with a checksum. Keep the export until you are sure.
  7. Load the data into a staging Worker and run your own tests on atomic() conflicts and list order.
  8. Check long-running and large-value paths against the Durable Object limits.
  9. Point a test hostname at the Worker, compare responses with the old app, then move your domain.
  10. Redirect old .deno.net addresses with a 301 so old links keep working.
  11. Keep the old app running until the new one has handled real traffic.

Where can the migrator help?

The Deno Deploy to Cloudflare Workers Migrator runs the whole migration free, with an isolated build and boot check, and you pay only if it passes. A deterministic TypeScript codemod then converts Deno.serve, oak, Deno.cron, Deno.env and Deno.openKv(), and hands back a zip or a GitHub pull request that runs in your own Cloudflare account. Starter is $79 USD for a stateless app of up to 15 routes. Pro, $149 USD, adds unlimited routes, the Deno KV adapter and live KV export with a SHA-256 checksum and a 7-day rollback snapshot. Agency, $249 USD, gives five migration credits and a redirect Worker for .deno.net addresses. Start at deno.redcenterstudio.com. Prefer to hand the whole job over? See Website and App Migrations.

Frequently asked questions

Can I move a Deno Deploy app to Cloudflare Workers?

Yes. Deno.serve, oak, Deno.cron and Deno.env convert directly, and Deno KV can run on a SQLite-backed Durable Object. Queues, watch, filesystem writes, multiple listeners and Fresh need manual work.

Does Cloudflare have a Deno KV equivalent?

Not an identical product. Workers KV is a different, eventually consistent store. A SQLite-backed Durable Object is the closer match, because it gives you transactions and ordered reads in one place.

Will my atomic() transactions still work?

They can, if the adapter runs the version checks and the writes inside one synchronous transaction in a single Durable Object. Test conflicts on your own data before you switch.

Is the key order the same?

It can be, if keys are encoded so that byte order matches Deno's type-then-value order. Test list calls with mixed key types, because that is where differences show up.

What happens to my queues?

They do not move automatically. Rebuild them on Cloudflare Queues or Durable Object alarms and decide the retry rules yourself.

When does Deno Deploy shut down?

Deno's docs say it will be sunset in April 2027, and its 9 October 2026 announcement says Deploy will keep operating for six months before shutting down. Neither page gives an exact day.

How is the migrator's output checked?

An isolated verifier container with no network access runs a type check, a wrangler dry-run bundle and two boot checks, including real workerd. Anything not converted is marked, listed and caps the readiness score.

Are Deno KV TTLs and versionstamps kept in a live export?

No. Remaining TTLs are not carried over and versionstamps are reassigned by the Durable Object. Keys, values and key order match, and the checksum is verified.

Does the migrator use AI to rewrite my code?

No. It is a deterministic codemod on the TypeScript syntax tree, so the same input gives the same output. What it cannot convert is marked and listed.

Edited

Sources

  1. Deno Deploy docs (sunset notice), Deno documentation
  2. Deno is joining Cloudflare (announcement, 9 October 2026), Deno
  3. Deno KV key space and ordering, Deno documentation
  4. Deno KV transactions, Deno documentation
  5. Deno KV manual (watch, consistency), Deno documentation
  6. Deno.Kv API (enqueue, listenQueue), Deno documentation
  7. Deno.cron, Deno documentation
  8. Web development with Deno (Fresh), Deno documentation
  9. SQLite-backed Durable Objects storage, Cloudflare documentation
  10. Durable Object SQLite storage API, Cloudflare documentation
  11. Durable Objects limits, Cloudflare documentation
  12. Cron Triggers, Cloudflare documentation
  13. Hono on Cloudflare Workers, Hono documentation
  14. SQLite datatypes (BLOB comparison), SQLite documentation

More field notes