Getting started
Move from Deno Deploy
Turn a Deno Deploy app into a Cloudflare Workers project that runs on Orange, or on Cloudflare.
orange migrate deno turns a Deno Deploy app into a plain Cloudflare Workers
project. Deno.serve, Deno.env, Deno.cron and Deno KV keep working, and
the project has no Orange imports, so it also runs on Cloudflare.
Quickstart
You need Node.js 22 or later and pnpm. Your Deno app does not change: the command writes the project next to it.
-
Write the Workers project
Run the command in the folder that holds your app. It prints what moved and a checklist of what needs a change by hand.
orange migrate deno notes ✓ Wrote a Workers project to notes-worker (10 files). ✓ main.ts:1 npm:mime@^4.0.0: Imports mime from package.json. ✓ main.ts:5 Deno.openKv: Stores its data in the DenoKvStore Durable Object. ✓ main.ts:6 Deno.env.get: Reads GREETING from the Worker's vars and secrets. ✓ main.ts:8 Deno.cron: Runs from the scheduled handler on "*/5 * * * *". ✓ main.ts:13 Deno.cron: Runs from the scheduled handler: "0 9 * * 1" (Deno) is "0 9 * * 2" in Cloudflare's weekday numbers. ✓ main.ts:37 Deno.KvU64: Is KvU64 from deno-compat/kv.ts. ✓ main.ts:59 Deno.serve: Runs as the Worker's fetch handler. ! 3 items need a change by hand: [ ] main.ts:17 kv.listenQueue: Deno KV queues and watch() do not run on Workers. Use Cloudflare Queues or a Durable Object alarm. [ ] main.ts:54 Deno.readTextFile: Read files that ship with the app from static assets or R2. node:fs also runs on Orange. [ ] deno.json:1 tasks: deno.json tasks (dev) did not move. package.json has wrangler dev and deploy scripts. Run it: cd notes-worker pnpm install orange dev -
Fix the checklist
Change each listed line in
notes-worker. Each item names the Workers API to use instead. -
Run it
Put your environment variables in
.dev.vars..dev.vars.examplelists the names your code reads.cd notes-worker cp .dev.vars.example .dev.vars pnpm install orange dev -
Deploy it
Deploy to your Rivet cluster. See Deploy.
orange deploy
Run it on Cloudflare
The project is a plain Workers project, so Wrangler deploys it as it is.
pnpm wrangler deploy
Update it after a change
Change the Deno app, then run the command again. It rewrites the files it wrote,
deletes the ones that no longer come from the app, and keeps files you added,
such as .dev.vars. If you changed a file it wrote, it stops and lists the
file: make that fix in the Deno app, or pass --force to overwrite it.
orange migrate deno notes
AI context What moves, what does not, Deno KV details, flags, exit codes, and errors
Written for LLMs and coding agents: every edge case, measurement, and known deviation. You do not need it to use the feature.
What moves
| In the Deno app | In the Workers project |
|---|---|
Deno.serve(handler), Deno.serve(options, handler), Deno.serve({ handler }) | The Worker’s fetch handler. The handler gets (request, info). info.remoteAddr.hostname is the cf-connecting-ip header, info.completed settles when the handler returns, and onError answers when the handler throws. The last call wins. Ports, hostnames and onListen do not apply. |
export default { fetch } in the entry module (deno serve) | The Worker’s fetch handler, when the app calls no Deno.serve. |
Deno.env.get, has, set, delete, toObject | Reads the Worker’s string vars and secrets through env from cloudflare:workers, so reads at module scope work. set and delete change only the running isolate. |
Deno.cron(name, "<cron>", [options], handler) | A scheduled handler that runs every job whose schedule equals controller.cron, and the schedule in triggers.crons. backoffSchedule does not apply. |
Deno.openKv(path?) | The DenoKvStore Durable Object, bound as DENO_KV, with a new_sqlite_classes migration. Each path is one object. No path is the object named default. |
Deno.KvU64 | KvU64 in deno-compat/kv.ts |
import.meta.main | true in the entry module, false elsewhere |
npm:pkg@version/sub | pkg/sub, and "pkg": "version" in package.json |
jsr:@scope/name@version/sub | @scope/name/sub, and "@scope/name": "npm:@jsr/scope__name@version" in package.json, with @jsr:registry=https://npm.jsr.io in .npmrc. This is JSR’s npm compatibility layer. |
npm:pkg or jsr:@scope/name with no version | The version in deno.lock, else the version another import of the package names, else * with a checklist item. When deno.lock resolves it to the same release as an import with a version, both share that entry. |
Two versions of one package, such as npm:zod@3 and npm:zod@4 | One alias each, such as "zod-3": "npm:zod@3", and each import uses its alias |
imports in deno.json, or the file in importMap | Each import resolves through the map as Deno does: an exact key, else the longest key that ends in /. A local path becomes a relative import. A path that starts with / is from the app’s folder. A node: built-in or a package name becomes that import. |
compilerOptions.jsx, jsxFactory, jsxFragmentFactory, jsxImportSource in deno.json | tsconfig.json, unless the app has one. "jsx": "precompile" becomes "react-jsx". A jsxImportSource package, with its subpath, goes in package.json. |
package.json | Merged into the written package.json. Its dependencies win. |
Each file that uses the global Deno imports it from deno-compat/deno.ts,
which holds only the APIs above. The import goes after a shebang line. Deno in
type positions, such as Deno.Kv, does not change and is not reported. A file
that declares or imports its own Deno, such as a parameter, keeps it in that scope.
What does not move
The command reports each of these with its file and line, and never drops code:
| In the Deno app | What to do |
|---|---|
Other Deno.* APIs, such as Deno.readTextFile, Deno.upgradeWebSocket, Deno.Command | Use the Workers API that the report names. File APIs: static assets or R2. node:fs also runs on Orange, which runs stock Node.js. |
Deno.cron with an object schedule or a schedule that is not a string literal | Write the schedule as a cron string. At run time such a job logs an error and does not run. |
backoffSchedule in Deno.cron options | Workers do not retry a failed cron run. Retry inside the job. |
A Deno KV call at module scope, such as a top-level await kv.get() | Move it into the Deno.serve handler or a Deno.cron job. Workers allow storage calls only inside a handler. At run time it fails with an error that says so. |
A Deno KV call that a Deno.cron job does not await | Await it. The scheduled handler ends when the job returns, so Cloudflare can drop the call. |
globalThis.Deno, self.Deno, window.Deno | Use Deno. In a Worker these are undefined. |
Deno-only packages: a /deno adapter such as hono/deno or jsr:@hono/hono/deno, @std/fs, @std/http/file-server, @std/dotenv | Use the package’s Workers adapter, and serve static files with Workers static assets (assets in wrangler.jsonc). These packages call the global Deno, which a Worker lacks, and fail with Deno is not defined. |
An npm: or jsr: import with no version that deno.lock does not list | Set its version in package.json. |
The app’s own wrangler.jsonc, .dev.vars.example, or deno-compat/ files | The command writes these files. Move what the app’s copy needs into the written one. |
kv.listenQueue(), kv.enqueue(), atomic().enqueue(), kv.watch() | Use Cloudflare Queues or a Durable Object alarm. At run time listenQueue() logs an error, and the others fail with an error that names the replacement. |
new BroadcastChannel() | Use a Durable Object. |
https:// imports | Add the package to package.json and import it by name. The report prints the URL without its credentials, query and fragment. |
An app with no Deno.serve call and no default export | Frameworks that call Deno.serve themselves, such as Fresh and Oak’s app.listen(), need Deno.serve(app.handler) or similar. Until then the Worker answers 500. |
deno.json tasks and keys the command does not know | package.json has dev and deploy scripts. |
| Data in Deno KV on Deno Deploy | The command moves code, not data. See Copy Deno KV data. |
The report finds every listenQueue() call, and watch() and enqueue() calls
on a variable that holds await Deno.openKv() in any file, such as
kv.atomic().enqueue(). A call through another name, such as a function
parameter, is not reported, and fails at run time as above.
Cron weekday numbers
Cloudflare numbers weekdays from 1 (Sunday) to 7 (Saturday). Deno numbers them
from 0 (Sunday) to 6, and 7 is also Sunday. The command moves each weekday in a
schedule to Cloudflare’s number, both in the code and in triggers.crons, so a
job runs on the same days: "0 9 * * 1" (Monday) becomes "0 9 * * 2",
1-5 becomes 2-6, and 5-7 becomes 1,6-7. Weekday names such as MON do
not change.
Deno KV on a Durable Object
- Each database is one SQLite-backed Durable Object, so reads and atomic
commits are strongly consistent, as on Deno Deploy.
consistency: "eventual"reads the same data. get,getMany,set,delete,list(withprefix,start,end,limit,reverse,cursor,batchSize),atomic()withcheck,set,delete,sum,min,maxandmutate, versionstamps,expireIn, andclose()work.list()returns keys in Deno KV’s order. Keys are encoded as in denokv.- A versionstamp is 20 hex digits that grow with each commit to the database.
- An entry stops reading as soon as its
expireInpasses. Deno deletes it at some point after. - Values pass through Workers RPC and Durable Object storage, which use the
structured clone algorithm. A
KvU64inside another value comes back as a plain object. A top-levelKvU64value comes back as aKvU64. - Cursors are Deno’s: the last key after the selector’s common prefix, in
base64url. A cursor outside the selector’s range fails with
cursor out of bounds, as in Deno. An iterator that ran out has the cursor"". atomic()copies each key and value when it is queued, as Deno does.- A call at module scope, while the Worker’s modules load, fails with an error that says to move it into a handler.
Copy Deno KV data
The command does not copy data yet. Deno Deploy’s KV databases accept KV
Connect from outside Deno Deploy: openKv from the
@deno/kv npm package, with the
database’s KV Connect URL and DENO_KV_ACCESS_TOKEN. A copy lists every entry
there and writes it through the Worker’s DenoKvStore, with the app’s writes
stopped. Deno Deploy shuts down in April 2027.
Files
| File | What it is |
|---|---|
| Your files | Copies, with the changes above. Files that .gitignore names, node_modules, .git, .open-orange, deno.json, deno.jsonc and deno.lock are not copied. |
wrangler.jsonc | Name from deno.json name without its scope, else the folder name. main is ./deno-compat/worker.ts, with nodejs_compat, crons and the KV binding. |
package.json, .npmrc | Dependencies from npm: and jsr: imports. .npmrc only for jsr:, with the app’s own .npmrc lines kept. |
.gitignore | The app’s .gitignore, with .dev.vars* (but not .dev.vars.example), node_modules, .wrangler and .open-orange/* added |
.open-orange/migrate-deno.json | Each file the command wrote, with its SHA-256. A later run reads it to tell its files from yours. .gitignore keeps it in Git. |
.dev.vars.example | Each name that the code reads with Deno.env.get("NAME") |
deno-compat/worker.ts | The Worker’s entry. It imports your entry module and exports the Worker. |
deno-compat/deno.ts, deno-compat/kv.ts | The Deno APIs above and the DenoKvStore class |
The entry module is --entry, else deploy.entrypoint in deno.json, else
the file that the start, serve or dev task runs, else the first of
main.ts, main.tsx, main.js, server.ts, server.js, mod.ts,
index.ts, index.js, src/main.ts, src/index.ts.
Flags
| Flag | Meaning |
|---|---|
[dir] | The Deno app. Default: the current directory. |
--out <dir> | Where to write the project. Default: <dir>-worker. It must be outside <dir>. |
--force | Overwrite, or delete, files in --out that changed since the last run |
--entry <file> | The entry module, relative to <dir> |
--dry-run | Print the report and write nothing |
--json | Print { dryRun, files, items, out, removed, source }. removed lists the files a rerun deletes. Each item has api, file, line, column, note, and status (migrated or manual). |
--cwd <dir> | Run as if started in <dir> |
Exit codes and errors
| Code | When |
|---|---|
0 | The project was written, or would be with --dry-run, also when the checklist has items |
1 | The app cannot move, and nothing was written: no entry module, a file that does not parse (Couldn't parse lib/broken.ts:1:18), invalid deno.json, package.json or deno.lock, a missing importMap file, or oxc-parser that does not load |
1 | The output is not safe to write, and nothing was written or deleted: --out is inside <dir> (also through a symlink), is a symlink, or is a file; --out holds files and no manifest; the manifest names a path outside --out; a path in --out is a symlink; a file the command did not write is where it would write, or where it needs a folder; or, without --force, a file it wrote has changed. The error lists the files. |
2 | An unknown flag, or more than one folder |