Workers (3)·续1
Workers Sites is deprecated. Please use Workers Assets or Pages.
- --site-include string[] optional deprecated
- Array of .gitignore-style patterns that match file or directory names from the sites directory. Only matched items will be uploaded.
- --site-exclude string[] optional deprecated
- Array of .gitignore-style patterns that match file or directory names from the sites directory. Matched items will not be uploaded.
- --var key:value\[] optional
- Array of key:value pairs to inject as variables into your code. The value will always be passed as a string to your Worker.
- For example, --var git_hash:$(git rev-parse HEAD) test:123 makes the git_hash and test variables available in your Worker's env.
- This flag is an alternative to defining vars in your Wrangler configuration file. If defined in both places, this flag's values will be used.
- --define key:value\[] optional
- Array of key:value pairs to replace global identifiers in your code.
- For example, --define GIT_HASH:$(git rev-parse HEAD) will replace all uses of GIT_HASH with the actual value at build time.
- This flag is an alternative to defining define in your Wrangler configuration file. If defined in both places, this flag's values will be used.
- --triggers, --schedule, --schedules string[] optional
- Cron schedules to attach to the deployed Worker. Refer to Cron Trigger Examples.
- --routes, --route string[] optional
- Routes where this Worker will be deployed.
- For example: --route example.com/*.
- --domain string[] optional
- Custom domains where this Worker will be deployed.
- For example: --domain example.com.
- --tsconfig string optional
- Path to a custom tsconfig.json file.
- --minify boolean optional
- Minify the bundled Worker before deploying.
- --dry-run boolean (default: false) optional
- Compile a project without actually deploying to live servers. Combined with --outdir, this is also useful for testing the output of npx wrangler deploy. It also gives developers a chance to upload our generated sourcemap to a service like Sentry, so that errors from the Worker can be mapped against source code, but before the service goes live.
- --keep-vars boolean (default: false) optional
- It is recommended best practice to treat your Wrangler developer environment as a source of truth for your Worker configuration, and avoid making changes via the Cloudflare dashboard.
- If you change your environment variables in the Cloudflare dashboard, Wrangler will override them the next time you deploy. If you want to disable this behaviour set keep-vars to true.
- Secrets are never deleted by a deployment whether this flag is true or false.
- --secrets-file string optional
- Path to a file containing secrets to upload alongside the deployment. Accepts JSON or .env format — the same formats used by wrangler secret bulk. Existing secrets not included in the file are preserved from the previous version. Refer to Secrets — Upload secrets alongside code for more details.
- --dispatch-namespace string optional
- Specify the Workers for Platforms dispatch namespace to upload this Worker to.
- --metafile string optional
- Specify a file to write the build metadata from esbuild to. If flag is used without a path string, this defaults to bundle-meta.json inside the directory specified by --outdir. This can be useful for understanding the bundle size.
- --containers-rollout immediate | gradual | none optional
- Rollout mode for Containers on this deploy. gradual (default) uses rollout_step_percentage. immediate uses one 100% step (not a simultaneous restart of every container instance). none skips container image and instance updates.
- --strict boolean (default: false) optional
- Turns on strict mode for the deployment command, meaning that the command will be more defensive and prevent deployments which could introduce potential issues. In particular, this mode prevents deployments if the deployment would potentially override remote settings in non-interactive environments.
- --tag string optional
- A tag for this Worker version. Matches the behavior of wrangler versions upload --tag.
- --message string optional
- A descriptive message for this Worker version and deployment. Matches the behavior of wrangler versions upload --message. The message is also applied to the deployment.
- --temporary boolean optional
- Deploy with a temporary preview account when no Cloudflare credentials are available. Requires Wrangler 4.102.0 or later. Wrangler prints a claim URL that lets you claim the deployment within 60 minutes. This is intended for AI agents and other first-time deployment flows. If Wrangler can already use OAuth, CLOUDFLARE_API_TOKEN, or a global API key, this flag returns an error. For more information, refer to Claim deployments.
The following global flags work on every command:
--helpboolean- Show help.
--configstring(not supported by Pages)- Path to your Wrangler configuration file.
--cwdstring- Run as if Wrangler was started in the specified directory instead of the current working directory.
preview
Create a Preview deployment of the current Worker for branch and pull request work. Use wrangler deploy for production.
wrangler preview [<SCRIPT>] [OPTIONS]
Note
None of the options for this command are required. Also, many can be set in your Wrangler file or in your Previews Base configuration. Refer to the Wrangler configuration documentation for more information.
SCRIPTstring- The path to an entry point for your Worker. Only required if your Wrangler configuration file does not include a
mainkey (for example,main = "index.js"). --namestringoptional- Name of the Preview. Defaults to the current git branch.
--tagstringoptional- A tag for this Preview deployment.
--messagestringoptional- A descriptive message for this Preview deployment.
--jsonboolean(default: false) optional- Return machine-readable output.
--ignore-base-configboolean(default: false) optional- Only use settings from your Wrangler file, ignoring the Preview base config configured in the Cloudflare dashboard.
--worker-namestringoptional- Name of the Worker to target. Defaults to the name in your local Wrangler file.
The following global flags work on every command:
--helpboolean- Show help.
--configstring(not supported by Pages)- Path to your Wrangler configuration file.
--cwdstring- Run as if Wrangler was started in the specified directory instead of the current working directory.
For example:
npx wrangler preview --name feature-branch
Other Preview branches are not affected.
preview delete
Delete a Preview and all its deployments
npmyarnpnpm
npx wrangler preview delete
yarn wrangler preview delete
pnpm wrangler preview delete
--namestringName of the Preview to delete (defaults to current git branch)--skip-confirmationbooleanalias: --ydefault: false
Skip the confirmation prompt
- --worker-name string Name of the Worker to target (defaults to the name in your local config file)
<details>
<summary>
Global flags
</summary>
- <code>--v</code><code>boolean</code> alias: --version
Show version number - <code>--cwd</code><code>string</code>Run as if Wrangler was started in the specified directory instead of the current working directory - <code>--config</code><code>string</code> alias: --c
Path to Wrangler configuration file - <code>--env</code><code>string</code> alias: --e
Environment to use for operations, and for selecting .env and .dev.vars files - <code>--env-file</code><code>string</code>Path to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files - <code>--install-skills</code><code>boolean</code> default: false
Install Cloudflare skills for detected AI coding agents before running the command - <code>--profile</code><code>string</code>Use a specific auth profile
</details>
preview secret put
Create or update a secret variable on a Worker Preview and create a new deployment
npmyarnpnpm
npx wrangler preview secret put <KEY>
yarn wrangler preview secret put <KEY>
pnpm wrangler preview secret put <KEY>
<KEY>stringrequired
The secret name to be accessible in the Worker
- --name string Name of the Preview (defaults to current git branch)
- --message string A descriptive message for this Preview deployment
- --tag string A tag for this Preview deployment
- --worker-name string Name of the Worker to target (defaults to the name in your local config file)
<details>
<summary>
Global flags
</summary>
- <code>--v</code><code>boolean</code> alias: --version
Show version number - <code>--cwd</code><code>string</code>Run as if Wrangler was started in the specified directory instead of the current working directory - <code>--config</code><code>string</code> alias: --c
Path to Wrangler configuration file - <code>--env</code><code>string</code> alias: --e
Environment to use for operations, and for selecting .env and .dev.vars files - <code>--env-file</code><code>string</code>Path to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files - <code>--install-skills</code><code>boolean</code> default: false
Install Cloudflare skills for detected AI coding agents before running the command - <code>--profile</code><code>string</code>Use a specific auth profile
</details>
preview secret delete
Delete a secret variable from a Worker Preview and create a new deployment
npmyarnpnpm
npx wrangler preview secret delete <KEY>
yarn wrangler preview secret delete <KEY>
pnpm wrangler preview secret delete <KEY>
<KEY>stringrequired
The secret name to delete
- --name string Name of the Preview (defaults to current git branch)
- --message string A descriptive message for this Preview deployment
- --tag string A tag for this Preview deployment
- --skip-confirmation boolean alias: --ydefault: false
Skip the confirmation prompt
- --worker-name string Name of the Worker to target (defaults to the name in your local config file)
<details>
<summary>
Global flags
</summary>
- <code>--v</code><code>boolean</code> alias: --version
Show version number - <code>--cwd</code><code>string</code>Run as if Wrangler was started in the specified directory instead of the current working directory - <code>--config</code><code>string</code> alias: --c
Path to Wrangler configuration file - <code>--env</code><code>string</code> alias: --e
Environment to use for operations, and for selecting .env and .dev.vars files - <code>--env-file</code><code>string</code>Path to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files - <code>--install-skills</code><code>boolean</code> default: false
Install Cloudflare skills for detected AI coding agents before running the command - <code>--profile</code><code>string</code>Use a specific auth profile
</details>
preview secret list
List all secrets on a Worker Preview's latest deployment
npmyarnpnpm
npx wrangler preview secret list
yarn wrangler preview secret list
pnpm wrangler preview secret list
--namestringName of the Preview (defaults to current git branch)--jsonbooleandefault: false
Return output as JSON
- --worker-name string Name of the Worker to target (defaults to the name in your local config file)
<details>
<summary>
Global flags
</summary>
- <code>--v</code><code>boolean</code> alias: --version
Show version number - <code>--cwd</code><code>string</code>Run as if Wrangler was started in the specified directory instead of the current working directory - <code>--config</code><code>string</code> alias: --c
Path to Wrangler configuration file - <code>--env</code><code>string</code> alias: --e
Environment to use for operations, and for selecting .env and .dev.vars files - <code>--env-file</code><code>string</code>Path to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files - <code>--install-skills</code><code>boolean</code> default: false
Install Cloudflare skills for detected AI coding agents before running the command - <code>--profile</code><code>string</code>Use a specific auth profile
</details>
preview secret bulk
Upload multiple secrets to a Worker Preview and create a new deployment
npmyarnpnpm
npx wrangler preview secret bulk [FILE]
yarn wrangler preview secret bulk [FILE]
pnpm wrangler preview secret bulk [FILE]
[FILE]stringThe file of key-value pairs to upload, as JSON or .env format--namestringName of the Preview (defaults to current git branch)--messagestringA descriptive message for this Preview deployment--tagstringA tag for this Preview deployment--worker-namestringName of the Worker to target (defaults to the name in your local config file)
<details>
<summary>
Global flags
</summary>
- <code>--v</code><code>boolean</code> alias: --version
Show version number - <code>--cwd</code><code>string</code>Run as if Wrangler was started in the specified directory instead of the current working directory - <code>--config</code><code>string</code> alias: --c
Path to Wrangler configuration file - <code>--env</code><code>string</code> alias: --e
