Skip to content

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>

Running the generator:

  1. Writes wrangler.jsonc into the project root (shape depends on template).
  2. Installs wrangler and @cloudflare/workers-types into the workspace root package.json devDependencies.
  3. Registers @naxodev/nx-cloudflare/plugin in nx.json if not already present, so that serve, deploy, typegen, version-upload, version-deploy, and tail targets are inferred from the Wrangler config.
  4. Gitignores worker-configuration.d.ts — the file generated by wrangler types.
TemplateDescription
workerPlain Worker. Points main at your entry file. (default)
spaStatic assets only. No Worker entry; assets served directly by Cloudflare.
fullstackStatic assets and an API Worker, with an ASSETS binding wired up.
OptionTypeDefaultDescription
projectstring(required)The existing Nx project to add Cloudflare configuration to.
templatestringworkerShape of the generated wrangler.jsonc. One of worker, spa, fullstack.
namestringWorker name written to wrangler.jsonc. Defaults to a sanitized form of the project name (lowercase + hyphens, as Cloudflare requires).
mainstringsrc/index.tsWorker entry point (project-relative). The generator does not create it — point it at your app’s entry. Ignored for the spa template.
assetsDirstringdistStatic 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.
compatibilityDatestringcompatibility_date in wrangler.jsonc (YYYY-MM-DD). Defaults to today.
nodejsCompatbooleanfalseAdd compatibility_flags: ["nodejs_compat"] to wrangler.jsonc.

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.

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.