Nx plugin for Cloudflare.
- ✅ Generate Cloudflare Worker Application
- ✅ Include Fetch Handler template
- ✅ Include Scheduled Handler template
- ✅ Vitest tests support
- ✅ Inferred
serve,deploy,typegen,version-upload, andtailtargets (via the@naxodev/nx-cloudflare/pluginCrystal plugin).
- ✅ Generate Cloudflare Worker Library
Nx Cloudflare is published as the @naxodev/nx-cloudflare package.
| Toolchain | Command |
|---|---|
| NPM CLI | npm install @naxodev/nx-cloudflare |
| PNPM CLI | pnpm add @naxodev/nx-cloudflare |
| Yarn CLI | yarn add @naxodev/nx-cloudflare |
Nx Cloudflare is compatible with the following versions of Nx:
| Nx Version | Nx Cloudflare Version |
|---|---|
| 17.x | 1.x |
| 18.x | 2.x |
| 19.x | 3.x |
| 20.x | 4.x |
| 21.x | 5.x |
nx g @naxodev/nx-cloudflare:application my-worker-appAvailable options:
| Option | Type | Default | Description |
|---|---|---|---|
| name | string | *required | What name would you like to use? |
| template | fetch-handler, scheduled-handler, hono, none | fetch-handler | Which worker template do you want to use? |
| projectNameAndRootFormat | as-provided, derived | as-provided | Whether to generate the project name and root directory as provided (as-provided) or generate them composing their values and taking the configured layout into account (derived). |
| port | number | 8787 | The port in which the worker will be run on development mode |
| accountId | string | null | The Cloudflare account identifier where the worker will be deployed |
| configFormat | jsonc, toml | jsonc | Format of the generated Wrangler configuration file (wrangler.jsonc or wrangler.toml). |
| js | boolean | false | Use JavaScript instead of TypeScript |
| tags | string | null | Add tags to the application (used for linting). |
| unitTestRunner | vitest, none | vitest | Test runner to use for unit tests. |
| directory | string | null | The directory of the new application. |
| rootProject | boolean | false | Create worker application at the root of the workspace |
| skipFormat | boolean | false | Skip formatting files. |
The generator emits a wrangler.jsonc by default — Cloudflare's recommended format, and the only one that some newer Wrangler features support. The generated file includes a $schema reference (resolved relative to the workspace-root node_modules) so editors validate and autocomplete the config:
To generate a wrangler.toml instead, pass --configFormat=toml:
nx g @naxodev/nx-cloudflare:application my-worker-app --configFormat=tomlGenerated Worker projects get their targets from the @naxodev/nx-cloudflare/plugin inference plugin (registered in nx.json by the generator). Any project with a wrangler.{jsonc,toml,json} beside a project.json/package.json gets:
| Target | Runs | Notes |
|---|---|---|
serve |
wrangler dev |
Continuous local dev server. |
deploy |
wrangler deploy |
Deploys the Worker. |
typegen |
wrangler types |
Generates worker-configuration.d.ts. |
version-upload |
wrangler versions upload |
Uploads a version (gradual deploys). |
tail |
wrangler tail |
Streams live logs. |
nx serve <my-app>
nx deploy <my-app>These targets wrap the Wrangler CLI, so any Wrangler flag passes straight through after --:
nx serve <my-app> -- --remote
nx deploy <my-app> -- --dry-runSee the wrangler dev and wrangler deploy docs for the full flag list. The dev-server port is set via dev.port in the generated wrangler config (defaults to 8787).
nx g @naxodev/nx-cloudflare:library my-worker-libAvailable options:
| Option | Type | Default | Description |
|---|---|---|---|
| name | string | *required | What name would you like to use? |
| directory | string | null | The directory of the new application. |
| projectNameAndRootFormat | as-provided, derived | as-provided | Whether to generate the project name and root directory as provided (as-provided) or generate them composing their values and taking the configured layout into account (derived). |
| linter | eslint, none | eslint | The tool to use for running lint checks. |
| unitTestRunner | vitest, none | vitest | Test runner to use for unit tests. |
| tags | string | null | Add tags to the application (used for linting). |
| skipFormat | boolean | false | Skip formatting files. |
| js | boolean | false | Use JavaScript instead of TypeScript |
| strict | boolean | true | Whether to enable tsconfig strict mode or not. |
| publishable | boolean | false | Generate a publishable library. |
| importPath | string | null | The library name used to import it, like @myorg/my-awesome-lib. Required for publishable library. |
| bundler | swc, tsc, vite, esbuild, none | tsc | Which bundler would you like to use to build the library? Choose 'none' to skip build setup. |
| minimal | boolean | false | Generate a library with a minimal setup. No README.md generated. |
| simpleName | boolean | false | Don't include the directory in the generated file name. |
This project is heavily inspired in the work done by other Nx Champions, check out their projects.
Thanks goes to these wonderful people (emoji key):
|
Nacho Vazquez 🐛 💻 📖 💡 🤔 🧑🏫 🚧 📆 👀 |
Abel Penton 💻 📖 |
Nik 💻 |
Chris Tunbridge 💻 |
{ "$schema": "../node_modules/wrangler/config-schema.json", "name": "my-worker-app", "compatibility_date": "2026-06-05", "compatibility_flags": ["nodejs_compat"], "main": "src/index.ts" }