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.containers
- Interact with Containers.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.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.secrets-store secret
- Manage account secrets within a secrets store.secrets-store store
- Manage your store within secrets store.workflows
- Manage and configure Workflows.tail
- Start a session to livestream logs from a deployed Worker.pages
- Configure Cloudflare Pages.pipelines
- Configure Cloudflare Pipelines.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.check
- Validate your Worker.
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.
npx wrangler docs [SEARCH]
pnpm wrangler docs [SEARCH]
yarn wrangler docs [SEARCH]
-
--search
stringEnter search terms (e.g. the wrangler command) you want to know more about
-
--yes
boolean alias: --yTakes you to the docs, even if search fails
Global flags
-
--v
boolean alias: --versionShow version number
-
--cwd
stringRun as if Wrangler was started in the specified directory instead of the current working directory
-
--config
string alias: --cPath to Wrangler configuration file
-
--env
string alias: --eEnvironment to use for operations, and for selecting .env and .dev.vars files
-
--env-file
stringPath to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files
-
--experimental-remote-bindings
boolean aliases: --x-remote-bindingsExperimental: Enable Remote Bindings
-
--experimental-provision
boolean aliases: --x-provisionExperimental: Enable automatic resource provisioning
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.
- 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 your Wrangler configuration file.
--cwd
string- Run as if Wrangler was started in the specified directory instead of the current working directory.
Interact with Cloudflare's Container Platform.
Build a Container image from a Dockerfile.
wrangler containers build [PATH] [OPTIONS]
PATH
string optional- Path for the directory containing the Dockerfile to build.
-t, --tag
string required- Name and optionally a tag (format: "name:tag").
--path-to-docker
string optional- Path to your docker binary if it's not on
$PATH
. - Default: "docker"
- Path to your docker binary if it's not on
-p, --push
boolean optional- Push the built image to Cloudflare's managed registry.
- Default: false
Delete a Container (application).
wrangler containers delete <CONTAINER_ID> [OPTIONS]
CONTAINER_ID
string required- The ID of the Container to delete.
Perform operations on images in your containers registry.
List images in your containers registry.
wrangler containers images list [OPTIONS]
--filter
string optional- Regex to filter results.
--json
boolean optional- Return output as clean JSON.
- Default: false
Remove an image from your containers registry.
wrangler containers images delete [IMAGE] [OPTIONS]
IMAGE
string required- Image to delete of the form
IMAGE:TAG
- Image to delete of the form
Get information about a specific Container, including top-level details and a list of instances.
wrangler containers info <CONTAINER_ID> [OPTIONS]
CONTAINER_ID
string required- The ID of the Container to get information about.
List the Containers in your account.
wrangler containers list [OPTIONS]
Push a tagged image to a Cloudflare managed registry, which is automatically integrated with your account.
wrangler containers push [TAG] [OPTIONS]
TAG
string required- The name and tag of the container image to push.
--path-to-docker
string optional- Path to your docker binary if it's not on
$PATH
. - Default: "docker"
- Path to your docker binary if it's not on
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 the Wrangler configuration file).
- Execute commands/files against a preview D1 database (as defined by
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.
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 the Wrangler configuration 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 the Wrangler configuration file).
- Execute any unapplied migrations on your preview D1 database (as defined by
Manage Hyperdrive database configurations.
Create a Hyperdrive config
npx wrangler hyperdrive create [NAME]
pnpm wrangler hyperdrive create [NAME]
yarn wrangler hyperdrive create [NAME]
-
--name
string requiredThe name of the Hyperdrive config
-
--connection-string
stringThe connection string for the database you want Hyperdrive to connect to - ex: protocol://user:password@host:port/database
-
--origin-host
string alias: --hostThe host of the origin database
-
--origin-port
number alias: --portThe port number of the origin database
-
--origin-scheme
string alias: --scheme default: postgresqlThe scheme used to connect to the origin database
-
--database
stringThe name of the database within the origin database
-
--origin-user
string alias: --userThe username used to connect to the origin database
-
--origin-password
string alias: --passwordThe password used to connect to the origin database
-
--access-client-id
stringThe Client ID of the Access token to use when connecting to the origin database
-
--access-client-secret
stringThe Client Secret of the Access token to use when connecting to the origin database
-
--caching-disabled
booleanDisables the caching of SQL responses
-
--max-age
numberSpecifies max duration for which items should persist in the cache, cannot be set when caching is disabled
-
--swr
numberIndicates the number of seconds cache may serve the response after it becomes stale, cannot be set when caching is disabled
-
--ca-certificate-id
string alias: --ca-certificate-uuidSets custom CA certificate when connecting to origin database. Must be valid UUID of already uploaded CA certificate.
-
--mtls-certificate-id
string alias: --mtls-certificate-uuidSets custom mTLS client certificates when connecting to origin database. Must be valid UUID of already uploaded public/private key certificates.
-
--sslmode
stringSets CA sslmode for connecting to database.
-
--origin-connection-limit
numberThe (soft) maximum number of connections that Hyperdrive may establish to the origin database
Global flags
-
--v
boolean alias: --versionShow version number
-
--cwd
stringRun as if Wrangler was started in the specified directory instead of the current working directory
-
--config
string alias: --cPath to Wrangler configuration file
-
--env
string alias: --eEnvironment to use for operations, and for selecting .env and .dev.vars files
-
--env-file
stringPath to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files
-
--experimental-remote-bindings
boolean aliases: --x-remote-bindingsExperimental: Enable Remote Bindings
-
--experimental-provision
boolean aliases: --x-provisionExperimental: Enable automatic resource provisioning
Delete a Hyperdrive config
npx wrangler hyperdrive delete [ID]
pnpm wrangler hyperdrive delete [ID]
yarn wrangler hyperdrive delete [ID]
-
--id
string requiredThe ID of the Hyperdrive config
Global flags
-
--v
boolean alias: --versionShow version number
-
--cwd
stringRun as if Wrangler was started in the specified directory instead of the current working directory
-
--config
string alias: --cPath to Wrangler configuration file
-
--env
string alias: --eEnvironment to use for operations, and for selecting .env and .dev.vars files
-
--env-file
stringPath to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files
-
--experimental-remote-bindings
boolean aliases: --x-remote-bindingsExperimental: Enable Remote Bindings
-
--experimental-provision
boolean aliases: --x-provisionExperimental: Enable automatic resource provisioning
Get a Hyperdrive config
npx wrangler hyperdrive get [ID]
pnpm wrangler hyperdrive get [ID]
yarn wrangler hyperdrive get [ID]
-
--id
string requiredThe ID of the Hyperdrive config
Global flags
-
--v
boolean alias: --versionShow version number
-
--cwd
stringRun as if Wrangler was started in the specified directory instead of the current working directory
-
--config
string alias: --cPath to Wrangler configuration file
-
--env
string alias: --eEnvironment to use for operations, and for selecting .env and .dev.vars files
-
--env-file
stringPath to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files
-
--experimental-remote-bindings
boolean aliases: --x-remote-bindingsExperimental: Enable Remote Bindings
-
--experimental-provision
boolean aliases: --x-provisionExperimental: Enable automatic resource provisioning
List Hyperdrive configs
npx wrangler hyperdrive list
pnpm wrangler hyperdrive list
yarn wrangler hyperdrive list
Global flags
-
--v
boolean alias: --versionShow version number
-
--cwd
stringRun as if Wrangler was started in the specified directory instead of the current working directory
-
--config
string alias: --cPath to Wrangler configuration file
-
--env
string alias: --eEnvironment to use for operations, and for selecting .env and .dev.vars files
-
--env-file
stringPath to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files
-
--experimental-remote-bindings
boolean aliases: --x-remote-bindingsExperimental: Enable Remote Bindings
-
--experimental-provision
boolean aliases: --x-provisionExperimental: Enable automatic resource provisioning
Update a Hyperdrive config
npx wrangler hyperdrive update [ID]
pnpm wrangler hyperdrive update [ID]
yarn wrangler hyperdrive update [ID]
-
--id
string requiredThe ID of the Hyperdrive config
-
--name
stringGive your config a new name
-
--connection-string
stringThe connection string for the database you want Hyperdrive to connect to - ex: protocol://user:password@host:port/database
-
--origin-host
string alias: --hostThe host of the origin database
-
--origin-port
number alias: --portThe port number of the origin database
-
--origin-scheme
string alias: --schemeThe scheme used to connect to the origin database
-
--database
stringThe name of the database within the origin database
-
--origin-user
string alias: --userThe username used to connect to the origin database
-
--origin-password
string alias: --passwordThe password used to connect to the origin database
-
--access-client-id
stringThe Client ID of the Access token to use when connecting to the origin database
-
--access-client-secret
stringThe Client Secret of the Access token to use when connecting to the origin database
-
--caching-disabled
booleanDisables the caching of SQL responses
-
--max-age
numberSpecifies max duration for which items should persist in the cache, cannot be set when caching is disabled
-
--swr
numberIndicates the number of seconds cache may serve the response after it becomes stale, cannot be set when caching is disabled
-
--ca-certificate-id
string alias: --ca-certificate-uuidSets custom CA certificate when connecting to origin database. Must be valid UUID of already uploaded CA certificate.
-
--mtls-certificate-id
string alias: --mtls-certificate-uuidSets custom mTLS client certificates when connecting to origin database. Must be valid UUID of already uploaded public/private key certificates.
-
--sslmode
stringSets CA sslmode for connecting to database.
-
--origin-connection-limit
numberThe (soft) maximum number of connections that Hyperdrive may establish to the origin database
Global flags
-
--v
boolean alias: --versionShow version number
-
--cwd
stringRun as if Wrangler was started in the specified directory instead of the current working directory
-
--config
string alias: --cPath to Wrangler configuration file
-
--env
string alias: --eEnvironment to use for operations, and for selecting .env and .dev.vars files
-
--env-file
stringPath to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files
-
--experimental-remote-bindings
boolean aliases: --x-remote-bindingsExperimental: Enable Remote Bindings
-
--experimental-provision
boolean aliases: --x-provisionExperimental: Enable automatic resource provisioning
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.
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