Commands
Wrangler offers a number of commands to manage your Cloudflare Workers.
docs
- Open this page in your default browser.init
- Create a new project from a variety of web frameworks and templates.generate
- Create a Wrangler project using an existing Workers template โ.d1
- Interact with D1.vectorize
- Interact with Vectorize indexes.hyperdrive
- Manage your Hyperdrives.deploy
- Deploy your Worker to Cloudflare.dev
- Start a local server for developing your Worker.publish
- Publish your Worker to Cloudflare.delete
- Delete your Worker from Cloudflare.kv namespace
- Manage Workers KV namespaces.kv key
- Manage key-value pairs within a Workers KV namespace.kv bulk
- Manage multiple key-value pairs within a Workers KV namespace in batches.r2 bucket
- Manage Workers R2 buckets.r2 object
- Manage Workers R2 objects.secret
- Manage the secret variables for a Worker.secret bulk
- Manage multiple secret variables for a Worker.workflows
- Manage and configure Workflows.tail
- Start a session to livestream logs from a deployed Worker.pages
- Configure Cloudflare Pages.queues
- Configure Workers Queues.login
- Authorize Wrangler with your Cloudflare account using OAuth.logout
- Remove Wranglerโs authorization for accessing your account.whoami
- Retrieve your user information and test your authentication configuration.versions
- Retrieve details for recent versions.deployments
- Retrieve details for recent deployments.rollback
- Rollback to a recent deployment.dispatch-namespace
- Interact with a dispatch namespace.mtls-certificate
- Manage certificates used for mTLS connections.cert
- Manage certificates used for mTLS and Certificate Authority (CA) chain connections.types
- Generate types from bindings and module rules in configuration.telemetry
- Configure whether Wrangler can collect anonymous usage data.
This page provides a reference for Wrangler commands.
wrangler <COMMAND> <SUBCOMMAND> [PARAMETERS] [OPTIONS]
Since Cloudflare recommends installing Wrangler locally in your project(rather than globally), the way to run Wrangler will depend on your specific setup and package manager.
npx wrangler <COMMAND> <SUBCOMMAND> [PARAMETERS] [OPTIONS]
yarn wrangler <COMMAND> <SUBCOMMAND> [PARAMETERS] [OPTIONS]
pnpm wrangler <COMMAND> <SUBCOMMAND> [PARAMETERS] [OPTIONS]
You can add Wrangler commands that you use often as scripts in your project's package.json
file:
{ ... "scripts": { "deploy": "wrangler deploy", "dev": "wrangler dev" } ...}
You can then run them using your package manager of choice:
npm run deploy
yarn run deploy
pnpm run deploy
Open the Cloudflare developer documentation in your default browser.
wrangler docs [<COMMAND>]
COMMAND
string optional- The Wrangler command you want to learn more about. This opens your default browser to the section of the documentation that describes the command.
The following global flags work on every command:
--help
boolean- Show help.
--config
string (not supported by Pages)- Path to
wrangler.json
orwrangler.toml
configuration file.
- Path to
Create a new project via the create-cloudflare-cli (C3) tool. A variety of web frameworks are available to choose from as well as templates. Dependencies are installed by default, with the option to deploy your project immediately.
wrangler init [<NAME>] [OPTIONS]
NAME
string optional (default: name of working directory)- The name of the Workers project. This is both the directory name and
name
property in the generated Wrangler configuration file.
- The name of the Workers project. This is both the directory name and
--yes
boolean optional- Answer yes to any prompts for new projects.
--from-dash
string optional- Fetch a Worker initialized from the dashboard. This is done by passing the flag and the Worker name.
wrangler init --from-dash <WORKER_NAME>
. - The
--from-dash
command will not automatically sync changes made to the dashboard after the command is used. Therefore, it is recommended that you continue using the CLI.
- Fetch a Worker initialized from the dashboard. This is done by passing the flag and the Worker name.
The following global flags work on every command:
--help
boolean- Show help.
--config
string (not supported by Pages)- Path to
wrangler.json
orwrangler.toml
configuration file.
- Path to
Create a new project using an existing Workers template โ.
wrangler generate [<NAME>] [TEMPLATE]
NAME
string optional (default: name of working directory)- The name of the Workers project. This is both the directory name and
name
property in the generated Wrangler configuration file.
- The name of the Workers project. This is both the directory name and
TEMPLATE
string optional- The URL of a GitHub template, with a default worker-template โ. Browse a list of available templates on the cloudflare/workers-sdk โ repository.
The following global flags work on every command:
--help
boolean- Show help.
--config
string (not supported by Pages)- Path to
wrangler.json
orwrangler.toml
configuration file.
- Path to
Interact with Cloudflare's D1 service.
Creates a new D1 database, and provides the binding and UUID that you will put in your Wrangler file.
wrangler d1 create <DATABASE_NAME> [OPTIONS]
DATABASE_NAME
string required- The name of the new D1 database.
--location
string optional- Provide an optional location hint for your database leader.
- Available options include
weur
(Western Europe),eeur
(Eastern Europe),apac
(Asia Pacific),oc
(Oceania),wnam
(Western North America), andenam
(Eastern North America).
Get information about a D1 database, including the current database size and state.
wrangler d1 info <DATABASE_NAME> [OPTIONS]
DATABASE_NAME
string required- The name of the D1 database to get information about.
--json
boolean optional- Return output as JSON rather than a table.
List all D1 databases in your account.
wrangler d1 list [OPTIONS]
--json
boolean optional- Return output as JSON rather than a table.
Delete a D1 database.
wrangler d1 delete <DATABASE_NAME> [OPTIONS]
DATABASE_NAME
string required- The name of the D1 database to delete.
-y, --skip-confirmation
boolean optional- Skip deletion confirmation prompt.
Execute a query on a D1 database.
wrangler d1 execute <DATABASE_NAME> [OPTIONS]
DATABASE_NAME
string required- The name of the D1 database to execute a query on.
--command
string optional- The SQL query you wish to execute.
--file
string optional- Path to the SQL file you wish to execute.
-y, --yes
boolean optional- Answer
yes
to any prompts.
- Answer
--local
boolean (default: true) optional- Execute commands/files against a local database for use with wrangler dev.
--remote
boolean (default: false) optional- Execute commands/files against a remote D1 database for use with wrangler dev --remote.
--persist-to
string optional- Specify directory to use for local persistence (for use in combination with
--local
).
- Specify directory to use for local persistence (for use in combination with
--json
boolean optional- Return output as JSON rather than a table.
--preview
boolean optional- Execute commands/files against a preview D1 database (as defined by
preview_database_id
in thewrangler.toml / wrangler.json
file).
- Execute commands/files against a preview D1 database (as defined by
--batch-size
number optional- Number of queries to send in a single batch.
Export a D1 database or table's schema and/or content to a .sql
file.
wrangler d1 export <DATABASE_NAME> [OPTIONS]
DATABASE_NAME
string required- The name of the D1 database to export.
--local
boolean (default: true) optional- Export from a local database for use with wrangler dev.
--remote
boolean (default: false) optional- Export from a remote D1 database for use with wrangler dev --remote.
--output
string required- Path to the SQL file for your export.
--table
string optional- The name of the table within a D1 database to export.
--no-data
boolean (default: false) optional- Controls whether export SQL file contains database data. Note that
--no-data=true
is not recommended due to a known wrangler limitation that intreprets the value as false.
- Controls whether export SQL file contains database data. Note that
--no-schema
boolean (default: false) optional- Controls whether export SQL file contains database schema. Note that
--no-schema=true
is not recommended due to a known wrangler limitation that intreprets the value as false.
- Controls whether export SQL file contains database schema. Note that
Restore a database to a specific point-in-time using Time Travel.
wrangler d1 time-travel restore <DATABASE_NAME> [OPTIONS]
DATABASE_NAME
string required- The name of the D1 database to execute a query on.
--bookmark
string optional- A D1 bookmark representing the state of a database at a specific point in time.
--timestamp
string optional- A UNIX timestamp or JavaScript date-time
string
within the last 30 days.
- A UNIX timestamp or JavaScript date-time
--json
boolean optional- Return output as JSON rather than a table.
Inspect the current state of a database for a specific point-in-time using Time Travel.
wrangler d1 time-travel info <DATABASE_NAME> [OPTIONS]
DATABASE_NAME
string required- The name of the D1 database to execute a query on.
--timestamp
string optional- A UNIX timestamp or JavaScript date-time
string
within the last 30 days.
- A UNIX timestamp or JavaScript date-time
--json
bboolean optional- Return output as JSON rather than a table.
Initiate a D1 backup.
wrangler d1 backup create <DATABASE_NAME>
DATABASE_NAME
string required- The name of the D1 database to backup.
List all available backups.
wrangler d1 backup list <DATABASE_NAME>
DATABASE_NAME
string required- The name of the D1 database to list the backups of.
Restore a backup into a D1 database.
wrangler d1 backup restore <DATABASE_NAME> <BACKUP_ID>
DATABASE_NAME
string required- The name of the D1 database to restore the backup into.
BACKUP_ID
string required- The ID of the backup you wish to restore.
Download existing data to your local machine.
wrangler d1 backup download <DATABASE_NAME> <BACKUP_ID>
DATABASE_NAME
string required- The name of the D1 database you wish to download the backup of.
BACKUP_ID
string required- The ID of the backup you wish to download.
--output
string optional- The
.sqlite3
file to write to (defaults to'<DB_NAME>.<SHORT_BACKUP_ID>.sqlite3'
).
- The
Create a new migration.
This will generate a new versioned file inside the migrations
folder. Name your migration file as a description of your change. This will make it easier for you to find your migration in the migrations
folder. An example filename looks like:
0000_create_user_table.sql
The filename will include a version number and the migration name you specify below.
wrangler d1 migrations create <DATABASE_NAME> <MIGRATION_NAME>
DATABASE_NAME
string required- The name of the D1 database you wish to create a migration for.
MIGRATION_NAME
string required- A descriptive name for the migration you wish to create.
View a list of unapplied migration files.
wrangler d1 migrations list <DATABASE_NAME> [OPTIONS]
DATABASE_NAME
string required- The name of the D1 database you wish to list unapplied migrations for.
--local
boolean optional- Show the list of unapplied migration files on your locally persisted D1 database.
--remote
boolean (default: false) optional- Show the list of unapplied migration files on your remote D1 database.
--persist-to
string optional- Specify directory to use for local persistence (for use in combination with
--local
).
- Specify directory to use for local persistence (for use in combination with
--preview
boolean optional- Show the list of unapplied migration files on your preview D1 database (as defined by
preview_database_id
in thewrangler.toml / wrangler.json
file).
- Show the list of unapplied migration files on your preview D1 database (as defined by
Apply any unapplied migrations.
This command will prompt you to confirm the migrations you are about to apply. Confirm that you would like to proceed. After, a backup will be captured.
The progress of each migration will be printed in the console.
When running the apply command in a CI/CD environment or another non-interactive command line, the confirmation step will be skipped, but the backup will still be captured.
If applying a migration results in an error, this migration will be rolled back, and the previous successful migration will remain applied.
wrangler d1 migrations apply <DATABASE_NAME> [OPTIONS]
DATABASE_NAME
string required- The name of the D1 database you wish to apply your migrations on.
--env
string optional- Specify which environment configuration to use for D1 binding
--local
boolean (default: true) optional- Execute any unapplied migrations on your locally persisted D1 database.
--remote
boolean (default: false) optional- Execute any unapplied migrations on your remote D1 database.
--persist-to
string optional- Specify directory to use for local persistence (for use in combination with
--local
).
- Specify directory to use for local persistence (for use in combination with
--preview
boolean optional- Execute any unapplied migrations on your preview D1 database (as defined by
preview_database_id
in thewrangler.toml / wrangler.json
file).
- Execute any unapplied migrations on your preview D1 database (as defined by
--batch-size
number optional- Number of queries to send in a single batch.
Manage Hyperdrive database configurations.
Create a new Hyperdrive configuration.
wrangler hyperdrive create <CONFIG_NAME> [OPTIONS]
CONFIG_NAME
string required- The name of the Hyperdrive configuration to create.
--connection-string
string optional- The database connection string in the form
postgres://user:password@hostname:port/database
.
- The database connection string in the form
--origin-host
string optional- The hostname or IP address Hyperdrive should connect to.
--origin-port
number optional- The database port to connect to.
--origin-scheme
string optional- The scheme used to connect to the origin database, for example, postgresql or postgres.
--database
string optional- The database (name) to connect to. For example, Postgres or defaultdb.
--origin-user
string optional- The username used to authenticate to the database.
--origin-password
string optional- The password used to authenticate to the database.
--access-client-id
string optional- The Client ID of the Access token to use when connecting to the origin database, must be set with a Client Access Secret. Mutually exclusive with
origin-port
.
- The Client ID of the Access token to use when connecting to the origin database, must be set with a Client Access Secret. Mutually exclusive with
--access-client-secret
string optional- The Client Secret of the Access token to use when connecting to the origin database, must be set with a Client Access ID. Mutually exclusive with
origin-port
.
- The Client Secret of the Access token to use when connecting to the origin database, must be set with a Client Access ID. Mutually exclusive with
--caching-disabled
boolean optional- Disables the caching of SQL responses.
--max-age
number optional- Specifies max duration for which items should persist in the cache, cannot be set when caching is disabled.
--swr
number optional- Stale While Revalidate - Indicates the number of seconds cache may serve the response after it becomes stale, cannot be set when caching is disabled.
The following global flags work on every command:
--help
boolean- Show help.
--config
string (not supported by Pages)- Path to
wrangler.json
orwrangler.toml
configuration file.
- Path to
Update an existing Hyperdrive configuration.
wrangler hyperdrive update <ID> [OPTIONS]
ID
string required- The ID of the Hyperdrive configuration to update.
--name
string optional- The new name of the Hyperdrive configuration.
--connection-string
string optional- The database connection string in the form
postgres://user:password@hostname:port/database
.
- The database connection string in the form
--origin-host
string optional- The new database hostname or IP address Hyperdrive should connect to.
--origin-port
string optional- The new database port to connect to.
--origin-scheme
string optional- The scheme used to connect to the origin database, for example, postgresql or postgres.
--database
string optional- The new database (name) to connect to. For example, Postgres or defaultdb.
--origin-user
string optional- The new username used to authenticate to the database.
--origin-password
string optional- The new password used to authenticate to the database.
--access-client-id
string optional- The Client ID of the Access token to use when connecting to the origin database, must be set with a Client Access Secret. Mutually exclusive with
origin-port
.
- The Client ID of the Access token to use when connecting to the origin database, must be set with a Client Access Secret. Mutually exclusive with
--access-client-secret
string optional- The Client Secret of the Access token to use when connecting to the origin database, must be set with a Client Access ID. Mutually exclusive with
origin-port
.
- The Client Secret of the Access token to use when connecting to the origin database, must be set with a Client Access ID. Mutually exclusive with
--caching-disabled
boolean optional- Disables the caching of SQL responses.
--max-age
number optional- Specifies max duration for which items should persist in the cache, cannot be set when caching is disabled.
--swr
number optional- Stale While Revalidate - Indicates the number of seconds cache may serve the response after it becomes stale, cannot be set when caching is disabled.
The following global flags work on every command:
--help
boolean- Show help.
--config
string (not supported by Pages)- Path to
wrangler.json
orwrangler.toml
configuration file.
- Path to
List all Hyperdrive configurations.
wrangler hyperdrive list
The following global flags work on every command:
--help
boolean- Show help.
--config
string (not supported by Pages)- Path to
wrangler.json
orwrangler.toml
configuration file.
- Path to
Delete an existing Hyperdrive configuration.
wrangler hyperdrive delete <ID>
ID
string required- The name of the Hyperdrive configuration to delete.
The following global flags work on every command:
--help
boolean- Show help.
--config
string (not supported by Pages)- Path to
wrangler.json
orwrangler.toml
configuration file.
- Path to
Get an existing Hyperdrive configuration.
wrangler hyperdrive get <ID>
ID
string required- The name of the Hyperdrive configuration to get.
The following global flags work on every command:
--help
boolean- Show help.
--config
string (not supported by Pages)- Path to
wrangler.json
orwrangler.toml
configuration file.
- Path to
Interact with a Vectorize vector database.
Creates a new vector index, and provides the binding and name that you will put in your Wrangler file.
npx wrangler vectorize create <INDEX_NAME> [--dimensions=<NUM_DIMENSIONS>] [--metric=<DISTANCE_METRIC>] [--description=<DESCRIPTION>]
INDEX_NAME
string required- The name of the new index to create. Must be unique for an account and cannot be changed after creation.
--dimensions
number required- The vector dimension width to configure the index for. Cannot be changed after creation.
--metric
string required- The distance metric to use for calculating vector distance. Must be one of
cosine
,euclidean
, ordot-product
.
- The distance metric to use for calculating vector distance. Must be one of
--description
string optional- A description for your index.
--deprecated-v1
boolean optional- Create a legacy Vectorize index. Please note that legacy Vectorize indexes are on a deprecation path.
The following global flags work on every command:
--help
boolean- Show help.
--config
string (not supported by Pages)- Path to
wrangler.json
orwrangler.toml
configuration file.
- Path to
List all Vectorize indexes in your account, including the configured dimensions and distance metric.
npx wrangler vectorize list
--deprecated-v1
boolean optional- List legacy Vectorize indexes. Please note that legacy Vectorize indexes are on a deprecation path.
The following global flags work on every command:
--help
boolean- Show help.
--config
string (not supported by Pages)- Path to
wrangler.json
orwrangler.toml
configuration file.
- Path to
Get details about an individual index, including its configuration.
npx wrangler vectorize get <INDEX_NAME>
INDEX_NAME
string required- The name of the index to fetch details for.
--deprecated-v1
boolean optional- Get a legacy Vectorize index. Please note that legacy Vectorize indexes are on a deprecation path.
The following global flags work on every command:
--help
boolean- Show help.
--config
string (not supported by Pages)- Path to
wrangler.json
orwrangler.toml
configuration file.
- Path to
Get some additional information about an individual index, including the vector count and details about the last processed mutation.
npx wrangler vectorize info <INDEX_NAME>
INDEX_NAME
string required- The name of the index to fetch details for.
The following global flags work on every command:
--help
boolean- Show help.
--config
string (not supported by Pages)- Path to
wrangler.json
orwrangler.toml
configuration file.
- Path to
Delete a Vectorize index.
npx wrangler vectorize delete <INDEX_NAME> [OPTIONS]
INDEX_NAME
string required- The name of the Vectorize index to delete.
--force
boolean optional- Skip confirmation when deleting the index (Note: This is not a recoverable operation).
--deprecated-v1
boolean optional- Delete a legacy Vectorize index. Please note that legacy Vectorize indexes are on a deprecation path.
The following global flags work on every command:
--help
boolean- Show help.
--config
string (not supported by Pages)- Path to
wrangler.json
orwrangler.toml
configuration file.
- Path to
Insert vectors into an index.
npx wrangler vectorize insert <INDEX_NAME> [OPTIONS]
INDEX_NAME
string required- The name of the Vectorize index to upsert vectors in.
--file
string required- A file containing the vectors to insert in newline-delimited JSON (JSON) format.
--batch-size
number optional- The number of vectors to insert at a time (default:
1000
).
- The number of vectors to insert at a time (default:
--deprecated-v1
boolean optional- Insert into a legacy Vectorize index. Please note that legacy Vectorize indexes are on a deprecation path.
The following global flags work on every command:
--help
boolean- Show help.
--config
string (not supported by Pages)- Path to
wrangler.json
orwrangler.toml
configuration file.
- Path to
Upsert vectors into an index. Existing vectors in the index would be overwritten.
npx wrangler vectorize upsert <INDEX_NAME> [OPTIONS]
INDEX_NAME
string required- The name of the Vectorize index to upsert vectors in.
--file
string required- A file containing the vectors to insert in newline-delimited JSON (JSON) format.
--batch-size
number optional- The number of vectors to insert at a time (default:
5000
).
- The number of vectors to insert at a time (default:
The following global flags work on every command:
--help
boolean- Show help.
--config
string (not supported by Pages)- Path to
wrangler.json
orwrangler.toml
configuration file.
- Path to
Query a Vectorize index for similar vectors.
npx wrangler vectorize query <INDEX_NAME> [OPTIONS]
INDEX_NAME
string required- The name of the Vectorize index to query.
--vector
array optional- Vector against which the Vectorize index is queried. Either this or the
vector-id
param must be provided.
- Vector against which the Vectorize index is queried. Either this or the
--vector-id
string optional- Identifier for a vector that is already present in the index against which the index is queried. Either this or the
vector
param must be provided.
- Identifier for a vector that is already present in the index against which the index is queried. Either this or the
--top-k
number optional- The number of vectors to query (default:
5
).
- The number of vectors to query (default:
--return-values
boolean optional- Enable to return vector values in the response (default:
false
).
- Enable to return vector values in the response (default:
--return-metadata
string optional- Enable to return vector metadata in the response. Must be one of
none
,indexed
, orall
(default:none
).
- Enable to return vector metadata in the response. Must be one of
--namespace
string optional- Query response to only include vectors from this namespace.
--filter
string optional- Filter vectors based on this metadata filter. Example:
'{ 'p1': 'abc', 'p2': { '$ne': true }, 'p3': 10, 'p4': false, 'nested.p5': 'abcd' }'
- Filter vectors based on this metadata filter. Example:
The following global flags work on every command:
--help
boolean- Show help.
--config
string (not supported by Pages)- Path to
wrangler.json
orwrangler.toml
configuration file.
- Path to
Fetch vectors from a Vectorize index using the provided ids.
npx wrangler vectorize get-vectors <INDEX_NAME> [OPTIONS]
INDEX_NAME
string required- The name of the Vectorize index from which vectors need to be fetched.
--ids
array required- List of ids for which vectors must be fetched.
The following global flags work on every command:
--help
boolean- Show help.
--config
string (not supported by Pages)- Path to
wrangler.json
orwrangler.toml
configuration file.
- Path to
Delete vectors in a Vectorize index using the provided ids.
npx wrangler vectorize delete-vectors <INDEX_NAME> [OPTIONS]
INDEX_NAME
string required- The name of the Vectorize index from which vectors need to be deleted.
--ids
array required- List of ids corresponding to the vectors that must be deleted.
The following global flags work on every command:
--help
boolean- Show help.
--config
string (not supported by Pages)- Path to
wrangler.json
orwrangler.toml
configuration file.
- Path to
Enable metadata filtering on the specified property.
npx wrangler vectorize create-metadata-index <INDEX_NAME> [OPTIONS]
INDEX_NAME
string required- The name of the Vectorize index for which metadata index needs to be created.
--property-name
string required- Metadata property for which metadata filtering should be enabled.
--type
string required- Data type of the property. Must be one of
string
,number
, orboolean
.
- Data type of the property. Must be one of
The following global flags work on every command:
--help
boolean- Show help.
--config
string (not supported by Pages)- Path to
wrangler.json
orwrangler.toml
configuration file.
- Path to
List metadata properties on which metadata filtering is enabled.
npx wrangler vectorize list-metadata-index <INDEX_NAME> [OPTIONS]
INDEX_NAME
string required- The name of the Vectorize index for which metadata indexes needs to be fetched.
The following global flags work on every command:
--help
boolean- Show help.
--config
string (not supported by Pages)- Path to
wrangler.json
orwrangler.toml
configuration file.
- Path to
Disable metadata filtering on the specified property.
npx wrangler vectorize delete-metadata-index <INDEX_NAME> [OPTIONS]
INDEX_NAME
string required- The name of the Vectorize index for which metadata index needs to be disabled.
--property-name
string required- Metadata property for which metadata filtering should be disabled.
The following global flags work on every command:
--help
boolean- Show help.
--config
string (not supported by Pages)- Path to
wrangler.json
orwrangler.toml
configuration file.
- Path to
Start a local server for developing your Worker.
wrangler dev [<SCRIPT>] [OPTIONS]
SCRIPT
string- The path to an entry point for your Worker. Only required if your
wrangler.toml / wrangler.json
file does not include amain
key (for example,main = "index.js"
).
- The path to an entry point for your Worker. Only required if your
--name
string optional- Name of the Worker.
--no-bundle
boolean (default: false) optional- Skip Wrangler's build steps. Particularly useful when using custom builds. Refer to Bundling โ for more information.
--env
string optional- Perform on a specific environment.
--compatibility-date
string optional- A date in the form yyyy-mm-dd, which will be used to determine which version of the Workers runtime is used.
--compatibility-flags
,--compatibility-flag
string[] optional- Flags to use for compatibility checks.
--latest
boolean (default: true) optional- Use the latest version of the Workers runtime.
--ip
string optional- IP address to listen on, defaults to
localhost
.
- IP address to listen on, defaults to
--port
number optional- Port to listen on.
--inspector-port
number optional- Port for devtools to connect to.
--routes
,--route
string[] optional- Routes to upload.
- For example:
--route example.com/*
.
--host
string optional- Host to forward requests to, defaults to the zone of project.
--local-protocol
'http'|'https' (default: http) optional- Protocol to listen to requests on.
--https-key-path
string optional- Path to a custom certificate key.
--https-cert-path
string optional- Path to a custom certificate.
--local-upstream
string optional- Host to act as origin in local mode, defaults to
dev.host
or route.
- Host to act as origin in local mode, defaults to
--assets
string optional beta- Folder of static assets to be served. Replaces Workers Sites. Visit assets for more information.
--legacy-assets
string optional deprecated, use `--assets`- Folder of static assets to be served.
--site
string optional deprecated, use `--assets`- Folder of static assets for Workers Sites.
--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.
- Array of
--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.
- Array of
--upstream-protocol
'http'|'https' (default: https) optional- Protocol to forward requests to host on.
--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 thegit_hash
andtest
variables available in your Worker'senv
. - This flag is an alternative to defining
vars
in yourwrangler.toml / wrangler.json
file. If defined in both places, this flag's values will be used.
- Array of
--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 ofGIT_HASH
with the actual value at build time. - This flag is an alternative to defining
define
in yourwrangler.toml / wrangler.json
file. If defined in both places, this flag's values will be used.
- Array of
--tsconfig
string optional- Path to a custom
tsconfig.json
file.
- Path to a custom
--minify
boolean optional- Minify the Worker.
--node-compat
boolean optional- Enable Node.js compatibility.
--persist-to
string optional- Specify directory to use for local persistence.
--remote
boolean (default: false) optional- Develop against remote resources and data stored on Cloudflare's network.
--test-scheduled
boolean (default: false) optional- Exposes a
/__scheduled
fetch route which will trigger a scheduled event (Cron Trigger) for testing during development. To simulate different cron patterns, acron
query parameter can be passed in:/__scheduled?cron=*+*+*+*+*
.
- Exposes a
--log-level
'debug'|'info'|'log'|'warn'|'error|'none' (default: log) optional- Specify Wrangler's logging level.
--show-interactive-dev-session
boolean (default: true if the terminal supports interactivity) optional- Show the interactive dev session.
--alias
Array<string>
- Specify modules to alias using module aliasing.
The following global flags work on every command:
--help
boolean- Show help.
--config
string (not supported by Pages)- Path to
wrangler.json
orwrangler.toml
configuration file.
- Path to
wrangler dev
is a way to locally test your Worker while developing. With wrangler dev
running, send HTTP requests to localhost:8787
and your Worker should execute as expected. You will also see console.log
messages and exceptions appearing in your terminal.
Deploy your Worker to Cloudflare.
wrangler deploy [<SCRIPT>] [OPTIONS]
SCRIPT
string- The path to an entry point for your Worker. Only required if your
wrangler.toml / wrangler.json
file does not include amain
key (for example,main = "index.js"
).
- The path to an entry point for your Worker. Only required if your
--name
string optional- Name of the Worker.
--no-bundle
boolean (default: false) optional- Skip Wrangler's build steps. Particularly useful when using custom builds. Refer to Bundling โ for more information.
--env
string optional- Perform on a specific environment.
--outdir
string optional- Path to directory where Wrangler will write the bundled Worker files.
--compatibility-date
string optional- A date in the form yyyy-mm-dd, which will be used to determine which version of the Workers runtime is used.
--compatibility-flags
,--compatibility-flag
string[] optional- Flags to use for compatibility checks.
--latest
boolean (default: true) optional- Use the latest version of the Workers runtime.
--assets
string optional beta- Folder of static assets to be served. Replaces Workers Sites. Visit assets for more information.
--legacy-assets
string optional deprecated, use `--assets`- Folder of static assets to be served.
--site
string optional deprecated, use `--assets`- Folder of static assets for Workers Sites.
--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.
- Array of
--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.
- Array of
--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 thegit_hash
andtest
variables available in your Worker'senv
. - This flag is an alternative to defining
vars
in yourwrangler.toml / wrangler.json
file. If defined in both places, this flag's values will be used.
- Array of
--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 ofGIT_HASH
with the actual value at build time. - This flag is an alternative to defining
define
in yourwrangler.toml / wrangler.json
file. If defined in both places, this flag's values will be used.
- Array of
--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/*
.
--tsconfig
string optional- Path to a custom
tsconfig.json
file.
- Path to a custom
--minify
boolean optional- Minify the bundled Worker before deploying.
--node-compat
boolean optional- Enable node.js compatibility.
--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 ofnpx 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.
- Compile a project without actually deploying to live servers. Combined with
--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 or bindings in the Cloudflare dashboard, Wrangler will override them the next time you deploy. If you want to disable this behaviour set
keep-vars
totrue
.
--dispatch-namespace
string optional- Specify the Workers for Platforms dispatch namespace to upload this Worker to.
The following global flags work on every command:
--help
boolean- Show help.
--config
string (not supported by Pages)- Path to
wrangler.json
orwrangler.toml
configuration file.
- Path to
Publish your Worker to Cloudflare.
wrangler publish [OPTIONS]
Delete your Worker and all associated Cloudflare developer platform resources.
wrangler delete [<SCRIPT>] [OPTIONS]
SCRIPT
string- The path to an entry point for your Worker. Only required if your
wrangler.toml / wrangler.json
file does not include amain
key (for example,main = "index.js"
).
- The path to an entry point for your Worker. Only required if your
--name
string optional- Name of the Worker.
--env
string optional- Perform on a specific environment.
--dry-run
boolean (default: false) optional- Do not actually delete the Worker. This is useful for testing the output of
wrangler delete
.
- Do not actually delete the Worker. This is useful for testing the output of
The following global flags work on every command:
--help
boolean- Show help.
--config
string (not supported by Pages)- Path to
wrangler.json
orwrangler.toml
configuration file.
- Path to
Manage Workers KV namespaces.
Create a new namespace.
wrangler kv namespace create <NAMESPACE> [OPTIONS]
NAMESPACE
string required- The name of the new namespace.
--env
string optional- Perform on a specific environment.
--preview
boolean optional- Interact with a preview namespace (the
preview_id
value).
- Interact with a preview namespace (the
The following global flags work on every command:
--help
boolean- Show help.
--config
string (not supported by Pages)- Path to
wrangler.json
orwrangler.toml
configuration file.
- Path to
The following is an example of using the create
command to create a KV namespace called MY_KV
.
npx wrangler kv namespace create "MY_KV"
๐ Creating namespace with title "worker-MY_KV"โจ Success!Add the following to your configuration file in your kv_namespaces array:kv_namespaces = [ { binding = "MY_KV", id = "e29b263ab50e42ce9b637fa8370175e8" }]
The following is an example of using the create
command to create a preview KV namespace called MY_KV
.
npx wrangler kv namespace create "MY_KV" --preview
๐ Creating namespace with title "my-site-MY_KV_preview"โจ Success!Add the following to your configuration file in your kv_namespaces array:kv_namespaces = [ { binding = "MY_KV", preview_id = "15137f8edf6c09742227e99b08aaf273" }]
List all KV namespaces associated with the current account ID.
wrangler kv namespace list
The following global flags work on every command:
--help
boolean- Show help.
--config
string (not supported by Pages)- Path to
wrangler.json
orwrangler.toml
configuration file.
- Path to
The following is an example that passes the Wrangler command through the jq
command:
npx wrangler kv namespace list | jq "."
[ { "id": "06779da6940b431db6e566b4846d64db", "title": "TEST_NAMESPACE" }, { "id": "32ac1b3c2ed34ed3b397268817dea9ea", "title": "STATIC_CONTENT" }]
Delete a given namespace.
wrangler kv namespace delete {--binding=<BINDING>|--namespace-id=<NAMESPACE_ID>} [OPTIONS]
--binding
string- The binding name of the namespace, as stored in the Wrangler file, to delete.
--namespace-id
string- The ID of the namespace to delete.
--env
string optional- Perform on a specific environment.
--preview
boolean optional- Interact with a preview namespace instead of production.
The following global flags work on every command:
--help
boolean- Show help.
--config
string (not supported by Pages)- Path to
wrangler.json
orwrangler.toml
configuration file.
- Path to
The following is an example of deleting a KV namespace called MY_KV.
npx wrangler kv namespace delete --binding=MY_KV
Are you sure you want to delete namespace f7b02e7fc70443149ac906dd81ec1791? [y/n]yesDeleting namespace f7b02e7fc70443149ac906dd81ec1791Deleted namespace f7b02e7fc70443149ac906dd81ec1791
The following is an example of deleting a preview KV namespace called MY_KV
.
npx wrangler kv namespace delete --binding=MY_KV --preview
Are you sure you want to delete namespace 15137f8edf6c09742227e99b08aaf273? [y/n]yesDeleting namespace 15137f8edf6c09742227e99b08aaf273Deleted namespace 15137f8edf6c09742227e99b08aaf273
Manage key-value pairs within a Workers KV namespace.
Write a single key-value pair to a particular namespace.
wrangler kv key put <KEY> {<VALUE>|--path=<PATH>} {--binding=<BINDING>|--namespace-id=<NAMESPACE_ID>} [OPTIONS]
KEY
string required- The key to write to.
VALUE
string optional- The value to write.
--path
optional- When defined, the value is loaded from the file at
--path
rather than reading it from theVALUE
argument. This is ideal for security-sensitive operations because it avoids saving keys and values into your terminal history.
- When defined, the value is loaded from the file at
--binding
string- The binding name of the namespace, as stored in the Wrangler file, to write to.
--namespace-id
string- The ID of the namespace to write to.