configuration generator
The configuration generator adds a wrangler.jsonc and Cloudflare deploy/serve/types targets to an existing Nx project. It is framework-agnostic — bring your own framework’s Cloudflare adapter; this generator only wires the deploy, serve, and types layer.
Alias: config
bunx nx g @naxodev/nx-cloudflare:configuration <project>
What it does
Section titled “What it does”Running the generator:
- Writes
wrangler.jsoncinto the project root (shape depends ontemplate). - Installs
wranglerand@cloudflare/workers-typesinto the workspace rootpackage.jsondevDependencies. - Registers
@naxodev/nx-cloudflare/plugininnx.jsonif not already present, so thatserve,deploy,typegen,version-upload,version-deploy, andtailtargets are inferred from the Wrangler config. - Gitignores
worker-configuration.d.ts— the file generated bywrangler types.
Templates
Section titled “Templates”| Template | Description |
|---|---|
worker | Plain Worker. Points main at your entry file. (default) |
spa | Static assets only. No Worker entry; assets served directly by Cloudflare. |
fullstack | Static assets and an API Worker, with an ASSETS binding wired up. |
Options
Section titled “Options”| Option | Type | Default | Description |
|---|---|---|---|
project | string | (required) | The existing Nx project to add Cloudflare configuration to. |
template | string | worker | Shape of the generated wrangler.jsonc. One of worker, spa, fullstack. |
name | string | Worker name written to wrangler.jsonc. Defaults to a sanitized form of the project name (lowercase + hyphens, as Cloudflare requires). | |
main | string | src/index.ts | Worker entry point (project-relative). The generator does not create it — point it at your app’s entry. Ignored for the spa template. |
assetsDir | string | dist | Static assets directory wrangler serves, relative to the project root. Must point at your build output — Nx’s default output lives at the workspace root (e.g. ../../dist/apps/web), so override this unless your framework builds into the project. Used by spa and fullstack. |
compatibilityDate | string | compatibility_date in wrangler.jsonc (YYYY-MM-DD). Defaults to today. | |
nodejsCompat | boolean | false | Add compatibility_flags: ["nodejs_compat"] to wrangler.jsonc. |
Framework-agnostic note
Section titled “Framework-agnostic note”The configuration generator does not install or configure a framework. If you are using React, Vue, Svelte, Astro, or another framework, install and configure the framework’s Cloudflare adapter separately — the generator only writes the Wrangler config and registers the plugin so that serve, deploy, and typegen targets become available in your Nx graph.
Example
Section titled “Example”Add SPA (static-only) Cloudflare deployment to an existing web project whose build output lands in dist/web:
bunx nx g @naxodev/nx-cloudflare:configuration web --template=spa --assetsDir=dist/web
After the generator runs:
bunx nx show project web
The project now has inferred serve, deploy, typegen, version-upload, version-deploy, and tail targets.
Next steps
Section titled “Next steps”- Inferred targets —
serve,deploy,typegen,version-upload,version-deploy,tail - Plugin options — customising inferred target names
- Wrangler config — config formats
- application generator — scaffold a new Cloudflare Worker from scratch
- binding generator — add KV, R2, D1, and other bindings