Pages
Configure Cloudflare Pages using Wrangler.
Develop your full-stack Pages application locally
npx wrangler pages dev [DIRECTORY] [COMMAND]pnpm wrangler pages dev [DIRECTORY] [COMMAND]yarn wrangler pages dev [DIRECTORY] [COMMAND]-
[DIRECTORY]stringThe directory of static assets to serve
-
[COMMAND]stringThe proxy command to run [deprecated]
-
--compatibility-datestringDate to use for compatibility checks
-
--compatibility-flagsstring alias: --compatibility-flagFlags to use for compatibility checks
-
--ipstringThe IP address to listen on
-
--portnumberThe port to listen on (serve from)
-
--inspector-portnumberPort for devtools to connect to
-
--proxynumberThe port to proxy (where the static assets are served)
-
--script-pathstringThe location of the single Worker script if not using functions [default: _worker.js]
-
--no-bundlebooleanWhether to run bundling on
_worker.js -
--bindingarray alias: --bBind variable/secret (KEY=VALUE)
-
--kvarray alias: --kKV namespace to bind (--kv KV_BINDING)
-
--d1arrayD1 database to bind (--d1 D1_BINDING)
-
--doarray alias: --oDurable Object to bind (--do DO_BINDING=CLASS_NAME@SCRIPT_NAME)
-
--r2arrayR2 bucket to bind (--r2 R2_BINDING)
-
--aistringAI to bind (--ai AI_BINDING)
-
--version-metadatastringWorker Version metadata (--version-metadata VERSION_METADATA_BINDING)
-
--servicearrayService to bind (--service SERVICE=SCRIPT_NAME)
-
--live-reloadboolean default: falseAuto reload HTML pages when change is detected
-
--local-protocol"http" | "https"Protocol to listen to requests on, defaults to http.
-
--https-key-pathstringPath to a custom certificate key
-
--https-cert-pathstringPath to a custom certificate
-
--persist-tostringSpecify directory to use for local persistence (defaults to .wrangler/state)
-
--log-level"debug" | "info" | "log" | "warn" | "error" | "none"Specify logging level
-
--show-interactive-dev-sessionbooleanShow interactive dev session (defaults to true if the terminal supports interactivity)
Global flags
-
--vboolean alias: --versionShow version number
-
--cwdstringRun as if Wrangler was started in the specified directory instead of the current working directory
-
--configstring alias: --cPath to Wrangler configuration file
-
--envstring alias: --eEnvironment to use for operations, and for selecting .env and .dev.vars files
-
--env-filestringPath to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files
-
--experimental-provisionboolean aliases: --x-provision default: trueExperimental: Enable automatic resource provisioning
-
--experimental-auto-createboolean alias: --x-auto-create default: trueAutomatically provision draft bindings with new resources
Compile a folder of Pages Functions into a single Worker
npx wrangler pages functions build [DIRECTORY]pnpm wrangler pages functions build [DIRECTORY]yarn wrangler pages functions build [DIRECTORY]-
[DIRECTORY]string default: functionsThe directory of Pages Functions
-
--outfilestringThe location of the output Worker script
-
--outdirstringOutput directory for the bundled Worker
-
--output-config-pathstringThe location for the output config file
-
--build-metadata-pathstringThe location for the build metadata file
-
--project-directorystringThe location of the Pages project
-
--output-routes-pathstringThe location for the output _routes.json file
-
--minifyboolean default: falseMinify the output Worker script
-
--sourcemapboolean default: falseGenerate a sourcemap for the output Worker script
-
--fallback-servicestring default: ASSETSThe service to fallback to at the end of the
nextchain. Setting to '' will fallback to the globalfetch. -
--watchboolean default: falseWatch for changes to the functions and automatically rebuild the Worker script
-
--pluginboolean default: falseBuild a plugin rather than a Worker script
-
--build-output-directorystringThe directory to output static assets to
-
--compatibility-datestringDate to use for compatibility checks
-
--compatibility-flagsstring alias: --compatibility-flagFlags to use for compatibility checks
-
--externalstringA list of module imports to exclude from bundling
-
--metafilestringPath to output build metadata from esbuild. If flag is used without a path, defaults to 'bundle-meta.json' inside the directory specified by --outdir.
Global flags
-
--vboolean alias: --versionShow version number
-
--cwdstringRun as if Wrangler was started in the specified directory instead of the current working directory
-
--configstring alias: --cPath to Wrangler configuration file
-
--envstring alias: --eEnvironment to use for operations, and for selecting .env and .dev.vars files
-
--env-filestringPath to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files
-
--experimental-provisionboolean aliases: --x-provision default: trueExperimental: Enable automatic resource provisioning
-
--experimental-auto-createboolean alias: --x-auto-create default: trueAutomatically provision draft bindings with new resources
List your Cloudflare Pages projects
npx wrangler pages project listpnpm wrangler pages project listyarn wrangler pages project listGlobal flags
-
--vboolean alias: --versionShow version number
-
--cwdstringRun as if Wrangler was started in the specified directory instead of the current working directory
-
--configstring alias: --cPath to Wrangler configuration file
-
--envstring alias: --eEnvironment to use for operations, and for selecting .env and .dev.vars files
-
--env-filestringPath to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files
-
--experimental-provisionboolean aliases: --x-provision default: trueExperimental: Enable automatic resource provisioning
-
--experimental-auto-createboolean alias: --x-auto-create default: trueAutomatically provision draft bindings with new resources
Create a new Cloudflare Pages project
npx wrangler pages project create [PROJECT-NAME]pnpm wrangler pages project create [PROJECT-NAME]yarn wrangler pages project create [PROJECT-NAME]-
[PROJECT-NAME]string requiredThe name of your Pages project
-
--production-branchstringThe name of the production branch of your project
-
--compatibility-flagsstring alias: --compatibility-flagFlags to use for compatibility checks
-
--compatibility-datestringDate to use for compatibility checks
Global flags
-
--vboolean alias: --versionShow version number
-
--cwdstringRun as if Wrangler was started in the specified directory instead of the current working directory
-
--configstring alias: --cPath to Wrangler configuration file
-
--envstring alias: --eEnvironment to use for operations, and for selecting .env and .dev.vars files
-
--env-filestringPath to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files
-
--experimental-provisionboolean aliases: --x-provision default: trueExperimental: Enable automatic resource provisioning
-
--experimental-auto-createboolean alias: --x-auto-create default: trueAutomatically provision draft bindings with new resources
Delete a Cloudflare Pages project
npx wrangler pages project delete [PROJECT-NAME]pnpm wrangler pages project delete [PROJECT-NAME]yarn wrangler pages project delete [PROJECT-NAME]-
[PROJECT-NAME]string requiredThe name of your Pages project
-
--yesboolean alias: --yAnswer "yes" to confirm project deletion
Global flags
-
--vboolean alias: --versionShow version number
-
--cwdstringRun as if Wrangler was started in the specified directory instead of the current working directory
-
--configstring alias: --cPath to Wrangler configuration file
-
--envstring alias: --eEnvironment to use for operations, and for selecting .env and .dev.vars files
-
--env-filestringPath to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files
-
--experimental-provisionboolean aliases: --x-provision default: trueExperimental: Enable automatic resource provisioning
-
--experimental-auto-createboolean alias: --x-auto-create default: trueAutomatically provision draft bindings with new resources
List deployments in your Cloudflare Pages project
npx wrangler pages deployment listpnpm wrangler pages deployment listyarn wrangler pages deployment list-
--project-namestringThe name of the project you would like to list deployments for
-
--environmentstringEnvironment type to list deployments for
-
--jsonboolean default: falseReturn output as clean JSON
Global flags
-
--vboolean alias: --versionShow version number
-
--cwdstringRun as if Wrangler was started in the specified directory instead of the current working directory
-
--configstring alias: --cPath to Wrangler configuration file
-
--envstring alias: --eEnvironment to use for operations, and for selecting .env and .dev.vars files
-
--env-filestringPath to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files
-
--experimental-provisionboolean aliases: --x-provision default: trueExperimental: Enable automatic resource provisioning
-
--experimental-auto-createboolean alias: --x-auto-create default: trueAutomatically provision draft bindings with new resources
Start a tailing session for a project's deployment and livestream logs from your Functions
npx wrangler pages deployment tail [DEPLOYMENT]pnpm wrangler pages deployment tail [DEPLOYMENT]yarn wrangler pages deployment tail [DEPLOYMENT]-
[DEPLOYMENT]string(Optional) ID or URL of the deployment to tail. Specify by environment if deployment ID is unknown.
-
--project-namestringThe name of the project you would like to tail
-
--environmentstring default: productionWhen not providing a specific deployment ID, specifying environment will grab the latest production or preview deployment
-
--formatstringThe format of log entries
-
--status"ok" | "error" | "canceled"Filter by invocation status
-
--headerstringFilter by HTTP header
-
--methodstringFilter by HTTP method
-
--searchstringFilter by a text match in console.log messages
-
--sampling-ratenumberAdds a percentage of requests to log sampling rate
-
--ipstringFilter by the IP address the request originates from. Use "self" to filter for your own IP
Global flags
-
--vboolean alias: --versionShow version number
-
--cwdstringRun as if Wrangler was started in the specified directory instead of the current working directory
-
--configstring alias: --cPath to Wrangler configuration file
-
--envstring alias: --eEnvironment to use for operations, and for selecting .env and .dev.vars files
-
--env-filestringPath to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files
-
--experimental-provisionboolean aliases: --x-provision default: trueExperimental: Enable automatic resource provisioning
-
--experimental-auto-createboolean alias: --x-auto-create default: trueAutomatically provision draft bindings with new resources
Deploy a directory of static assets as a Pages deployment
npx wrangler pages deploy [DIRECTORY]pnpm wrangler pages deploy [DIRECTORY]yarn wrangler pages deploy [DIRECTORY]-
[DIRECTORY]stringThe directory of static files to upload
-
--project-namestringThe name of the project you want to deploy to
-
--branchstringThe name of the branch you want to deploy to
-
--commit-hashstringThe SHA to attach to this deployment
-
--commit-messagestringThe commit message to attach to this deployment
-
--commit-dirtybooleanWhether or not the workspace should be considered dirty for this deployment
-
--skip-cachingbooleanSkip asset caching which speeds up builds
-
--no-bundlebooleanWhether to run bundling on
_worker.jsbefore deploying -
--upload-source-mapsboolean default: falseWhether to upload any server-side sourcemaps with this deployment
Global flags
-
--vboolean alias: --versionShow version number
-
--cwdstringRun as if Wrangler was started in the specified directory instead of the current working directory
-
--configstring alias: --cPath to Wrangler configuration file
-
--envstring alias: --eEnvironment to use for operations, and for selecting .env and .dev.vars files
-
--env-filestringPath to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files
-
--experimental-provisionboolean aliases: --x-provision default: trueExperimental: Enable automatic resource provisioning
-
--experimental-auto-createboolean alias: --x-auto-create default: trueAutomatically provision draft bindings with new resources
Create or update a secret variable for a Pages project
npx wrangler pages secret put [KEY]pnpm wrangler pages secret put [KEY]yarn wrangler pages secret put [KEY]-
[KEY]string requiredThe variable name to be accessible in the Pages project
-
--project-namestring aliases: --projectThe name of your Pages project
Global flags
-
--vboolean alias: --versionShow version number
-
--cwdstringRun as if Wrangler was started in the specified directory instead of the current working directory
-
--configstring alias: --cPath to Wrangler configuration file
-
--envstring alias: --eEnvironment to use for operations, and for selecting .env and .dev.vars files
-
--env-filestringPath to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files
-
--experimental-provisionboolean aliases: --x-provision default: trueExperimental: Enable automatic resource provisioning
-
--experimental-auto-createboolean alias: --x-auto-create default: trueAutomatically provision draft bindings with new resources
Bulk upload secrets for a Pages project
npx wrangler pages secret bulk [FILE]pnpm wrangler pages secret bulk [FILE]yarn wrangler pages secret bulk [FILE]-
[FILE]stringThe file of key-value pairs to upload, as JSON in form {"key": value, ...} or .dev.vars file in the form KEY=VALUE
-
--project-namestring aliases: --projectThe name of your Pages project
Global flags
-
--vboolean alias: --versionShow version number
-
--cwdstringRun as if Wrangler was started in the specified directory instead of the current working directory
-
--configstring alias: --cPath to Wrangler configuration file
-
--envstring alias: --eEnvironment to use for operations, and for selecting .env and .dev.vars files
-
--env-filestringPath to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files
-
--experimental-provisionboolean aliases: --x-provision default: trueExperimental: Enable automatic resource provisioning
-
--experimental-auto-createboolean alias: --x-auto-create default: trueAutomatically provision draft bindings with new resources
Delete a secret variable from a Pages project
npx wrangler pages secret delete [KEY]pnpm wrangler pages secret delete [KEY]yarn wrangler pages secret delete [KEY]-
[KEY]string requiredThe variable name to be accessible in the Pages project
-
--project-namestring aliases: --projectThe name of your Pages project
Global flags
-
--vboolean alias: --versionShow version number
-
--cwdstringRun as if Wrangler was started in the specified directory instead of the current working directory
-
--configstring alias: --cPath to Wrangler configuration file
-
--envstring alias: --eEnvironment to use for operations, and for selecting .env and .dev.vars files
-
--env-filestringPath to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files
-
--experimental-provisionboolean aliases: --x-provision default: trueExperimental: Enable automatic resource provisioning
-
--experimental-auto-createboolean alias: --x-auto-create default: trueAutomatically provision draft bindings with new resources
List all secrets for a Pages project
npx wrangler pages secret listpnpm wrangler pages secret listyarn wrangler pages secret list-
--project-namestring aliases: --projectThe name of your Pages project
Global flags
-
--vboolean alias: --versionShow version number
-
--cwdstringRun as if Wrangler was started in the specified directory instead of the current working directory
-
--configstring alias: --cPath to Wrangler configuration file
-
--envstring alias: --eEnvironment to use for operations, and for selecting .env and .dev.vars files
-
--env-filestringPath to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files
-
--experimental-provisionboolean aliases: --x-provision default: trueExperimental: Enable automatic resource provisioning
-
--experimental-auto-createboolean alias: --x-auto-create default: trueAutomatically provision draft bindings with new resources
Experimental
Download your Pages project config as a Wrangler configuration file
npx wrangler pages download config [PROJECTNAME]pnpm wrangler pages download config [PROJECTNAME]yarn wrangler pages download config [PROJECTNAME]-
[PROJECTNAME]stringThe Pages project to download
-
--forcebooleanOverwrite an existing Wrangler configuration file without prompting
Global flags
-
--vboolean alias: --versionShow version number
-
--cwdstringRun as if Wrangler was started in the specified directory instead of the current working directory
-
--configstring alias: --cPath to Wrangler configuration file
-
--envstring alias: --eEnvironment to use for operations, and for selecting .env and .dev.vars files
-
--env-filestringPath to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files
-
--experimental-provisionboolean aliases: --x-provision default: trueExperimental: Enable automatic resource provisioning
-
--experimental-auto-createboolean alias: --x-auto-create default: trueAutomatically provision draft bindings with new resources