Skip to content

Inferred targets

For every project with a Wrangler config, the plugin infers a set of Nx targets that shell out to the Wrangler CLI. Target names are configurable — see Plugin options.

Forward flags to the underlying Wrangler command after --:

bunx nx run <my-worker>:<target> -- --some-wrangler-flag

Runs wrangler dev from the project root, starting a continuous local development server for the Worker.

  • Command: wrangler dev
  • Continuous: yes
  • Readiness: readyWhen: { logMatches: 'Ready on' } at the target level. Tasks that request waitFor: 'ready' wait for Wrangler’s listening message.

The dev server port is set via dev.port in the Wrangler config and defaults to 8787.

bunx nx run <my-worker>:serve -- --remote
bunx nx run <my-worker>:serve -- --ip 0.0.0.0

See the wrangler dev CLI docs.

Add this dependency to an existing test target. Replace my-worker with the Worker’s Nx project name:

{
  "targets": {
    "e2e": {
      "dependsOn": [{ "projects": "my-worker", "target": "serve", "waitFor": "ready" }]
    }
  }
}

Use the configured target name instead of serve if you set serveTargetName. Nx keeps the Worker running while dependent tasks need it. A startup failure or readiness timeout prevents those tasks from running. Without waitFor: 'ready', dependent tasks start once the server process starts.

The default readiness timeout is ten minutes. Override it in the Worker’s project configuration with "readyWhen": { "...": true, "timeout": 30000 } to retain the inferred check and wait at most 30 seconds.

Wrangler log levels such as warn, error, or none can hide the listening message. If you suppress it, replace the target’s readyWhen with a URL or port check that matches your server. Set it to null to disable the check. These are target-level fields, separate from options passed to Wrangler.

See Nx readiness checks for the supported checks and override rules.

Runs wrangler deploy from the project root, publishing the Worker to Cloudflare’s edge network.

  • Command: wrangler deploy
  • Continuous: no
bunx nx run <my-worker>:deploy -- --dry-run
bunx nx run <my-worker>:deploy -- --name my-custom-worker

See the wrangler deploy CLI docs.

Runs wrangler types from the project root, generating worker-configuration.d.ts — the typed Env interface and Workers runtime types derived from the Wrangler config.

  • Command: wrangler types
  • Continuous: no
  • Cached: yes
  • Inputs: project files, upstream project files, and the wrangler external dependency
  • Outputs: {projectRoot}/worker-configuration.d.ts

worker-configuration.d.ts is a generated artifact and is git-ignored. typegen is inferred only for Worker applications (projects with a Wrangler config); Worker libraries do not have one.

bunx nx run <my-worker>:typegen -- --name MyEnv

See the wrangler types CLI docs.

Runs wrangler versions upload from the project root, uploading a new version of the Worker to Cloudflare’s Versions API. This is the foundation for gradual deployments — rolling out new versions incrementally and rolling back instantly.

  • Command: wrangler versions upload
  • Continuous: no
bunx nx run <my-worker>:version-upload -- --message "fix: update handler"

See the Wrangler versions docs.

Runs wrangler versions deploy from the project root, shifting traffic to one or more previously uploaded Worker versions. Pair with version-upload for gradual deployments — upload a version, then deploy it once it has been verified.

  • Command: wrangler versions deploy
  • Continuous: no
bunx nx run <my-worker>:version-deploy -- --message "roll out fix"

See the Wrangler versions docs.

Runs wrangler tail from the project root, streaming live logs from a deployed Worker in real time. For local development, use serve instead and read the terminal output directly.

  • Command: wrangler tail
  • Continuous: yes
bunx nx run <my-worker>:tail -- --status error
bunx nx run <my-worker>:tail -- --format json

See the wrangler tail CLI docs.

The plugin infers a d1 target for each d1_databases binding in the Wrangler config. D1 inference is only for jsonc/json Wrangler configs (not TOML — there is no TOML parser in the plugin). The d1 target exposes three Nx configurations: apply, create, and list.

Unlike the Worker lifecycle targets above, the D1 and secret targets are backed by a dedicated executor and accept only the typed options documented below (--remote, --env, --message, --name, --file, --db). Arbitrary -- <wrangler flag> passthrough does not apply to them.

Runs wrangler d1 migrations apply <database>. Applies pending migrations to the local database by default; pass --remote for production. Accepts --env <environment>.

bunx nx run <my-worker>:d1:apply           # apply locally (default)
bunx nx run <my-worker>:d1:apply --remote  # apply to the remote database

See the wrangler d1 migrations apply CLI docs.

Runs wrangler d1 migrations create <database> <message>. Scaffolds a new migration file. Requires --message.

bunx nx run <my-worker>:d1:create --message=add_users

See the wrangler d1 migrations create CLI docs.

Runs wrangler d1 migrations list <database>. Lists unapplied (pending) migration files — those not yet applied to the target database. Uses the local database by default; pass --remote for production. Accepts --env <environment>.

bunx nx run <my-worker>:d1:list            # list local migrations
bunx nx run <my-worker>:d1:list --remote   # list remote migrations

See the wrangler d1 migrations list CLI docs.

When a Worker declares more than one d1_databases binding, pass --db=<binding> to select which database a command targets:

bunx nx run <my-worker>:d1:apply --db=ANALYTICS --remote
bunx nx run <my-worker>:d1:create --db=ANALYTICS --message=add_users

With a single D1 database, --db is optional. With multiple, omitting it errors and lists the valid bindings.

The plugin infers a secret target for every Worker — secrets are not declared in the Wrangler config so no config parsing is needed. Secret values are never passed as arguments. All configurations accept --env <environment>. The secret target exposes four Nx configurations: put, bulk, list, and delete.

Runs wrangler secret put <name>. Prompts interactively for the secret value; requires --name.

bunx nx run <my-worker>:secret:put --name=API_KEY

See the wrangler secret put CLI docs.

Runs wrangler secret bulk <file>. Uploads multiple secrets from a JSON file; requires --file=<path>. Do not commit that file to source control.

bunx nx run <my-worker>:secret:bulk --file=secrets.json

See the wrangler secret bulk CLI docs.

Runs wrangler secret list. Lists all secrets bound to the Worker.

bunx nx run <my-worker>:secret:list

See the wrangler secret list CLI docs.

Runs wrangler secret delete <name>. Deletes a secret; requires --name.

bunx nx run <my-worker>:secret:delete --name=API_KEY

See the wrangler secret delete CLI docs.

The plugin infers a version-secret target for every Worker alongside the secret target. Where secret operates on the currently deployed Worker, version-secret stages changes on a new version without shifting traffic — pair it with version-deploy for gradual deployments. All configurations accept --env <environment>.

Runs wrangler versions secret put <name>. Stages a secret on a new Worker version without deploying it; requires --name. Prompts interactively for the value.

bunx nx run <my-worker>:version-secret:put --name=API_KEY

See the wrangler versions secret put CLI docs.

Runs wrangler versions secret bulk <file>. Stages multiple secrets from a JSON file on a new version; requires --file=<path>. Do not commit that file to source control.

bunx nx run <my-worker>:version-secret:bulk --file=secrets.json

See the wrangler versions secret bulk CLI docs.

Runs wrangler versions secret list. Lists the secrets on the latest version. (Cloudflare does not publish a dedicated docs anchor for this subcommand.)

bunx nx run <my-worker>:version-secret:list

Runs wrangler versions secret delete <name>. Stages a secret removal on a new version; requires --name.

bunx nx run <my-worker>:version-secret:delete --name=API_KEY

See the wrangler versions secret delete CLI docs.