---
title: "Moving Cloudflare Pages Deploys to npm Scripts"
description: "A short operations note on adding deploy scripts to package.json so I don't have to remember wrangler commands every time I redeploy to Cloudflare Pages."
lang: "en"
canonical: "https://llm-lab.dev/en/posts/cloudflare-pages-deploy-script-note/"
source: "https://llm-lab.dev/en/posts/cloudflare-pages-deploy-script-note.md"
publishedAt: "2026-06-17"
updatedAt: "2026-06-17"
category: "技術メモ"
tags:
  - "cloudflare"
  - "cloudflare-pages"
  - "wrangler"
  - "npm"
---

# Moving Cloudflare Pages Deploys to npm Scripts

Deploying to Cloudflare Pages isn't difficult once you've done it the first time. But after a while, I find myself trying to remember the arguments for `wrangler pages deploy` every time.

This time, I added `deploy` and `deploy:build` scripts to my blog's `package.json`. `deploy` simply uploads the pre-built `dist` directory to Cloudflare Pages, while `deploy:build` runs `build` first and then performs the same deploy.

```bash
npm run deploy
npm run deploy:build
```

It's a small change, but pinning `project-name` and `branch` in the script lowers the cognitive load on redeploy. This is especially effective for a personal blog— a repo I don't touch every day.

Separating the "upload as-is" case from the "rebuild first" case also makes the intent explicit. I use `deploy` when I've already verified the site locally, and `deploy:build` when I've added a post or updated dependencies.

Cloudflare Pages works well with Git integration, but there are still times when I want to push explicitly from my local machine. When that happens, keeping it inside the project's npm scripts is lighter than digging up a long wrangler command from a note.
