wrangler pages dev injects Pages environment variables
Introduced 2026-02-12 · score 0.97
HOW TO USE IT
When running a Pages project locally, use `wrangler pages dev` and check the startup bindings table to verify the Pages environment, branch, and commit values.
npx wrangler pages dev [<DIRECTORY>]npx wrangler pages dev --binding=CF_PAGES_BRANCH=<branch>WHY THIS HELPS
Run a Pages project locally and verify that its framework detects the Pages environment and current branch or commit.
REQUIREMENTS AND LIMITATIONS
- Version: 4.65.0
- [DIRECTORY]: Directory of static assets to serve.
- --binding=<KEY>=<VALUE>: Binds a variable or secret; use the Pages variable name and desired value to override it.
- CF_PAGES: Injected as `1` to indicate the Pages environment.
- CF_PAGES_BRANCH: Injected from the current Git branch, or `local` when Git branch detection is unavailable.
- CF_PAGES_COMMIT_SHA: Injected from the current Git commit SHA, or a zero SHA placeholder when Git commit detection is unavailable.
- CF_PAGES_URL: Injected as `https://<short-sha>.<project-name>.pages.dev`.
- `CF_PAGES_BRANCH` defaults to the current git branch, or `"local"` when not in a git repository.
- `CF_PAGES_COMMIT_SHA` defaults to the current git commit SHA, or a placeholder when not in a git repository.
- `CF_PAGES_URL` is a simulated commit preview URL.
FIRST-PARTY EVIDENCE
- https://github.com/cloudflare/workers-sdk/releases/tag/wrangler%404.65.0
- https://developers.cloudflare.com/workers/wrangler/commands/pages/
- https://developers.cloudflare.com/pages/functions/bindings/
- https://github.com/cloudflare/workers-sdk/blob/b900c5adc18c12d500e0fb8c58c2295843518695/packages/wrangler/src/pages/dev.ts
Check the installed version and the source before using it. Entry JSON