Skip to content
Cloudflare Docs

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.

How to run Wrangler commands

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.

Terminal window
npx 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:

Terminal window
npm run deploy

docs

Open the Cloudflare developer documentation in your default browser.

Terminal window
npx wrangler docs [SEARCH]
  • --search string

    Enter search terms (e.g. the wrangler command) you want to know more about

  • --yes boolean alias: --y

    Takes you to the docs, even if search fails

Global flags

  • --v boolean alias: --version

    Show version number

  • --cwd string

    Run as if Wrangler was started in the specified directory instead of the current working directory

  • --config string alias: --c

    Path to Wrangler configuration file

  • --env string alias: --e

    Environment to use for operations, and for selecting .env and .dev.vars files

  • --env-file string

    Path 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-bindings

    Experimental: Enable Remote Bindings

  • --experimental-provision boolean aliases: --x-provision

    Experimental: Enable automatic resource provisioning


init

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.
  • --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.

The following global flags work on every command:

  • --help boolean
    • Show help.
  • --config string (not supported by Pages)
  • --cwd string
    • Run as if Wrangler was started in the specified directory instead of the current working directory.

containers

Interact with Cloudflare's Container Platform.

build

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"
  • -p, --push boolean optional
    • Push the built image to Cloudflare's managed registry.
    • Default: false

delete

Delete a Container (application).

wrangler containers delete <CONTAINER_ID> [OPTIONS]
  • CONTAINER_ID string required
    • The ID of the Container to delete.

images

Perform operations on images in your containers registry.

images list

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

images delete

Remove an image from your containers registry.

wrangler containers images delete [IMAGE] [OPTIONS]
  • IMAGE string required
    • Image to delete of the form IMAGE:TAG

info

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

List the Containers in your account.

wrangler containers list [OPTIONS]

push

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"

d1

Interact with Cloudflare's D1 service.

create

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), and enam (Eastern North America).

info

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

List all D1 databases in your account.

wrangler d1 list [OPTIONS]
  • --json boolean optional
    • Return output as JSON rather than a table.

delete

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

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.
  • --local boolean (default: true) optional
    • Execute commands/files against a local database for use with wrangler dev.
  • --remote boolean (default: false) optional
  • --persist-to string optional
    • Specify directory to use for local persistence (for use in combination with --local).
  • --json boolean optional
    • Return output as JSON rather than a table.
  • --preview boolean optional

export

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
  • --remote boolean (default: false) optional
  • --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.
  • --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.

time-travel restore

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.
  • --json boolean optional
    • Return output as JSON rather than a table.

time-travel info

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.
  • --json bboolean optional
    • Return output as JSON rather than a table.

migrations create

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.

migrations list

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).
  • --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).

migrations apply

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).
  • --preview boolean optional

hyperdrive

Manage Hyperdrive database configurations.

hyperdrive create

Create a Hyperdrive config

Terminal window
npx wrangler hyperdrive create [NAME]
  • --name string required

    The name of the Hyperdrive config

  • --connection-string string

    The connection string for the database you want Hyperdrive to connect to - ex: protocol://user:password@host:port/database

  • --origin-host string alias: --host

    The host of the origin database

  • --origin-port number alias: --port

    The port number of the origin database

  • --origin-scheme string alias: --scheme default: postgresql

    The scheme used to connect to the origin database

  • --database string

    The name of the database within the origin database

  • --origin-user string alias: --user

    The username used to connect to the origin database

  • --origin-password string alias: --password

    The password used to connect to the origin database

  • --access-client-id string

    The Client ID of the Access token to use when connecting to the origin database

  • --access-client-secret string

    The Client Secret of the Access token to use when connecting to the origin database

  • --caching-disabled boolean

    Disables the caching of SQL responses

  • --max-age number

    Specifies max duration for which items should persist in the cache, cannot be set when caching is disabled

  • --swr number

    Indicates 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-uuid

    Sets custom CA certificate when connecting to origin database. Must be valid UUID of already uploaded CA certificate.

  • --mtls-certificate-id string alias: --mtls-certificate-uuid

    Sets custom mTLS client certificates when connecting to origin database. Must be valid UUID of already uploaded public/private key certificates.

  • --sslmode string

    Sets CA sslmode for connecting to database.

  • --origin-connection-limit number

    The (soft) maximum number of connections that Hyperdrive may establish to the origin database

Global flags

  • --v boolean alias: --version

    Show version number

  • --cwd string

    Run as if Wrangler was started in the specified directory instead of the current working directory

  • --config string alias: --c

    Path to Wrangler configuration file

  • --env string alias: --e

    Environment to use for operations, and for selecting .env and .dev.vars files

  • --env-file string

    Path 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-bindings

    Experimental: Enable Remote Bindings

  • --experimental-provision boolean aliases: --x-provision

    Experimental: Enable automatic resource provisioning

hyperdrive delete

Delete a Hyperdrive config

Terminal window
npx wrangler hyperdrive delete [ID]
  • --id string required

    The ID of the Hyperdrive config

Global flags

  • --v boolean alias: --version

    Show version number

  • --cwd string

    Run as if Wrangler was started in the specified directory instead of the current working directory

  • --config string alias: --c

    Path to Wrangler configuration file

  • --env string alias: --e

    Environment to use for operations, and for selecting .env and .dev.vars files

  • --env-file string

    Path 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-bindings

    Experimental: Enable Remote Bindings

  • --experimental-provision boolean aliases: --x-provision

    Experimental: Enable automatic resource provisioning

hyperdrive get

Get a Hyperdrive config